ATR Timeframe on different timeframes

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #176511 quote
    robert123
    Participant
    Master

    Hi Nicholas and all.

    I have written a code snippet for retrieving the 7hr ATR on a 1 min TF, the same program is used throughout my trading and hence used on different TF’s, however now that the ATR snippet has been added it fails to work on the daily TF …for obvious reasons..

    My question is…with the use of a variable, do you think it would be possible to have the snippet turned off by default?

    I hope that makes sense, I have attached the snippet.

    TIA

    RR

    defparam drawonlastbaronly=true
    defparam calculateonlastbars=6000
    
    if time=93000 then
    
    US=open
    
    endif
    
    
    
    
    
    
    atrmid=us
    if close>atrmid then
    
    
    H4ext=atrmid+(aatr*2)
    DRAWtext("---------------H4ext",barindex[0],H4ext,dialog,bold,13)coloured (0,255,255)
    
    H3ext=atrmid+(aatr*1.5)
    DRAWtext("---------------H3ext",barindex[0],H3ext,dialog,bold,13)coloured (0,255,255)
    
    H2ext=atrmid+(aatr)
    DRAWtext("---------------H2ext",barindex[0],H2ext,dialog,bold,13)coloured (0,255,255)
    
    Hfull=atrmid+(aatr/2)
    DRAWtext("---------------Hfull",barindex[0],Hfull,dialog,bold,13)coloured (0,255,255)
    endif
    Hhalf=atrmid+(aatr/4)
    DRAWtext("---------------Hhalf",barindex[0],Hhalf,dialog,bold,13)coloured (0,255,255)
    
    
    atrmid=atrmid
    DRAWtext("---------------atrMID",barindex[0],atrmid,dialog,bold,13)coloured (0,255,255)
    
    
    Lhalf=atrmid[0]-(aatr/4)
    DRAWtext("---------------L",barindex[0],Lhalf,dialog,bold,13)coloured (0,255,255)
    if close<atrmid then
    L1=atrmid-(aatr/2)
    DRAWtext("--------------L1",barindex[0],L1,dialog,bold,13)coloured (0,255,255)
    
    Lfull=atrmid-(aatr)
    DRAWtext("--------------L1",barindex[0],L1,dialog,bold,13)coloured (0,255,255)
    
    
    L2ext=atrmid[0]-(aatr*1.5)
    DRAWtext("---------------Lfull",barindex[0],Lfull,dialog,bold,13)coloured (0,255,255)
    endif
    timeframe(7 hours,default)
    aatr=AverageTrueRange[14](close)
    
    return close
    #176512 quote
    robert123
    Participant
    Master

    Here is a picture….

    SPTRD-1-minute.png SPTRD-1-minute.png
    #176518 quote
    robertogozzi
    Moderator
    Master

    I added the boolean variable DISABLED which can be ticked/unticked:

    defparam drawonlastbaronly=true
    defparam calculateonlastbars=6000
    timeframe(7 hours,default)
    aatr=AverageTrueRange[14](close)
    timeframe(default)
    //ONCE Disabled = 0
    IF Disabled = 0 THEN
    if time=93000 then
    US=open
    endif
    atrmid=us
    if close>atrmid then
    H4ext=atrmid+(aatr*2)
    DRAWtext("---------------H4ext",barindex[0],H4ext,dialog,bold,13)coloured (0,255,255)
    H3ext=atrmid+(aatr*1.5)
    DRAWtext("---------------H3ext",barindex[0],H3ext,dialog,bold,13)coloured (0,255,255)
    H2ext=atrmid+(aatr)
    DRAWtext("---------------H2ext",barindex[0],H2ext,dialog,bold,13)coloured (0,255,255)
    Hfull=atrmid+(aatr/2)
    DRAWtext("---------------Hfull",barindex[0],Hfull,dialog,bold,13)coloured (0,255,255)
    endif
    Hhalf=atrmid+(aatr/4)
    DRAWtext("---------------Hhalf",barindex[0],Hhalf,dialog,bold,13)coloured (0,255,255)
    atrmid=atrmid
    DRAWtext("---------------atrMID",barindex[0],atrmid,dialog,bold,13)coloured (0,255,255)
    Lhalf=atrmid[0]-(aatr/4)
    DRAWtext("---------------L",barindex[0],Lhalf,dialog,bold,13)coloured (0,255,255)
    if close<atrmid then
    L1=atrmid-(aatr/2)
    DRAWtext("--------------L1",barindex[0],L1,dialog,bold,13)coloured (0,255,255)
     
    Lfull=atrmid-(aatr)
    DRAWtext("--------------L1",barindex[0],L1,dialog,bold,13)coloured (0,255,255)
     
     
    L2ext=atrmid[0]-(aatr*1.5)
    DRAWtext("---------------Lfull",barindex[0],Lfull,dialog,bold,13)coloured (0,255,255)
    endif
    endif
    return close
    x-11.jpg x-11.jpg MyInd.itf
    #176526 quote
    robert123
    Participant
    Master

    Thanks Roberto, this still fails to load on a daily TF (when the code is disabled) …comes up with a ‘multiples’ warning)

    RR

    #176527 quote
    robertogozzi
    Moderator
    Master

    Yes, the TF on your chart MUST be equal or lower that the LOWEST one used in your indicator. In you case you cannot use any TF greater than 7 hours.
    Even lower TFs must be such that 7 hours is a multiple of them. 1-min, 5-min, 6-min, 1h are fine, but NOT 9-min, NOT 2h because 7hours (420 minutes) is not a multiple of them.

    #176533 quote
    robert123
    Participant
    Master

    Thanks for your help Roberto, I take it that having this snippet transfer between a 1min chart and a daily is a none starter.

    RR

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

ATR Timeframe on different timeframes


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
robert123 @robert123 Participant
Summary

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

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