NexusFi: Find Your Edge


Home Menu

 





Please HELP! Driving me NUTso


Discussion in NinjaTrader

Updated
    1. trending_up 2,040 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
Search this Thread

Please HELP! Driving me NUTso

  #1 (permalink)
 
Trader.Jon's Avatar
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
Posts: 473 since Jul 2009
Thanks Given: 401
Thanks Received: 184

Greets from my den of frustration ::

Trying to write a very basic MTF indicator from scratch, and getting a simple "does not exist in current context" message on the single DataSeries initialized in the indicator. I tried Print and it doesnt print out the value of the dataseries (of course) but I cant get it any simpler without not doing this at all!! And, no, it doesnt show data in the databox or plot either.

 
Code
#region Using declarations
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel;
using System.Xml.Serialization;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion

// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
	/// <summary>
	///  (BR5Close) is the Better Renko 5 CLOSE
	/// </summary>
	[Description("The BR5Close is a framework to have Better Renko OHLC available in trading systems as DATA.")]
	public class BR5Close : Indicator
	{
		#region Variables
		private int			thePeriod		= 5;
		
		private DataSeries sBR5Cl;
		#endregion

		protected override void Initialize()
		{
			Add(PeriodType.Custom4, thePeriod);  // BarsInProgress index = 1
			Add(new Plot(Color.Green, "BR5Cl"));
			Plots[0].Pen.DashStyle = DashStyle.Dot;
			sBR5Cl = new DataSeries(this);
			//
			CalculateOnBarClose	= true;
			DisplayInDataBox	= true;
			Overlay				= true;		
			PaintPriceMarkers	= true;
		}

		protected override void OnBarUpdate()
		{ 
			if (CurrentBar == 0)
			{
				if (BarsInProgress == 0)  //
			{
				Print("Value of 00 close = "+Closes[0][0]+", CurrentBar0#="+CurrentBars[0]+"Time of bar="+Time[0]+", CurrentBar1#="+CurrentBars[1]);
			}
		
			if (BarsInProgress == 1)  //Better Renko
			{
				sBR5Cl.Set(Close[0]);   
				// sBR5Cl.Set(Closes[0][0]); has the same problem 
				Print("Value of BR5 close = "+Closes[1][0]+", CurrentBar1#="+CurrentBars[1]+"Time of bar="+Time[0]+", bar0 closed "+Closes[0][0]+", Bar0HI="+Highs[0][0]+", Bar0LO="+Lows[0][0]+", CurrentBar00#="+CurrentBars[0]);
				Print("Value of BR5CI        = "+sBR5CI[0]);
			}
		}
		}
		#region Properties
		//
		[Description("Numbers of bars used for calculations")]
		[GridCategory("Parameters")]
		public int ThePeriod
		{
			get { return thePeriod; }
			set { thePeriod =  value; }
		}
		#endregion
	}
}
Printing shows the bars for both BIP 0 & BIP 1 ... but obviously not the Dataseries:

Quoting 
Value of BR5 close = 1.361, CurrentBar1#=3593Time of bar=3/3/2010 3:27:54 AM, bar0 closed 1.3605, Bar0HI=1.3605, Bar0LO=1.36, CurrentBar00#=9486
Value of 00 close = 1.361, CurrentBar0#=9487Time of bar=3/3/2010 3:28:12 AM, CurrentBar1#=3593
Value of BR5 close = 1.3615, CurrentBar1#=3594Time of bar=3/3/2010 3:28:32 AM, bar0 closed 1.361, Bar0HI=1.361, Bar0LO=1.3605, CurrentBar00#=9487
Value of 00 close = 1.3615, CurrentBar0#=9488Time of bar=3/3/2010 3:28:33 AM, CurrentBar1#=3594
Value of 00 close = 1.3613, CurrentBar0#=9489Time of bar=3/3/2010 3:29:20 AM, CurrentBar1#=3594
Value of 00 close = 1.361, CurrentBar0#=9490Time of bar=3/3/2010 3:30:55 AM, CurrentBar1#=3594
Value of 00 close = 1.3613, CurrentBar0#=9491Time of bar=3/3/2010 3:32:20 AM, CurrentBar1#=3594
Value of 00 close = 1.3613, CurrentBar0#=9492Time of bar=3/3/2010 3:34:07 AM, CurrentBar1#=3594
Value of 00 close = 1.3611, CurrentBar0#=9493Time of bar=3/3/2010 3:36:26 AM, CurrentBar1#=3594
Value of 00 close = 1.3608, CurrentBar0#=9494Time of bar=3/3/2010 3:38:37 AM, CurrentBar1#=3594
Value of 00 close = 1.3612, CurrentBar0#=9495Time of bar=3/3/2010 3:39:47 AM, CurrentBar1#=3594
Value of 00 close = 1.3609, CurrentBar0#=9496Time of bar=3/3/2010 3:43:13 AM, CurrentBar1#=3594
Value of BR5 close = 1.3605, CurrentBar1#=3595Time of bar=3/3/2010 3:43:56 AM, bar0 closed 1.3609, Bar0HI=1.3614, Bar0LO=1.3609, CurrentBar00#=9496
Value of 00 close = 1.361, CurrentBar0#=9497Time of bar=3/3/2010 3:45:01 AM, CurrentBar1#=3595

Can any astute observer of newbie code errors please reply!?

Thanks from the tips of my cold cramped fingers,
Jon

Writing to you from the wonderful province of Ontario, Canada. Home to the world's biggest natural negative ion generator, the Niagara Falls, and to those that dare to know how to go over it in a barrel. SALUTE!
Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
REcommedations for programming help
Sierra Chart
Better Renko Gaps
The Elite Circle
Cheap historycal L1 data for stocks
Stocks and ETFs
MC PL editor upgrade
MultiCharts
 
  #3 (permalink)
 gever17 
Cheyenne,Wyoming...USA
 
Experience: Beginner
Platform: NinjaTrader
Broker: Mirus Futures/Zen-Fire
Trading: NQ, YM
Posts: 69 since Nov 2010
Thanks Given: 329
Thanks Received: 54


Hi Jon,
I cant figure out what is wrong in your code but here is how I got mine to work.
Scotts webinar helped me out tremendously. Hopefully he will have one on MTF indys!!!

 
Code
                            
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
    
/// <summary>
    /// Shows an EMA from a different timeframe Range Bar Chart
    /// </summary>
    
[Description("Shows an EMA from a different timeframe Range Bar Chart")]
    public class 
EmaMtfOnRangeBars Indicator
    
{
        
#region Variables
               
private int altPeriod 8// Default setting for AltPeriod
            
private int eMAPeriod 89// Default setting for EMAPeriod
        #endregion
        
        
private EMA _EMA1;

        private 
bool _initialized false;
 
        protected 
override void Initialize()
        {
            
Add(new Plot (new Pen (Color.FromKnownColor(KnownColor.DarkOrchid), 2), PlotStyle.Line"EMA 1"));
            
Plots[0].Pen.DashStyle DashStyle.Dash;
            
            
CalculateOnBarClose    true;
            
DisplayInDataBox    false;
            
Overlay                true;        
            
PaintPriceMarkers    false;
            
            
Add(PeriodType.RangealtPeriod);
        }

        
        protected 
override void OnBarUpdate()
        {
            if (!
_initialized)
            {
                
_EMA1 = (EMA(BarsArray[1], eMAPeriod));    
                
_initialized true;
            }
            
            if (
CurrentBar <= eMAPeriod)
                return;
            
            
EMA1.Set (_EMA1 [0]);
        }

        
#region Properties
        
[Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
        
[XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
        
public DataSeries EMA1
        
{
            
get { return Values[0]; }
        }

        [
Description("Alternate Range Bar Period")]
        [
GridCategory("Parameters")]
        public 
int AltPeriod
        
{
            
get { return altPeriod; }
            
set altPeriod Math.Max(1value); }
        }

        [
Description("Period for EMA")]
        [
GridCategory("Parameters")]
        public 
int EMAPeriod
        
{
            
get { return eMAPeriod; }
            
set eMAPeriod Math.Max(1value); }
        }
        
#endregion
    
}


Reply With Quote
Thanked by:
  #4 (permalink)
 
Trader.Jon's Avatar
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
Posts: 473 since Jul 2009
Thanks Given: 401
Thanks Received: 184

OK .. so it compiles without errors.. but still wont plot, and data doesnt appear in the databox ... but it does print out ok .. anybody??
 
Code
{
	/// <summary>
	///  (R5Close) is the Range 5 CLOSE
	/// </summary>
	[Description("The R5Close is a framework to have Range5 Close available in trading systems as DATA.")]
	public class R5Close : Indicator
	{
		private int			thePeriod		= 5;
		public DataSeries sRange5Closes;
	
		protected override void Initialize()
		{	Add( PeriodType.Range, thePeriod);
			 Add(new Plot(new Pen (Color.FromKnownColor(KnownColor.ForestGreen), 3), PlotStyle.Line, "sRange5Closes"));
			Plots[0].Pen.DashStyle = DashStyle.Solid;
			sRange5Closes = new DataSeries (this); 
			//
			CalculateOnBarClose	= true;
			DisplayInDataBox	= true;
			Overlay				= true;			}

		protected override void OnBarUpdate()
		{ 			if (CurrentBar < 0 || CurrentBars[1] < 0)
						return; 
			{				if (BarsInProgress == 0)
		{	Print("BIP=0 close = "+Closes[0][0]+", CurrentBar0#="+CurrentBars[0]+"Time of bar0="+Times[0][0]+", Bar0HI="+Highs[0][0]+", Bar0LO="+Lows[0][0]);	}
		//
			if (BarsInProgress == 1)  
			{	sRange5Closes.Set(Closes[1][0]);   
				Print("BIP=1 close = "+Closes[1][0]+", CurrentBar1#="+CurrentBars[1]+"Time of bar1="+Times[1][0]+", Bar1HI="+Highs[1][0]+", Bar1LO="+Lows[1][0]);
				Print("Range5Close=        "+sRange5Closes[0]);			}
		}
		}
		#region Properties
			//
		[Description("Numbers of bars used for calculations")]
		[GridCategory("Parameters")]
		public int ThePeriod
		{
			get { return thePeriod; }
			set { thePeriod =  value; }
		}
		#endregion
	}
}

Writing to you from the wonderful province of Ontario, Canada. Home to the world's biggest natural negative ion generator, the Niagara Falls, and to those that dare to know how to go over it in a barrel. SALUTE!
Started this thread Reply With Quote
  #5 (permalink)
 
Trader.Jon's Avatar
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
Posts: 473 since Jul 2009
Thanks Given: 401
Thanks Received: 184

Gary,

IF I dont have a solution tomorrow I will try to modify yours ... thanks for the codes!

Jon

Writing to you from the wonderful province of Ontario, Canada. Home to the world's biggest natural negative ion generator, the Niagara Falls, and to those that dare to know how to go over it in a barrel. SALUTE!
Started this thread Reply With Quote




Last Updated on March 7, 2011


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts