Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
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 for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Please HELP! Driving me NUTso
Updated March 8, 2011
trending_up
2,040 views
thumb_up
1 thanks given
group
2 followers
forum
4 posts
attach_file
0 attachments
Please HELP! Driving me NUTso
March 7th, 2011, 06:30 PM
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!
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
March 7th, 2011, 08:29 PM
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 . Range , altPeriod ); } 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 ( 1 , value ); } } [ Description ( "Period for EMA" )] [ GridCategory ( "Parameters" )] public int EMAPeriod { get { return eMAPeriod ; } set { eMAPeriod = Math . Max ( 1 , value ); } } #endregion } }
March 7th, 2011, 11:29 PM
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!
March 7th, 2011, 11:33 PM
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!
Last Updated on March 7, 2011