I am relatively new to NinjaTrader. I have been working with and writing NinjaScripts. I have a problem while using LowestBar() and HighestBar() with Bars.GetTime().
While it seems the values returned by HighestBar() and LowestBar() are correct the DateTime and highestbarsago & lowestbarsago will print incorrect values in Draw.TextFixed. The Print() will print the correct values but
Shouldn't this work?
highestbarsago = HighestBar(High, (CurrentBars[0] < LookBackMax ? CurrentBars[0] : LookBackMax)); // Limit HighestBar Lookback to input value
lowestbarsago = LowestBar(Low, (CurrentBars[0] < LookBackMax ? CurrentBars[0] : LookBackMax)); // Limit LowestBar Lookback to input value
rescaleoldmin = Low[lowestbarsago];
rescaleoldmax = High[highestbarsago];
rescaleoldrange = rescaleoldmax - rescaleoldmin;
dtmax = Bars.GetTime(highestbarsago);
dtmin = Bars.GetTime(lowestbarsago);
string str = "\n" + dtmax + " Bars: " + highestbarsago + " High: " + rescaleoldmax + "\n" + dtmin + " Bars: " + lowestbarsago + " Low: " + rescaleoldmin;
Draw.TextFixed(this, ProcDescript + "FixedTextBottomLeft", str, TextPosition.BottomLeft);
Print(ProcDescript + " CurrentBars[0]: " + CurrentBars[0] + " " + Bars.GetTime(CurrentBars[0]) + " highestbarsago: " + highestbarsago + " High: " + High[highestbarsago] +
" lowestbarsago: " + lowestbarsago + " Low: " + Low[lowestbarsago] + " rescaleoldmin: " + rescaleoldmin + " rescaleoldmax: " + rescaleoldmax +
" Reset Range Scale >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>");
Importantly it does yeild the correct vales for highestbarsago and lowestbarsago and rescaleoldmin & rscaleoldmax(correct High and Low values are attained). Problem is with Bars.GetTime(); It is not returning the correct Date Time for the barsago values. Is there something I may have missed? Test code attached.
Comment