Trailing stop loss advice
Forums › ProRealTime English forum › ProOrder support › Trailing stop loss advice
- This topic has 6 replies, 2 voices, and was last updated 2 years ago by SVK.
Tagged: Break Even, BreakEven, stop, trailing, trailing stop
-
-
01/09/2022 at 12:19 PM #184925
Hi all,
I would really appreciate if any of you experienced people can point me in the right direction of Trailing stop loss.
I’m aware of the Snippet Link Library and I have now tested several of them and it must be me but none of them are doing what I’m looking for.
Maybe some of them do and I’m just far too stupid (spent 6 hours yesterday and 4 hours today and frustration is getting better of me).Can you please point me to Trailing stop loss which does following ?
Example:
1; Stop Loss = 20 points2; Trailing starts after price moves 5 points in my favor
3; Trailing step is 5 points
So every 5 points in my favor stop moves up by 5 points (simple mechanical thing).
Stop Loss
Trailing start
Trailing step
Vonas has done something close to that but there is not trailing step (if his startegy didn’t have minimum stop distance it would does what I’m after).
sl = 144 //Stop loss distanceslmove = 5 //Price move needed to move stopminstop = 10 //Minimum stop distance allowedThank you very much
01/09/2022 at 12:26 PM #184927Lines 17-56 of this snippet by Nicolas is doing exactly what you are looking for https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/.
Just Copy & Paste those lines at the end of your code and replace 20 with 5 in trailingstart (trailingstep is already set as 5).
1 user thanked author for this post.
01/09/2022 at 1:16 PM #184937Hi Roberto,
thank you very much for your response.
I’m using Nicolas’s trailing stop with your modification.1; Nicolas’s trailing stop was stopping strategy 100% of the time as soon as profit reached Trailingstart
2; I have searched for hours and found your post I think in German language where you have Distance = 4 * pipsize. This has helped massively as the strategy stopped quitting after each succesfull trade.
3; Trailing stop never trails. 100% of profitable trades exit at the point of reaching trailingstart.
DAX settingsTrailing start = 30 points
Trailing step = 6 points (tested with, 7, 8, 9, 10, 11 makes zero difference)
I have observed behavior of this trailing stop:
1; Trailing start reached (30 points)
2; it correctly moves stop loss to break even point
3; immediatelly it moves stop to the next step 6 points
4; another 6 points and another until it reaches 30 points and then it sells at that point (100% trades exited at 30 point)
What I’m after:
Stop loss = -20 points
Step size = 5 points
Trailing start = 30
30 points move up = New stop loss -15
Another 30 points up = New stop loss -10
Thank you very much for your help
01/09/2022 at 3:04 PM #18495201/09/2022 at 3:07 PM #18495301/11/2022 at 2:16 AM #185053Try this one:
Trailing Stop (classic, no breakeven)12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667//----------------------------------------------------------------------------------------------------// Trailing Stop (classic, no breakeven)//NewTrade = (OnMarket AND Not OnMarket[1]) OR (LongOnMarket AND ShortOnMarket[1]) OR (LongOnMarket[1] AND ShortOnMarket)//IF Not OnMarket OR NewTrade THENMainSL = 400 * PipSizeTrailingStart = 100 * PipSizeTrailingStep = 30 * PipSizeDistance = 10 * PipSizeENDIF//// LONG side//MyProfit = positionperf * positionpriceIF LongOnMarket THENIF (Not OnMarket[1]) OR ShortOnMarket[1] THENTrailingSL = TradePrice - MainSLENDIFIF ((close - TradePrice) >= TrailingStart) AND (TrailingStart > 0) THENTrailingSL = TrailingSL + TrailingStartSavedPips = TrailingStartTrailingStart = 0ENDIFWHILE ((MyProfit - SavedPips) >= TrailingStep)TrailingSL = TrailingSL + TrailingStepSavedPips = SavedPips + TrailingStepWENDENDIF//// SHORT side//IF ShortOnMarket THENIF (Not OnMarket[1]) OR LongOnMarket[1] THENTrailingSL = TradePrice + MainSLENDIFIF ((TradePrice - close) >= TrailingStart) AND (TrailingStart > 0) THENTrailingSL = TrailingSL - TrailingStartSavedPips = TrailingStartTrailingStart = 0ENDIFWHILE ((MyProfit - SavedPips) >= TrailingStep)TrailingSL = TrailingSL - TrailingStepSavedPips = SavedPips + TrailingStepWENDENDIF//// LONG ExitIF LongOnMarket THENIF close > (TrailingSL + Distance) THENSELL AT TrailingSL STOPELSIF close < (TrailingSL - Distance) THENSELL AT TrailingSL LIMITELSESELL AT MarketENDIFENDIF// SHORT ExitIF ShortOnMarket THENIF (close - Distance) > TrailingSL THENEXITSHORT AT TrailingSL LIMITELSIF (close + Distance) < TrailingSL THENEXITSHORT AT TrailingSL STOPELSEEXITSHORT AT MarketENDIFENDIF1 user thanked author for this post.
01/12/2022 at 1:00 AM #185221 -
AuthorPosts
Find exclusive trading pro-tools on