namespace NinjaTrader.NinjaScript.Indicators
{
// [TypeConverter("NinjaTrader.NinjaScript.Indicators. PivotsTypeConverter")]
public class HighLowRange: Indicator
{
private double sum, lowestPrice, highestPrice, fractal;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Plot High / Low of a certain range";
Name = "HighLowRange";
Calculate = Calculate.OnBarClose;
DisplayInDataBox = false;
DrawOnPricePanel = false;
IsAutoScale = false;
IsOverlay = true;
PaintPriceMarkers = true;
ScaleJustification = ScaleJustification.Right;
iLookBackPeriodBars = 64;
AddPlot(Brushes.Red, "H88");
AddPlot(Brushes.Green, "L08");
}
}
protected override void OnBarUpdate()
{
lowestPrice = MIN(Low, li_LookBack)[0];
highestPrice = MAX(High, li_LookBack)[0];
}
}
}
This gives completely false values.
I also tried it with determining of the index
lowestPrice = Low[LowestBar(Low, li_LookBack)];
highestPrice = High[HighestBar(High, li_LookBack)];
However this also is not retrieving the correct values
Only if I determine the values when processing just the last Bar and putting in the condition
if(Count - CurrentBar > 2)
before the calculation does it retrieve the correct value, however this messes up the plots and everything else that comes afterwards.
Please advice. Thank you
Comment