Please HELP! Driving me NUTso - futures io
futures io



Please HELP! Driving me NUTso


Discussion in NinjaTrader

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




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Please HELP! Driving me NUTso

(login for full post details)
  #1 (permalink)
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
 
Trader.Jon's Avatar
 
Posts: 500 since Jul 2009
Thanks: 401 given, 183 received

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

Journal Challenge April 2021 results (now extended!):
Competing for $1800 in prizes from Jigsaw
looks_oneMaking a Living with the Microsby sstheo
(107 thanks from 17 posts)
looks_twoSalao's Journalby Salao
(33 thanks from 8 posts)
looks_3Deetee’s DAX Trading Journal (time based)by Deetee
(28 thanks from 11 posts)
looks_4Learning to Profit - A journey in algorithms and optionsby Syntax
(14 thanks from 9 posts)
looks_5Maybe a little bit different journalby Malykubo
(9 thanks from 8 posts)
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Would You Sell Your System?
73 thanks
The Crude Dude Oil Trading System
44 thanks
Big Mike in Ecuador
41 thanks
The New Micro Contract - MICRO BITCOIN coming May 2021
25 thanks
futures io site changelog and issues/problem reporting
24 thanks
 
(login for full post details)
  #3 (permalink)
 gever17 
Cheyenne,Wyoming...USA
 
Experience: Beginner
Platform: NinjaTrader
Broker: Mirus Futures/Zen-Fire
Trading: NQ, YM
 
Posts: 69 since Nov 2010
Thanks: 329 given, 54 received


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
The following user says Thank You to gever17 for this post:
 
(login for full post details)
  #4 (permalink)
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
 
Trader.Jon's Avatar
 
Posts: 500 since Jul 2009
Thanks: 401 given, 183 received

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
 
(login for full post details)
  #5 (permalink)
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
 
Trader.Jon's Avatar
 
Posts: 500 since Jul 2009
Thanks: 401 given, 183 received

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


futures io Trading Community Platforms and Indicators NinjaTrader > Please HELP! Driving me NUTso


Last Updated on March 7, 2011


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1,800 in prizes!

April

Seven Trading Mistakes Solved With Smart Trading Tools w/Brannigan Barrett

Elite only
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts