Preferred or Most Effective Trailing Stops – Suggestions Please
Forums › ProRealTime English forum › ProOrder support › Preferred or Most Effective Trailing Stops – Suggestions Please
- This topic has 7 replies, 3 voices, and was last updated 2 months ago by JS.
-
-
08/23/2024 at 1:35 PM #236641
Loads of Trailing Stop codes are linked here …
Would anyone like to share (could be from Library above) a Trailing Stop (TS) Code they have found to be effective (could be Gain increase or Drawdown reduction?) when added to their AutoTrading System(s)?
A TS code that allows different settings when Long or Short should be very interesting?
Thank You
08/23/2024 at 2:51 PM #236646My favorite is still:
ATR trailing stoploss123456789101112131415161718192021222324252627282930313233343536373839404142434445464748//VARIABLES STOP SUIVEURONCE trailingStopType = 1 // Trailing Stop - 0 OFF, 1 ONONCE trailingstoplong = 7.5 // Trailing Stop Atr Relative DistanceONCE trailingstopshort = 4 // Trailing Stop Atr Relative DistanceONCE atrtrailingperiod = 25 // Atr parameter ValueONCE minstop = 0 // Minimum Trailing Stop Distance// TRAILINGSTOP//----------------------------------------------atrtrail = AverageTrueRange[atrtrailingperiod]((close/10)*pipsize)/1000trailingstartl = round(atrtrail*trailingstoplong)trailingstartS = round(atrtrail*trailingstopshort)if trailingStopType = 1 THENTGL =trailingstartlTGS=trailingstartsif not onmarket thenMAXPRICE = 0MINPRICE = closePREZZOUSCITA = 0ENDIFif longonmarket thenMAXPRICE = MAX(MAXPRICE,close)if MAXPRICE-tradeprice(1)>=TGL*pointsize thenif MAXPRICE-tradeprice(1)>=MINSTOP thenPREZZOUSCITA = MAXPRICE-TGL*pointsizeELSEPREZZOUSCITA = MAXPRICE - MINSTOP*pointsizeENDIFENDIFENDIFif shortonmarket thenMINPRICE = MIN(MINPRICE,close)if tradeprice(1)-MINPRICE>=TGS*pointsize thenif tradeprice(1)-MINPRICE>=MINSTOP thenPREZZOUSCITA = MINPRICE+TGS*pointsizeELSEPREZZOUSCITA = MINPRICE + MINSTOP*pointsizeENDIFENDIFENDIFif onmarket and PREZZOUSCITA>0 thenEXITSHORT AT PREZZOUSCITA STOPSELL AT PREZZOUSCITA STOPENDIFENDIF08/29/2024 at 9:27 AM #23680108/29/2024 at 9:55 AM #236804I haven’t got a favourite (yet! 🙂 ) … apart from you kindly posting your fav TS, it doesn’t look like others have a favourite either as no more posts since yours.
I have tried TS’s in the past, but most barely improved overall performance and several reduced performance. I guess it depends on the strategy and exit conditions etc.
I have an Algo working on 1 hour TF, Exit is a switch of direction, but after seeing Gain increase then fall back again, I thought .. maybe a TS might help here.
I tried Exit when Close < MA and Close Crosses under MA etc, but that didn’t help much overall either.
I have about 20 versions of the Algo currently on Demo Live test … some without TS, some with various TS’s and some with MA’s etc … I have these working 1 min TF, one is on 1 sec TF (main strategy is on 1 hour TF).
I’ll let you know the outcome.
1 user thanked author for this post.
08/29/2024 at 11:02 AM #236820https://www.prorealcode.com/topic/trailing-stop-on-1-second-timeframe/
1 user thanked author for this post.
08/29/2024 at 11:58 AM #23683108/29/2024 at 12:18 PM #236834Hi GraHal,
Sometimes the official instructions/commands of PRT do not work as expected, for example if you use “StrategyProfit” and your system goes directly from “Long” to “Short” or vice versa, then the “StrategyProfit” will not work properly (too late)…
In such cases, I create my own variable by putting an “x” in front of it (xStrategyProfit) so that I know that this is my own variable…1 user thanked author for this post.
08/29/2024 at 12:29 PM #236837In this case, it would be something like this:
If BuyCondition then
Buy 1 contract at Market
xLongOnMarket=1
xShortOnMarket=0
EndIfIf ShortCondition then
SellShort 1 contract at Market
xLongOnMarket=0
xShortOnMarket=1
EndIf1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on