I was testing a piece of code to draw segments in the future with this code (Dax, Daily TF) using DateToBarIndex:
GG = 6
MyDay = OpenDay
MyMonth = OpenMonth
MyYear = OpenYear
DayMax = 31
TestX = 1
MyGG = GG
WHILE Test = 1
IF MyMonth = 4 OR MyMonth = 6 OR MyMonth = 9 OR Month = 11 THEN
DayMax = 30
ELSIF MyMonth = 2 THEN
DayMax = 28
IF Year MOD 4 = 0 THEN
IF Year MOD 100 = 0 THEN
IF Year MOD 400 = 0 THEN
DayMax = 29
ENDIF
ELSE
DayMax = 29
ENDIF
ENDIF
ENDIF
MyDay = MyDay + MyGG
IF MyDay <= DayMax THEN
Test = 0
ELSE
MyDay = MyDay - DayMax
MyMonth = MyMonth + 1
IF MyMonth = 13 THEN
MyMonth = 1
MyYear = MyYear + 1
ENDIF
DayMax = 31
MyGG = 0
ENDIF
WEND
MyDate = (MyYear * 10000) + (MyMonth * 100) + MyDay
DRAWSEGMENT(barindex,high,DateToBarIndex(MyDate),high)
RETURN
at line it only accepts, as an offset into the future, from 2 to 31 days, otherwise an error is reported as from attached pics (Draw1 is correct, with 31, while Draw2 returned an error as soon as I incremented the variable to 32).
Is this a limit or a bug?
Making it a strategy and GRAPHing all variables, the future dates calculated are GRAPHed correctly, so there should be no error in the calculation code.