I have a ninja7 strategy and want to convert it to 8.
It calculates the max and min value between a special period. it uses GetBar to do that and i converted it to this piece of code :
localZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneId);
startDate = TimeZoneInfo.ConvertTimeFromUtc(startDate, localZone);
endDate = TimeZoneInfo.ConvertTimeFromUtc(endDate, localZone);
startBarsAgo = Bars.GetBar(startDate);
endBarsAgo = Bars.GetBar(endDate);
nightSessionHigh = MAX(High, startBarsAgo - endBarsAgo + 1)[endBarsAgo];
nightSessionLow = MIN(Low, startBarsAgo - endBarsAgo + 1)[endBarsAgo];
it calculates two important values : startBarsAgo and startBarsAgo according to the time zone of PC. the it runs Bars.GetBar(startDate) and here i catch an exepction:
Value of property 'Period' of NinjaScript 'MAX' is -43692 and not in valid range between 1 and 2147483647.
The values of fields are
startBarsAgo : 618791
endBarsAgo : 662484
So what should i do?
Comment