How to set this type of SL to only move closer to entry
1 replies
Threshold
9 years ago #112261
This is a defensive type stop loss I made for a system to exit early if the trade shows a signal that it is not working. Its a daily system but this “Defenze” variable triggers a PERIOD_M15 ATR to tighten and trail a the stop loss.
The problem is not that the stop loss keeps moving with the ticks, but it sometimes will move away from the entry price instead of closer. Stop losses should always only move closer, never wider in my opinion.
How can this be modified?
Mark Fric
9 years ago #124978
Hello,
if you use Move to SL function that doesn’t check if the SL is moved closer to entry or no, it gives you all the flexibility.
If you want this check you can add it to your condition – use function OrderSL() to get actual stop loss and set the new one only if it moves SL closer to the price.
I’d do it this way:
1. define variables
NewSLLong, NewSLShort
2. rule Compute SL
NewSLLong = your new SL formula
NewSLShort = your new SL formula
3. rule Set Long SL
IF (Defenze = 1)
and NewSLLong > OrderSL(long magic number)
THEN
Move SL To(NewSLLong)
4. rule Set Short SL
IF (Defenze = 1)
and NewSLShort < OrderSL(short magic number)
THEN
Move SL To(NewSLShort)
Mark
StrategyQuant architect
Viewing 1 replies (of 1 total)