ATR Timeframe on different timeframes
Forums › ProRealTime English forum › ProBuilder support › ATR Timeframe on different timeframes
- This topic has 5 replies, 2 voices, and was last updated 3 years ago by robert123.
-
-
08/31/2021 at 8:38 AM #176511
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
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455defparam drawonlastbaronly=truedefparam calculateonlastbars=6000if time=93000 thenUS=openendifatrmid=usif close>atrmid thenH4ext=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)endifHhalf=atrmid+(aatr/4)DRAWtext("---------------Hhalf",barindex[0],Hhalf,dialog,bold,13)coloured (0,255,255)atrmid=atrmidDRAWtext("---------------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 thenL1=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)endiftimeframe(7 hours,default)aatr=AverageTrueRange[14](close)return close08/31/2021 at 8:42 AM #17651208/31/2021 at 9:26 AM #176518I added the boolean variable DISABLED which can be ticked/unticked:
12345678910111213141516171819202122232425262728293031323334353637383940defparam drawonlastbaronly=truedefparam calculateonlastbars=6000timeframe(7 hours,default)aatr=AverageTrueRange[14](close)timeframe(default)//ONCE Disabled = 0IF Disabled = 0 THENif time=93000 thenUS=openendifatrmid=usif close>atrmid thenH4ext=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)endifHhalf=atrmid+(aatr/4)DRAWtext("---------------Hhalf",barindex[0],Hhalf,dialog,bold,13)coloured (0,255,255)atrmid=atrmidDRAWtext("---------------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 thenL1=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)endifendifreturn close08/31/2021 at 10:37 AM #17652608/31/2021 at 11:18 AM #176527Yes, 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.08/31/2021 at 11:50 AM #176533 -
AuthorPosts
Find exclusive trading pro-tools on