ATR Tralingstop help
Forums › ProRealTime English forum › ProOrder support › ATR Tralingstop help
- This topic has 2 replies, 3 voices, and was last updated 3 years ago by nonetheless.
-
-
03/04/2021 at 11:37 PM #163154
Basically I came over this ATRtraling stop, I think it made by GraHal so thanks to him. I’m not so used to ATR but I think it works good though. Problem is that I can’t really understand the different parameters and what they mean. So if someone please can help me understand ill be grateful.
What I’m wondering about:12345678910once tsincrements = // set to 0 to ignore tsincrementsonce tsminatrdist =once tsatrperiod = // ts atr parameteronce tsminstop = // ts minimum stop distanceonce tssensitivity = // [0]close;[1]high/lowtrailingstoplong = // ts atr distancetrailingstopshort = // ts atr distanceWhat parameters can I optimize and what should be set to standard values? What values is okey to use to not overoptimize can I use decimals on some of these values or will it be a bit to much? Please give me some tips 🙂
Whole ATR CODE:
Whole ATR Code12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697// %trailing stop function incl. cumulative positionsonce tsincrements = // set to 0 to ignore tsincrementsonce tsminatrdist =once tsatrperiod = // ts atr parameteronce tsminstop = // ts minimum stop distanceonce tssensitivity = // [0]close;[1]high/lowif barindex=tradeindex thentrailingstoplong = // ts atr distancetrailingstopshort = // ts atr distanceelseif longonmarket thenif tsnewsl>0 thenif trailingstoplong>tsminatrdist thenif tsnewsl>tsnewsl[1] thentrailingstoplong=trailingstoplongelsetrailingstoplong=trailingstoplong-tsincrementsendifelsetrailingstoplong=tsminatrdistendifendifendifif shortonmarket thenif tsnewsl>0 thenif trailingstopshort>tsminatrdist thenif tsnewsl<tsnewsl[1] thentrailingstopshort=trailingstopshortelsetrailingstopshort=trailingstopshort-tsincrementsendifelsetrailingstopshort=tsminatrdistendifendifendifendiftsatr=averagetruerange[tsatrperiod]((close/10)*pipsize)/1000//tsatr=averagetruerange[tsatrperiod]((close/1)*pipsize) // (forex)tgl=round(tsatr*trailingstoplong)tgs=round(tsatr*trailingstopshort)if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) thentsmaxprice=0tsminprice=closetsnewsl=0endifif tssensitivity thentssensitivitylong=hightssensitivityshort=lowelsetssensitivitylong=closetssensitivityshort=closeendifif longonmarket thentsmaxprice=max(tsmaxprice,tssensitivitylong)if tsmaxprice-tradeprice(1)>=tgl*pointsize thenif tsmaxprice-tradeprice(1)>=tsminstop thentsnewsl=tsmaxprice-tgl*pointsizeelsetsnewsl=tsmaxprice-tsminstop*pointsizeendifendifendifif shortonmarket thentsminprice=min(tsminprice,tssensitivityshort)if tradeprice(1)-tsminprice>=tgs*pointsize thenif tradeprice(1)-tsminprice>=tsminstop thentsnewsl=tsminprice+tgs*pointsizeelsetsnewsl=tsminprice+tsminstop*pointsizeendifendifendifif longonmarket thenif tsnewsl>0 thensell at tsnewsl stopendifif tsnewsl>0 thenif low crosses under tsnewsl thensell at market // when stop is rejectedendifendifendifif shortonmarket thenif tsnewsl>0 thenexitshort at tsnewsl stopendifif tsnewsl>0 thenif high crosses over tsnewsl thenexitshort at market // when stop is rejectedendifendifendif/ tompa3
03/05/2021 at 10:09 AM #16317703/05/2021 at 11:06 AM #163189once tsincrements = // usually 0 – 0.2, effects how quickly the stop will trail
once tsminatrdist = // 0 – 3, but this setting often has no effect at allonce tsatrperiod = // typically 14, how many periods it looks back – not worth optimizing
once tsminstop = // enter the minimum stop distance as set by IG, DJ = 12, NAS = 4, DAX = 5 etconce tssensitivity = // [0]close;[1]high/low //this chooses how the stop is triggered: 0 = when price closes above/below the trigger level, 1 = previous candle high above trigger or low if short
trailingstoplong = // ts atr distance // typically 3-10, this is the most important setting
trailingstopshort = // ts atr distance // as above but usually worth optimizing separatelyTake note of line 43 if you’re trading Forex (ie use 43 and // line 42)
I think Paul gets the credit for this TS, this is his revised version which will also work with cumulative orders. Note that he advises NOT to use ONCE with tssensitivity
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118// trailing atr stop incl. cumulative positionsonce trailingstoptype2 = 1if trailingstoptype2 = 1 then//====================once tsincrements = tsi // set to 0 to ignore tsincrementsonce tsminatrdist = tsmonce tsatrperiod = 14 // ts atr parameteronce tsminstop = IG // ts minimum stop distancetssensitivity = 2 // [1] default [2] high/low [3] low/high [4] typicalprice (not use once)//====================if barindex=tradeindex thentrailingstoplong = tsl // ts atr distancetrailingstopshort = tss // ts atr distanceelseif longonmarket thenif tsnewsl>0 thenif trailingstoplong>tsminatrdist thenif tsnewsl>tsnewsl[1] thentrailingstoplong=trailingstoplongelsetrailingstoplong=trailingstoplong-tsincrementsendifelsetrailingstoplong=tsminatrdistendifendifendifif shortonmarket thenif tsnewsl>0 thenif trailingstopshort>tsminatrdist thenif tsnewsl<tsnewsl[1] thentrailingstopshort=trailingstopshortelsetrailingstopshort=trailingstopshort-tsincrementsendifelsetrailingstopshort=tsminatrdistendifendifendifendiftsatr=averagetruerange[tsatrperiod]((close/10))/1000//tsatr=averagetruerange[tsatrperiod]((close/1)) // (forex)tgl=round(tsatr*trailingstoplong)tgs=round(tsatr*trailingstopshort)if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) thentsmaxprice=0tsminprice=closetsnewsl=0mypositionpriceatr = 0endifpositioncountatr = abs(countofposition)if tsnewsl > 0 thenif positioncountatr > positioncountatr[1] thenif longonmarket thentsnewsl = max(tsnewsl,positionprice * tsnewsl / mypositionpriceatr)elsetsnewsl = min(tsnewsl,positionprice * tsnewsl / mypositionpriceatr)endifendifendifif tssensitivity=1 thentssensitivitylong=closetssensitivityshort=closeelsif tssensitivity=2 thentssensitivitylong=hightssensitivityshort=lowelsif tssensitivity=3 thentssensitivitylong=lowtssensitivityshort=highelsif tssensitivity=4 thentssensitivitylong=typicalpricetssensitivityshort=typicalpriceendifif longonmarket thentsmaxprice=max(tsmaxprice,tssensitivitylong)if tsmaxprice-positionprice>=tgl*pointsize thenif tsmaxprice-positionprice>=tsminstop thentsnewsl=tsmaxprice-tgl*pointsizeelsetsnewsl=tsmaxprice-tsminstop*pointsizeendifendifendifif shortonmarket thentsminprice=min(tsminprice,tssensitivityshort)if positionprice-tsminprice>=tgs*pointsize thenif positionprice-tsminprice>=tsminstop thentsnewsl=tsminprice+tgs*pointsizeelsetsnewsl=tsminprice+tsminstop*pointsizeendifendifendifif longonmarket thenif tsnewsl>0 thensell at tsnewsl stopendifif tsnewsl>0 thenif low crosses under tsnewsl thensell at market // when stop is rejectedendifendifendifif shortonmarket thenif tsnewsl>0 thenexitshort at tsnewsl stopendifif tsnewsl>0 thenif high crosses over tsnewsl thenexitshort at market // when stop is rejectedendifendifendifmypositionpriceatr = positionpriceendif3 users thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on