Simple script showing values correctly on Daily but not lower TFs

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #158797 quote
    ashehzi
    Participant
    Average

    Hi all,

    I’ve a simple “Camarilla Levels” script for PRT. It used to display fine on all timeframes in PRT 10.3 but ever since moving to PRT 11, it shows correctly on daily but wrong values in lower TFs.

    Code is below

    defparam drawonlastbaronly = true
    
    //vertical offset to draw text correctly over horizontal lines
    //Voffset = 5*pipsize
    Voffset = 0// -3*pipsize
    textloc=barindex
    
    //yesterday's value
    highhtf = DHigh(1)
    lowhtf = DLow(1)
    closehtf=DClose(1)
    
    //Camarilla Pivot Point
    P = (highhtf + lowhtf + closehtf)/3
    RP= round(P)
    DRAWTEXT("                                                                                   CPiv #RP#",textloc,RP,SansSerif,Bold,11)//coloured(255,0,128)
    DRAWHLINE(RP)
    
    DRange = highhtf - lowhtf
    
    H5 = round((highhtf / lowhtf) * closehtf) // Breakout Target
    H4 = round(closehtf + DRange * 1.1/2)      // Bullish Breakout
    H3 = round(closehtf + DRange * 1.1/4)      // Sell Reversal
    //H2 = round(closehtf + DRange * 1.1/6)
    //H1 = round(closehtf + DRange * 1.1/12)
    //L1 = round(closehtf - DRange * 1.1/12)
    //L2 = round(closehtf - DRange * 1.1/6)
    L3 = round(closehtf - DRange * 1.1/4)      // Buy Reversal
    L4 = round(closehtf - DRange * 1.1/2)      // Bearish Breakout
    L5 = round(closehtf - (H5 - closehtf))    // Bearish Target
     
    
     
    //draw pivot points text
    DRAWTEXT("                                                                          BOT-H5 #H5#",textloc,H5+Voffset,SansSerif,Bold,12)coloured(255,0,128)
    DRAWTEXT("                                                                          BBO-H4 #H4#",textloc,H4+Voffset,SansSerif,Bold,12)coloured(0,200,0)
    DRAWTEXT("                                                                          SR-H3 #H3#",textloc,H3+Voffset,SansSerif,Bold,12)coloured(255,0,0)
    
    DRAWTEXT("                                                                          BR-L3 #L3#",textloc,L3+Voffset,SansSerif,Bold,12)//coloured(0,255,255)
    DRAWTEXT("                                                                          SBD-L4 #L4#",textloc,L4+Voffset,SansSerif,Bold,12)coloured(255,0,128)
    DRAWTEXT("                                                                          BDT-L5 #L5#",textloc,L5+Voffset,SansSerif,Bold,12)coloured(0,255,128)
     
    //draw pivot points lines with extension
    DRAWSEGMENT(barindex-4,H5,barindex,H5) //coloured(255,0,255)
    DRAWSEGMENT(barindex-4,H4,barindex,H4) //coloured(255,0,255)
    DRAWSEGMENT(barindex-4,H3,barindex,H3) //coloured(255,0,255)
    
    DRAWSEGMENT(barindex-4,L3,barindex,L3) //coloured(0,255,255)
    DRAWSEGMENT(barindex-4,L4,barindex,L4) //coloured(0,255,255)
    DRAWSEGMENT(barindex-4,L5,barindex,L5) //coloured(0,255,255)
     
    RETURN
    

    Any thoughts what could be the problem here?

    Regards

    Ash

    #158802 quote
    Nicolas
    Keymaster
    Master

    Indeed, there is sometimes strange behaviour of the code, coming from constants like Dopen or Dlow, I can replicate with the below code:

    defparam drawonlastbaronly = true
    
    //vertical offset to draw text correctly over horizontal lines
    //Voffset = 5*pipsize
    Voffset = 0// -3*pipsize
    textloc=barindex
    
    //yesterday's value
    highhtf = DHigh(1)
    lowhtf = DLow(1)
    closehtf=DClose(1)
    
    //Camarilla Pivot Point
    P = (highhtf + lowhtf + closehtf)/3
    RP= round(P)
    DRAWTEXT("                                                                                   CPiv #RP#",textloc,RP,SansSerif,Bold,11)//coloured(255,0,128)
    DRAWHLINE(RP)
    
    DRange = highhtf - lowhtf
    
    H5 = round((highhtf / lowhtf) * closehtf) // Breakout Target
    H4 = round(closehtf + DRange * 1.1/2)      // Bullish Breakout
    H3 = round(closehtf + DRange * 1.1/4)      // Sell Reversal
    //H2 = round(closehtf + DRange * 1.1/6)
    //H1 = round(closehtf + DRange * 1.1/12)
    //L1 = round(closehtf - DRange * 1.1/12)
    //L2 = round(closehtf - DRange * 1.1/6)
    L3 = round(closehtf - DRange * 1.1/4)      // Buy Reversal
    L4 = round(closehtf - DRange * 1.1/2)      // Bearish Breakout
    L5 = round(closehtf - (H5 - closehtf))    // Bearish Target
    
     
    //draw pivot points text
    DRAWTEXT("                                                                          BOT-H5 #H5#",textloc,H5+Voffset,SansSerif,Bold,12)coloured(255,0,128)
    DRAWTEXT("                                                                          BBO-H4 #H4#",textloc,H4+Voffset,SansSerif,Bold,12)coloured(0,200,0)
    DRAWTEXT("                                                                          SR-H3 #H3#",textloc,H3+Voffset,SansSerif,Bold,12)coloured(255,0,0)
    
    DRAWTEXT("                                                                          BR-L3 #L3#",textloc,L3+Voffset,SansSerif,Bold,12)//coloured(0,255,255)
    DRAWTEXT("                                                                          SBD-L4 #L4#",textloc,L4+Voffset,SansSerif,Bold,12)coloured(255,0,128)
    DRAWTEXT("                                                                          BDT-L5 #L5#",textloc,L5+Voffset,SansSerif,Bold,12)coloured(0,255,128)
     
    //draw pivot points lines with extension
    DRAWSEGMENT(barindex-4,H5,barindex,H5) //coloured(255,0,255)
    DRAWSEGMENT(barindex-4,H4,barindex,H4) //coloured(255,0,255)
    DRAWSEGMENT(barindex-4,H3,barindex,H3) //coloured(255,0,255)
    
    DRAWSEGMENT(barindex-4,L3,barindex,L3) //coloured(0,255,255)
    DRAWSEGMENT(barindex-4,L4,barindex,L4) //coloured(0,255,255)
    DRAWSEGMENT(barindex-4,L5,barindex,L5) //coloured(0,255,255)
     
    RETURN highhtf ,lowhtf ,closehtf

    I will ask what cause this issue, please feel free to launch a suppor ticket with a link to this thread, I’ll do the same. Thanks.

    dlow-problems.png dlow-problems.png
    #158821 quote
    ashehzi
    Participant
    Average

    I use IG PRT but where shall I raise the support ticket?

    Thanks.

    #158823 quote
    GraHal
    Participant
    Master
    #158893 quote
    Nicolas
    Keymaster
    Master

    If you are an IG customer use the support ticket tool in the platform Help menu.

    #159390 quote
    Nicolas
    Keymaster
    Master

    Topic moved to ProBuilder forum. I confirm that a fix is on his way for that issue.

    #159746 quote
    ashehzi
    Participant
    Average

    Thanks Nic.

    highhtf = DHigh(1)
    lowhtf = DLow(1)
    closehtf=DClose(1)

    Just a simple script to display above values will give different results on different time frames. Only daily is returning correct value because above values are Daily based.

    #162527 quote
    ashehzi
    Participant
    Average

    Hi,

     

    Any idea if this bug has been fixed?

     

    Thanks.

    #162534 quote
    Nicolas
    Keymaster
    Master

    I have no idea right now, but a workaround would be to use the daily timeframe to get the OHLC value:

    timeframe(daily, updateonclose)
    highhtf = high[1]
    lowhtf = Low[1]
    closehtf = Close[1]
    ashehzi thanked this post
    #162606 quote
    ashehzi
    Participant
    Average

    Thanks a lot Nic.

    Everyday is a learning day. I read somewhere Ale mentioning that MTF is there in new version but i was like it is only in scanners. I will be doing all my MTF porting from TV to PRT now. Thanks.

    Function timeframe opens many opportunities.

    #162607 quote
    ashehzi
    Participant
    Average

    Hi Nic,

    I modified the code such as

    defparam drawonlastbaronly = true
    
    
    //vertical offset to draw text correctly over horizontal lines
    //Voffset = 5*pipsize
    Voffset = 0// -3*pipsize
    textloc=barindex
    
    //yesterday's value
    timeframe(daily, updateonclose)
    highhtf = High[1]
    lowhtf = Low[1]
    closehtf=Close[1]
    
    //Camarilla Pivot Point
    P = (highhtf + lowhtf + closehtf)/3
    RP= round(P)
    DRAWTEXT("                                                                                   CPiv #RP#",textloc,RP,SansSerif,Bold,11)//coloured(255,0,128)
    DRAWHLINE(RP)
    
    DRange = highhtf - lowhtf
    
    H5 = round((highhtf / lowhtf) * closehtf) // Breakout Target
    H4 = round(closehtf + DRange * 1.1/2)      // Bullish Breakout
    H3 = round(closehtf + DRange * 1.1/4)      // Sell Reversal
    //H2 = round(closehtf + DRange * 1.1/6)
    //H1 = round(closehtf + DRange * 1.1/12)
    //L1 = round(closehtf - DRange * 1.1/12)
    //L2 = round(closehtf - DRange * 1.1/6)
    L3 = round(closehtf - DRange * 1.1/4)      // Buy Reversal
    L4 = round(closehtf - DRange * 1.1/2)      // Bearish Breakout
    L5 = round(closehtf - (H5 - closehtf))    // Bearish Target
     
    
     
    //draw pivot points text
    DRAWTEXT("                                                                          BOT-H5 #H5#",textloc,H5+Voffset,SansSerif,Bold,12)coloured(255,0,128)
    DRAWTEXT("                                                                          BBO-H4 #H4#",textloc,H4+Voffset,SansSerif,Bold,12)coloured(0,200,0)
    DRAWTEXT("                                                                          SR-H3 #H3#",textloc,H3+Voffset,SansSerif,Bold,12)coloured(255,0,0)
    
    DRAWTEXT("                                                                          BR-L3 #L3#",textloc,L3+Voffset,SansSerif,Bold,12)//coloured(0,255,255)
    DRAWTEXT("                                                                          SBD-L4 #L4#",textloc,L4+Voffset,SansSerif,Bold,12)coloured(255,0,128)
    DRAWTEXT("                                                                          BDT-L5 #L5#",textloc,L5+Voffset,SansSerif,Bold,12)coloured(0,255,128)
     
    //draw pivot points lines with extension
    DRAWSEGMENT(barindex-4,H5,barindex,H5) //coloured(255,0,255)
    DRAWSEGMENT(barindex-4,H4,barindex,H4) //coloured(255,0,255)
    DRAWSEGMENT(barindex-4,H3,barindex,H3) //coloured(255,0,255)
    
    DRAWSEGMENT(barindex-4,L3,barindex,L3) //coloured(0,255,255)
    DRAWSEGMENT(barindex-4,L4,barindex,L4) //coloured(0,255,255)
    DRAWSEGMENT(barindex-4,L5,barindex,L5) //coloured(0,255,255)
     
    RETURN
    

    The display is fine on Daily Chart but when I use lower TF charts, it doesn’t display anything.

    #162614 quote
    Nicolas
    Keymaster
    Master

    Because you are not switching to the default timeframe (the one displayed on the chart) in the code, add this line below line 13:

    timeframe(default)

    so all the below code will be read and used on the current timeframe displayed.

    ashehzi thanked this post
    #162622 quote
    ashehzi
    Participant
    Average

    I did that but it displays different values on 1D chart, and different values on lower timeframes charts but all lower timeframes have same values. i.e.

    values of 1D isn’t equal to values from 4h/2h/1h/30/15m while (4h=2h=1h=30m=15m)

    #162664 quote
    Nicolas
    Keymaster
    Master

    remove updateonclose for the daily timeframe instruction, it should be ok then.

    ashehzi thanked this post
    #162673 quote
    ashehzi
    Participant
    Average

    I see no benefit either way.

    I think this workaround doesn’t work. Bug needs proper fix.

Viewing 15 posts - 1 through 15 (of 17 total)
  • You must be logged in to reply to this topic.

Simple script showing values correctly on Daily but not lower TFs


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
ashehzi @ashehzi Participant
Summary

This topic contains 16 replies,
has 3 voices, and was last updated by Nicolas
4 years, 11 months ago.

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