Recently PRT introduced, along with version 11, new options to use graphic drawing tools to plot into future bars, a long awaited feature.
The easiest way is to simply add an offset to BarIndex, such as BarIndex + 5.
There are time, though, when you don’t know the correct value of that BarIndex number. Here comes in handy the new keyword DateToBarIndex(MyDate), to be used with graphic drawing instructions. PRT’s engine will calculate the correct BarIndex number to be used. It’s very useful if you need to draw segments from, say, the beginning of the day through the end of the day. Some instruments trade 24 hours, other less. You don’t have to care about this, the new keyword will!
More at https://www.prorealcode.com/documentation/datetobarindex/.
This is an example on how to use it. It plots Pivot lines at the beginning of each day, through the end of the day:
DEFPARAM DrawOnLastBarOnly = true
//
IF OpenDay <> OpenDay[1] THEN
//
Pips = 20 * pipsize
StartBar = BarIndex
//
// PredeEndDated PRT calculation (H+L+C)/3
Pivt = (DHigh(1) + DLow(1) + DClose(1))/3 // - Pivot
Res3 = DHigh(1)+(2*(Pivt-DLow(1))) //Res3
Res2 = Pivt+(DHigh(1)-DLow(1)) //Res2
Res1 = (2*Pivt) - DLow(1) //Res1
Sup1 = (2*Pivt) - DHigh(1) //Sup1
Sup2 = Pivt-(DHigh(1)-DLow(1)) //Sup2
Sup3 = DLow(1)-(2*(DHigh(1)-Pivt)) //Sup3
//
MyYear = OpenYear
MyMonth = OpenMonth
MyDay = OpenDay
// pack Year, Month and Day into YYYYMMDD
MyDate = (MyYear * 10000000000) + (MyMonth * 100000000) + (MyDay * 1000000)
// add HHMMSS
EndDate = MyDate + (23 * 10000) + (0 * 100) + 0
ENDIF
// plot Pivot at (unknown)barindex of date YYYYMMMDDHHMMSS
DRAWSEGMENT(StartBar,Pivt,DateToBarIndex(EndDate),Pivt) coloured(0,128,0,255) STYLE(dottedline,1)
DRAWTEXT("Pvt #Pivt#",DateToBarIndex(EndDate),Pivt+Pips) coloured(0,128,0,255)
// plot Resistance levels
DRAWSEGMENT(StartBar,Res1,DateToBarIndex(EndDate),Res1) coloured(255,0,0,255) STYLE(dottedline,1)
DRAWTEXT("R1 #Res1#",DateToBarIndex(EndDate),Res1+Pips) coloured(255,0,0,255)
DRAWSEGMENT(StartBar,Res2,DateToBarIndex(EndDate),Res2) coloured(0,0,255,255) STYLE(dottedline,1)
DRAWTEXT("R2 #Res2#",DateToBarIndex(EndDate),Res2+Pips) coloured(0,0,255,255)
DRAWSEGMENT(StartBar,Res3,DateToBarIndex(EndDate),Res3) coloured(0,128,128,255) STYLE(dottedline,1)
DRAWTEXT("R3 #Res3#",DateToBarIndex(EndDate),Res3+Pips) coloured(0,128,128,255)
// plot Support levels
DRAWSEGMENT(StartBar,Sup1,DateToBarIndex(EndDate),Sup1) coloured(255,0,0,64) STYLE(dottedline,1)
DRAWTEXT("S1 #Sup1#",DateToBarIndex(EndDate),Sup1+Pips) coloured(255,0,0,64)
DRAWSEGMENT(StartBar,Sup2,DateToBarIndex(EndDate),Sup2) coloured(0,0,255,64) STYLE(dottedline,1)
DRAWTEXT("S2 #Sup2#",DateToBarIndex(EndDate),Sup2+Pips) coloured(0,0,255,64)
DRAWSEGMENT(StartBar,Sup3,DateToBarIndex(EndDate),Sup3) coloured(0,128,128,64) STYLE(dottedline,1)
DRAWTEXT("S3 #Sup3#",DateToBarIndex(EndDate),Sup3+Pips) coloured(0,128,128,64)
RETURN