Breakeven- en trailingstop on different securities & indexes & forex
Forums › ProRealTime English forum › ProOrder support › Breakeven- en trailingstop on different securities & indexes & forex
- This topic has 79 replies, 15 voices, and was last updated 4 years ago by Paul.
-
-
04/16/2020 at 6:10 PM #12643904/16/2020 at 9:31 PM #126454
>> meant to quote GraHal here but something happened…
1st is for set up of what to use, the 2nd is the bread and butter if you dont make the home run, the third is the execution of it all if I can understand it correctly. I will try to apply this when standard deviation of range goes outside of a regular day. Usually there is a small profit to be collected there on both sides, but it is usually a quick one and needs a really good trailing to make it before a reversal. Maybe this can do it. 🙂
05/02/2020 at 12:15 PM #129380I am clearing the decks of loads of Systems … off PRT and onto my PC.
I came across attached … good results so I thought I’d add to this Topic! I did not optimise at all, just backtested today!
Paul you put so much hard work … I hope this Topic might be revived.
I will put on Forward Test on Monday and report back … and if I forget to report back, please remind me at some stage anybody!? 🙂
3 users thanked author for this post.
05/12/2020 at 7:15 PM #13136705/12/2020 at 8:44 PM #131385Ha and I needed reminding too … I had put it in my ‘4Test folder’ and then forgot to put it on test!
I’ve been doing very well this week on manual trades and it’s taken my eye off the Auto-Systems!
I’ve just set it going on Forward Test.
Thanks
05/13/2020 at 11:15 PM #131573Hi @Paul, I’ve been playing with the ATR TS code you used on the new Vectorial DAX and the results are fantastic – just wanted to say a big thanks for that!
Looking at this section of it,
123456789101112once tsincrements = 0.5 // set to 0 to ignore tsincrementsonce tsminatrdist = 4.0once tsatrperiod = 14 // ts atr parameteronce tsminstop = 10 // ts minimum stop distanceonce tssensitivity = 0 // [0]close;[1]high/lowif trailingstoptype thenif barindex=tradeindex thentrailingstoplong = 8 // ts atr distancetrailingstopshort = 8 // ts atr distanceI tend to leave tsatrperiod and tsminstop as they are, as those values seem to work on any instrument and TF. But changes to ts atr distance, tsminatrdist, and tsincrements all have a huge effect. I’m still a bit unclear as to how these 3 work together. A lower ts atr distance, 3 to 6 for example, def gives a higher win % and seems better for scalping.
Do you have any basic rule of thumb as to how you select values for those on different instruments or TFs?
At the moment I’m working on a 2m TF with atr distance =5, tsminatrdist=2 and increments=0, seems to get good results overall.
5 users thanked author for this post.
05/14/2020 at 7:56 AM #131601what do you mean by ATR = 5
I put the screen copy for more understanding05/14/2020 at 8:48 AM #131614i mean trailingstoplong / short = 5
ts atr distance is rem’d out
1 user thanked author for this post.
05/14/2020 at 2:44 PM #131671Hi Nonetheless. Thanks for your comment!
I do the same with the tsatrperiod, leaving it at 14 regardless instrument.
the tsminstop is different. For this it’s best to have the correct value from IG.
It means if the current price is too close to the ts exit stop price, it will reject the exit when using the wrong value. (not visible in a backtest)
Because of this I added an extra exit criteria, if index crosses over/under the tsnewsl it still exits next bar at open on market. My purpose was for fast timeframes, because if the stop is rejected, the next bar will be fast. On a hourly timeframe it doesn’t bring much.
Then there’s tssensitivity. If you have often a spike and a close considerably away from the new high/low, the system originally only use the close. With some algo’s I thought might be interesting to calculate from the real high/low instead of close.
The trailingstop long/short is used to set the atr distance when the gains are sufficient. I do not have a basic rule on this, but when the trailing stop starts working, it has to have gains which makes sense compared to a loss on stoploss or average losses.
In the old situation, with tsincrements at 0 and tssensitivity at 0, it means a fixed (besides the round difference) number of points for the trailing stop. Those points are calculated from the highest/lowest close.
In the other situation, it starts working when the atr distance trailingstoplong/short is reached.
From that moment on it starts reducing the atr distance to the tsminatrdist with he increments set. Values which make sense normally are 0-0.25 with increments of 0.05. At the vectorial dax I’ve put them even higher.
In other words, if the trailing stop value in points was originally +/- 80, it starts reducing it to +/- 40 points quickly once it kicks in (using values in vectorial dax)
To have a better visual, try to use graph tgl/tgs and graphonprice tsnewsl and see the difference using increments at zero and higher.
The trailingstop doesn’t do completely what I had in mind though, but for me it’s good.
4 users thanked author for this post.
05/14/2020 at 4:24 PM #131681Thanks very much for the explanation, that makes a lot of things clearer. ATR TS is so much more sophisticated than the standard version where all you really have is the start and the step. Yours does a much better job of catching a bigger piece of the MFE for trades that don’t ever get to the TP.
It’s a brilliant contribution, consider me a convert. 👍
05/15/2020 at 6:10 PM #131809I have a “trailing challenge” for anyone up to it. I would guess that @Paul and @nonetheless might like this.
Attached is the Kama Sma strategy originally posted by robertogozzi. It includes his sophisticated trail. However the gain/loss ratio is about the same (2.6-2.7) with and without the trail. The win-rate is better with trail. But the interesting part is the MFE/MAE ratio at 3.7 (!) meaning there is way more candy to steal. I have tried a lot of trails and breakevens from this forum but can’t find a good one boosting the G/L above 3. Any suggestions on a suitable trail? A side note is that the equity curve will never be straight so don’t get hung up on that.
With trail123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208DEFPARAM CumulateOrders = falseDEFPARAM PreLoadBars = 2000//code re-investCapital = 1000 // initial capitalEquity = Capital + StrategyProfitPosition = Max(1, Equity * (1/Capital))Position = Round(Position*100)Position = Position/100//********************ONCE TP = 4.5ONCE SL = 0.3//code quit strategymaxequity = max(equity,maxequity)DrawdownNeededToQuit = 40 // percent drawdown from max equity to stop strategyif equity < maxequity * (1 - (DrawdownNeededToQuit/100)) thenquitendif//*****************////////////////////////////////////////////////////////////////////////TIMEFRAME (default)//ONCE nLots = 1ONCE LongTrading = 1 //1=allowed 0=bannedONCE ShortTrading = 1 //1=allowed 0=bannedTIMEFRAME (1 hour, updateonclose) //h1IF Not OnMarket THENBarCount = 0ELSEBarCount = BarCount + 1ENDIF//------------------------------------------------------------------------------------// Kama & Sma Strategy////https://www.forexstrategiesresources.com/trend-following-forex-strategies/111-kama-strategy///Period = 2 //2 (standard 10)FastPeriod = 2 //standardSlowPeriod = 30 //standard//Fastest = 2 / (FastPeriod + 1)Slowest = 2 / (SlowPeriod + 1)if barindex >= (Period + 1) thenNum = abs(close-close[Period])Den = summation[Period](abs(close-close[1]))ER = Num / DenAlpha = SQUARE(ER *(Fastest - Slowest )+ Slowest)Kama = (Alpha * Close) + ((1 -Alpha)* Kama[1])elseKama = closeendif//------------------------------------------------------------------------------------Sma = average[22,0](close) //22//------------------------------------------------------------------------------------a1 = Kama CROSSES OVER Sma// --- SHORTb1 = Kama CROSSES UNDER Sma////////////////////////////////////////////////////////////////////////TIMEFRAME (default) //1 minONCE TradeON = 1IF IntraDayBarIndex = 0 THENTradeON = 1ENDIFTradeBar = BarCountIF Not OnMarket AND TradeBar <> TradeBar[1] THENTradeON = 1ENDIF//************************************************************************// LONG trades//************************************************************************IF a1 AND TradeON AND LongTrading and TradeOK THENBUY 1 CONTRACT AT MARKETTradeON = 0ENDIF//************************************************************************// SHORT trades//************************************************************************IF b1 AND TradeON AND ShortTrading and TradeOK THENSELLSHORT 1 CONTRACT AT MARKETTradeON = 0ENDIF//SET TARGET %PROFIT TPSET STOP %LOSS SL//////////////////////////////////////////////////////////////////////////////////////////////////////////// Trailing Stop//------------------------------------------------------------------------------------IF Not OnMarket THENTrailStart = 50 //50 Start trailing profits from this pointBasePerCent = 0.07 //0.07 //10.0% Profit to keepStepSize = 6 //6 Pips chunks to increase PercentagePerCentInc = 0.1 //10.0% PerCent increment after each StepSize chunkRoundTO = -0.5 //-0.5 rounds to Lower integer, +0.4 rounds to Higher integerPriceDistance = 7 * pipsize//8.9 minimun distance from current pricey1 = 0y2 = 0ProfitPerCent = BasePerCentELSIF LongOnMarket AND close > (TradePrice + (y1 * pipsize)) THEN //LONGx1 = (close - tradeprice) / pipsize //convert price to pipsIF x1 >= TrailStart THEN //go ahead only if N+ pipsDiff1 = abs(TrailStart - x1)Chunks1 = max(0,round((Diff1 / StepSize) + RoundTO))ProfitPerCent = BasePerCent + (BasePerCent * (Chunks1 * PerCentInc))ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent))y1 = max(x1 * ProfitPerCent, y1) //y = % of max profitENDIFELSIF ShortOnMarket AND close < (TradePrice - (y2 * pipsize)) THEN//SHORTx2 = (tradeprice - close) / pipsize //convert price to pipsIF x2 >= TrailStart THEN //go ahead only if N+ pipsDiff2 = abs(TrailStart - x2)Chunks2 = max(0,round((Diff2 / StepSize) + RoundTO))ProfitPerCent = BasePerCent + (BasePerCent * (Chunks2 * PerCentInc))ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent))y2 = max(x2 * ProfitPerCent, y2) //y = % of max profitENDIFENDIFIF y1 THEN //Place pending STOP order when y>0SellPrice = Tradeprice + (y1 * pipsize) //convert pips to priceIF abs(close - SellPrice) > PriceDistance THENIF close >= SellPrice THENSELL AT SellPrice STOPELSESELL AT SellPrice LIMITENDIFELSESELL AT MarketENDIFENDIFIF y2 THEN //Place pending STOP order when y>0ExitPrice = Tradeprice - (y2 * pipsize) //convert pips to priceIF abs(close - ExitPrice) > PriceDistance THENIF close <= ExitPrice THENEXITSHORT AT ExitPrice STOPELSEEXITSHORT AT ExitPrice LIMITENDIFELSEEXITSHORT AT MarketENDIFENDIF// (GER) No trade after friday 16:00:00 (UTC+2 Europe/Berlin) or on holidaysIf dayofweek = 5 AND Time > 160000 thenTradeOK = 0elsif dayofweek = 0 thenTradeOK = 0elsif dayofweek = 1 AND Time < 000100 thenTradeOK = 0elsif year = 2019 and month = 12 and day = 24 then //TradeOK = 0elsif year = 2019 and month = 12 and day = 25 then //TradeOK = 0elsif year = 2019 and month = 12 and day = 26 then //TradeOK = 0elsif year = 2019 and month = 12 and day = 31 then //TradeOK = 0elsif year = 2020 and month = 1 and day = 1 then // New Year's DayTradeOK = 0elsif year = 2020 and month = 4 and day = 9 then // EasterTradeOK = 0elsif year = 2020 and month = 4 and day = 10 then // EasterTradeOK = 0elsif year = 2020 and month = 4 and day = 13 then // EasterTradeOK = 0elsif year = 2020 and month = 5 and day = 1 then //TradeOK = 0elsif year = 2020 and month = 6 and day = 1 then //TradeOK = 0elsif year = 2020 and month = 12 and day = 24 then //TradeOK = 0elsif year = 2020 and month = 12 and day = 25 then //TradeOK = 0elsif year = 2020 and month = 12 and day = 26 then //TradeOK = 0elsif year = 2020 and month = 12 and day = 31 then //TradeOK = 0elseTradeOK = 1endif// Add TradeOK to buy condition//*************// (GER) Close positions before weekend or day before holiday at 17:15:00 (UTC+2 Europe/Berlin)if dayofweek = 5 and time = 171500 THENEndbeforeholiday = 1elsif year = 2019 and month = 12 and day = 23 and time = 171500 thenEndbeforeholiday = 1elsif year = 2019 and month = 12 and day = 30 and time = 171500 thenEndbeforeholiday = 1elsif year = 2020 and month = 4 and day = 8 and time = 171500 thenEndbeforeholiday = 1elsif year = 2020 and month = 4 and day = 30 and time = 171500 thenEndbeforeholiday = 1elsif year = 2020 and month = 12 and day = 23 and time = 171500 thenEndbeforeholiday = 1elsif year = 2020 and month = 12 and day = 30 and time = 171500 thenEndbeforeholiday = 1elseEndbeforeholiday = 0endifIF Endbeforeholiday THENSELL AT MARKETEXITSHORT AT MARKETENDIF//*************05/15/2020 at 6:51 PM #131816And of course thank you @robertogozzi for converting the strategy to PRT. It’s still awesome!
1 user thanked author for this post.
05/15/2020 at 8:16 PM #131827I doubt that Roberto’s version can be bettered … if it could he would have done it!
05/15/2020 at 8:59 PM #131832There’s never an end to new ideas to improve things.
I made it, but then I never updated it.
05/16/2020 at 5:55 PM #131875 -
AuthorPosts