Central Pivot point with Top and bottom Buffer

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #175302 quote
    oyinloyea
    Participant
    Veteran

    I wrote a code shown below

    DefParam DrawOnLastBarOnly = true
    
    H1 = DHigh(1)
    
    L1 = DLow(1)
    
    C1 = DClose(1)
    
    PDC=c1
    
    PDH=H1
    
    PDL=L1
    
    PPDAY = (H1 + L1 + C1) / 3
    
    BCPRT=((H1 + L1)/2 )-10
    
    BCPR= (H1 + L1)/2
    
    TCPR =(PPDay-BCPR)+PPDay
    
    TCPRT=((PPDay-BCPR)+PPDay) +10
    
    DRAWsegment(barindex-1,PPDay,barindex,PPDay)
    
    DRAWsegment(barindex-1,BCPR,barindex,BCPR)
    
    DRAWsegment(barindex-1,TCPR,barindex,TCPR)
    
    drawtext(“TCPR”,barindex,TCPR,SansSerif,Bold,13)
    
    drawtext(“BCPR”,barindex,BCPR,SansSerif,Bold,13)
    
    drawtext(“PPDay”,barindex,PPDay,SansSerif,Bold,13)
    
    //drawtext(“PDC”,barindex,PDC,SansSerif,Bold,13)
    
     
    
    RETURN TCPR AS ” TCPR” ,BCPR AS “BCPR”, PPDay as “PPDay”

    I  want to put condition on this code

    At times BCPR is greater than TCPR

    So I will like to add

    If BCPR is greater than TCPR then

     

    BCPR=((H1 + L1)/2 )+10

    TCPR=((PPDay-BCPR)+PPDay) -10

     

    If TCPR is greater than BTCPR then

    TCPR=((H1 + L1)/2 )+10

    BCPR=((PPDay-BCPR)+PPDay) -10

    #175306 quote
    robertogozzi
    Moderator
    Master

    There you go:

    DefParam DrawOnLastBarOnly = true
    H1 = DHigh(1)
    L1 = DLow(1)
    C1 = DClose(1)
    PDC=c1
    PDH=H1
    PDL=L1
    PPDAY = (H1 + L1 + C1) / 3
    BCPRT=((H1 + L1)/2 )-10
    BCPR= (H1 + L1)/2
    TCPR =(PPDay-BCPR)+PPDay
    TCPRT=((PPDay-BCPR)+PPDay) +10
    ///////////////////////////////
    If BCPR > TCPR then
    BCPR=((H1 + L1)/2 )+10
    TCPR=((PPDay-BCPR)+PPDay) -10
    ELSIf TCPR > BCPR then
    TCPR=((H1 + L1)/2 )+10
    BCPR=((PPDay-BCPR)+PPDay) -10
    ENDIF
    //////////////////////////////
    DRAWsegment(barindex-1,PPDay,barindex,PPDay)
    DRAWsegment(barindex-1,BCPR,barindex,BCPR)
    DRAWsegment(barindex-1,TCPR,barindex,TCPR)
    drawtext("TCPR",barindex,TCPR,SansSerif,Bold,13)
    drawtext("BCPR",barindex,BCPR,SansSerif,Bold,13)
    drawtext("PPDay",barindex,PPDay,SansSerif,Bold,13)
    //drawtext("PDC",barindex,PDC,SansSerif,Bold,13)
    RETURN TCPR AS " TCPR" ,BCPR AS "BCPR", PPDay as "PPDay"
    #175314 quote
    oyinloyea
    Participant
    Veteran

    Thanks for the prompt response.I have re-written it but it is showing blank. Please help

    //DefParam DrawOnLastBarOnly = true
    H1 = DHigh(1)
    L1 = DLow(1)
    C1 = DClose(1)
    PDC=c1
    PDH=H1
    PDL=L1
    PPDAY = (H1 + L1 + C1) / 3
    BCPR= (H1 + L1)/2
    TCPR =(PPDay-BCPR)+PPDay
    
    ///////////////////////////////
    If BCPR > TCPR then
    BCPRT=((H1 + L1)/2 )+10
    TCPRT=((PPDay-BCPR)+PPDay) -10
    ELSIf TCPR > BCPR then
    TCPRT=((H1 + L1)/2 )+10
    BCPRT=((PPDay-BCPR)+PPDay) -10
    ENDIF
    
    //////////////////////////////
    DRAWsegment(barindex-1,PPDay,barindex,PPDay)
    DRAWsegment(barindex-1,BCPR,barindex,BCPR)
    DRAWsegment(barindex-1,TCPR,barindex,TCPR)
    DRAWsegment(barindex-1,BCPRT,barindex,BCPRt)
    DRAWsegment(barindex-1,TCPRT,barindex,TCPRT)
    drawtext(“TCPR”,barindex,TCPR,SansSerif,Bold,13)
    drawtext(“BCPR”,barindex,BCPR,SansSerif,Bold,13)
    drawtext(“PPDay”,barindex,PPDay,SansSerif,Bold,13)
    drawtext(“TCPRT”,barindex,TCPRT,SansSerif,Bold,13)
    drawtext(“BCPRT”,barindex,BCPRT,SansSerif,Bold,13)
    //drawtext(“PDC”,barindex,PDC,SansSerif,Bold,13)
    RETURN TCPR AS ” TCPR” ,BCPR AS “BCPR”, PPDay as “PPDay”,TCPRT AS ” TCPRT” ,BCPRT AS “BCPRT”
    #175329 quote
    robertogozzi
    Moderator
    Master

    I’ll check next week.

    #175526 quote
    robertogozzi
    Moderator
    Master

    It works fine, with 10K units (if you use 200K units, then you’ll have to wait some time).

    I added +5 to BARINDEX when displaying text, so it is plotted in the future (a feature added in v11) and doesn’t make a mess with data lines:

    DefParam DrawOnLastBarOnly = true
    H1 = DHigh(1)
    L1 = DLow(1)
    C1 = DClose(1)
    PDC=c1
    PDH=H1
    PDL=L1
    PPDAY = (H1 + L1 + C1) / 3
    BCPR= (H1 + L1)/2
    TCPR =(PPDay-BCPR)+PPDay
     
    ///////////////////////////////
    If BCPR > TCPR then
    BCPRT=((H1 + L1)/2 )+10
    TCPRT=((PPDay-BCPR)+PPDay) -10
    ELSIf TCPR > BCPR then
    TCPRT=((H1 + L1)/2 )+10
    BCPRT=((PPDay-BCPR)+PPDay) -10
    ENDIF
     
    //////////////////////////////
    DRAWsegment(barindex-1,PPDay,barindex,PPDay)
    DRAWsegment(barindex-1,BCPR,barindex,BCPR)
    DRAWsegment(barindex-1,TCPR,barindex,TCPR)
    DRAWsegment(barindex-1,BCPRT,barindex,BCPRt)
    DRAWsegment(barindex-1,TCPRT,barindex,TCPRT)
    drawtext("TCPR",barindex+5,TCPR,SansSerif,Bold,13)
    drawtext("BCPR",barindex+5,BCPR,SansSerif,Bold,13)
    drawtext("PPDay",barindex+5,PPDay,SansSerif,Bold,13)
    drawtext("TCPRT",barindex+5,TCPRT,SansSerif,Bold,13)
    drawtext("BCPRT",barindex+5,BCPRT,SansSerif,Bold,13)
    //drawtext("PDC",barindex,PDC,SansSerif,Bold,13)
    RETURN TCPR AS " TCPR" ,BCPR AS "BCPR", PPDay as "PPDay",TCPRT AS " TCPRT" ,BCPRT AS "BCPRT"
    x-8.jpg x-8.jpg
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Central Pivot point with Top and bottom Buffer


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
oyinloyea @oyinloyea Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by robertogozzi
4 years, 5 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 08/14/2021
Status: Active
Attachments: 1 files
Logo Logo
Loading...