Normal atr trailingstop
Forums › ProRealTime English forum › ProOrder support › Normal atr trailingstop
- This topic has 42 replies, 5 voices, and was last updated 2 years ago by Franro.
Tagged: atr, atr trailing stop, graph, GRAPHONPRICE, stop, trailing, trailing stop
-
-
04/14/2022 at 9:02 AM #1917451graph AverageTrueRange[atrtrailingperiod](close)04/14/2022 at 9:03 AM #191746
To plot prices on the chart GRAPHONPRICE is best suited.
04/14/2022 at 10:26 AM #19175204/14/2022 at 10:55 AM #191754To answer unequivocally, with a Yes or No, we would have to set up the Trailing Stop and the GRAPH in the code.
We are also, at the same time, trying to get our own code / Systems working robustly (and living our lives etc 🙂 ).
I like to see things through to a conclusion, so I will set up the TS on XBT / USD later or might be tomorrow and let you know my findings. Hopefully I will learn something in the process! 🙂
If anybody wants to contribute in the meantime, feel free.
1 user thanked author for this post.
04/14/2022 at 11:27 AM #19175604/14/2022 at 2:06 PM #19175904/14/2022 at 2:10 PM #19176004/14/2022 at 4:09 PM #191762This does not graph the distance from ONCE trailingstoplong = 10. As the distance is never in that curve once more than 10 and my algo running on and have active position has a running trailingstop. Which means that does not plot the ATR distance that I was looking for 🙁
04/14/2022 at 4:24 PM #19176312atrtrail = AverageTrueRange[atrtrailingperiod]((close/10)*pipsize)/1000trailingstartl = round(atrtrail*trailingstoplong)Well this is explaining how trailing for long is started. My question is, is this part “AverageTrueRange[atrtrailingperiod]((close/10)*pipsize)/1000” affected by market and I guess it is..
Which means just another %trail is much better to run backtest with when the market have recently went up alot or have most data on the from one other market relation
04/14/2022 at 4:56 PM #19176504/14/2022 at 5:23 PM #19176604/14/2022 at 5:32 PM #19176704/14/2022 at 5:38 PM #191768Well I like to work with maximum data avalaible. Ofcourse all have there own methods.
But it would be good if ATR would work the same way at all times, that would solve all issues. Is it possible replacing this ((close/10)*pipsize)/1000 with something that would not affect marketprice
04/14/2022 at 6:29 PM #191769This is the ATR trail that I use (coded by Paul). I only use it on 2 or 3 systems but my understanding is that it reads the highs and lows over a certain period (default = 14) and moves the stop in accordance with that range, ie the stop only moves up when a new high is achieved, often to just below the last dip.
Typical values for the atr distance are between 3 and 10, but this is definitely not the trail start distance. TBH, after years of using it, it is still a mystery to me at what point the trail starts to move. I always use it in conjunction with a breakeven code, so I always know when that kicks in – then some at point the trail moves up, but it’s all very mysterious (to me) .
I know this doesn’t answer your question, but perhaps you’ll find it helpful anyway. I don’t think the instrument value (ie whether it’s 1000 or 8000) makes any difference; as the name implies, it’s looking at a range, rather than a value.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118// atr trailing stoponce trailingstopATR = 1if trailingstopATR = 1 then//====================once tsincrements = 0 // set to 0 to ignore tsincrementsonce tsminatrdist = 3once tsatrperiod = 14 // ts atr parameteronce tsminstop = IG // IG minimum stop distancetssensitivity = 2 // 1 = close 2 = High/Low 3 = Low/High 4 = typicalprice (not use once)//====================if barindex=tradeindex thentrailingstoplong = 6 // ts atr distancetrailingstopshort = 6 // 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 thenif tsmaxprice-positionprice>=tsminstop thentsnewsl=tsmaxprice-tglelsetsnewsl=tsmaxprice-tsminstopendifendifendifif shortonmarket thentsminprice=min(tsminprice,tssensitivityshort)if positionprice-tsminprice>=tgs thenif positionprice-tsminprice>=tsminstop thentsnewsl=tsminprice+tgselsetsnewsl=tsminprice+tsminstopendifendifendifif 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 = positionpriceendif1 user thanked author for this post.
04/14/2022 at 8:30 PM #191773ATR distance that I was looking for
What TF are you running on?
This Topic is discussing an ATR based Trailing Stop, the ‘ATR distance’ is therefore related to TF.
-
AuthorPosts
Find exclusive trading pro-tools on