Not logged in
Viewing 2 posts - 1 through 2 (of 2 total)

Forums>AlgoWizard / EA Wizard>General Discussion>How to set this type of SL to only move closer to entry

  • #112261 |
    484 Posts

    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?

    Attachments in this forum are visible only for registered users.

    Mark Fric
    1182 Posts



    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)


    Move SL To(NewSLLong) 


    4. rule Set Short SL

    IF (Defenze = 1)

    and NewSLShort < OrderSL(short magic number)


    Move SL To(NewSLShort) 

    StrategyQuant architect

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.