What I would like to do is to use the command Draw.Dot(this, ...from a nested class.
From NinjaTrader Help, I understand that the NinjaScriptBase owner "this" has to be replaced by the NinjaScript object which is calling the draw method.
I tried to create a object of the main class within the nested class, its compiles but after that NinjaTrader crashes as soon as I intend to open the indicator window.
I've been through the help, the forum and google but i cant figure out what is the syntax for what should replace "this", any clue would be welcome.
namespace NinjaTrader.NinjaScript.Indicators
{
public class MainClass : Indicator
{
public class NestedClass: Indicator
{
public int Dot;
// MainClass mainClass = new MainClass(); //compiling but crashes NinjaTrader when any indicator is added to a chart
public void DRAW()
{
Dot += 1;
Print(String.Format("NestedClass Dot: {0}", Dot ));
Draw.Dot(this, String.Format("Dot{0}" , Dot ), true, 0, 1284, Brushes.Red); // compiling but doesnt display, "this": what I would like to replace
}
}
NestedClass nestedClass = new NestedClass();
protected override void OnBarUpdate()
{
if ( CurrentBars[0] < 1 ) return;
if ( High[0] > High[1]) nestedClass.DRAW(); // what I would like to do
// all below is OK
// if ( High[0] > High[1]) DRAW();
}
// public int Dot;
// public void DRAW()
// {
// Dot += 1;
// Draw.Dot(this, String.Format("Dot{0}" , Dot ), true, 0, High[0], Brushes.Red);
// }
}
}
Comment