I am trying to create an oscillator but it is not plotting anything. The Data Window says N/A.
I have printed all of the values to the Output Window and everything is printing correctly there so I assume that it is something in the way that I have told NT to write to the chart. But I can not find my error. Could you please help me with that?
I really appreciate it. I have highlighted and made bold the areas that I think are important for creating it to make it easier for you to see.
Thanks!
protected override void Initialize()
{
[COLOR="red"][B] Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
Add(new Line(Color.FromKnownColor(KnownColor.DarkOliveGreen), 0, "Distance"));
Overlay = false;[/B][/COLOR]
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (CurrentBar <= 4)
{
return;
}
if ((High[0] < High[2]
&& High[1] < High[2]
&& High[3] < High[2]
&& High[4] < High[2])
|| (High[0] < High[2]
&& High[1] == High[2]
&& High[3] < High[2]
&& High[4] < High[2]))
{
swingHigh = High[2];
}
if ((Low[0] > Low[2]
&& Low[1] > Low[2]
&& Low[3] > Low[2]
&& Low[4] > Low[2])
|| (Low[0] > Low[2]
&& Low[1] == Low[2]
&& Low[3] > Low[2]
&& Low[4] > Low[2]))
{
SL1 = true;
SLValue1 = Low[2];
Print("SLValue1 = " + SLValue1);
}
if ((SL1 == true
&& Low[0] > Low[2]
&& Low[1] > Low[2]
&& Low[3] > Low[2]
&& Low[4] > Low[2])
|| (SL1 == true
&& Low[0] > Low[2]
&& Low[1] == Low[2]
&& Low[3] > Low[2]
&& Low[4] > Low[2]))
{
SL2 = true;
SLValue2 = Low[2];
Print("SLValue2 = " + SLValue2);
}
if (SL1 == true
&& SL2 == true
&& swingHigh > 0)
{
distance = swingHigh - SLValue1;
Print(distance *10000);
[B][COLOR="Red"]Plot0.Set(distance * 10000);[/COLOR][/B]
swingHigh = 0;
SL2 = false;
SLValue1 = SLValue2;
Print("Submit Oscillator");
}
}

Comment