PIVOT lines drawn into the future (v11 only)

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #123922 quote
    robertogozzi
    Moderator
    Master

    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
    Nicolas thanked this post
    x-9.jpg x-9.jpg PIVOT-grid-into-Future.itf
    #123934 quote
    robertogozzi
    Moderator
    Master

    Example to pack single data into a YYYYMMDDHHMMSS date:

    YYYY = 2020
    MM   = 03
    DD   = 30
    HH   = 11
    MM   = 26
    SS   = 15
    
    YYYY * 10000000000 = 20200000000000 +
    MM   *   100000000 =     0300000000 +
    DD   *     1000000 =       30000000 +
    HH   *       10000 =         110000 +
    MM   *         100 =           2600 +
    SS   *           1 =             15 =
                         --------------
                         20200330112615
                         YYYYMMDDHHMMSS
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

PIVOT lines drawn into the future (v11 only)


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 1 reply,
has 1 voice, and was last updated by robertogozzi
5 years, 10 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 03/30/2020
Status: Active
Attachments: 2 files
Logo Logo
Loading...