Stop loss below the lowest of the last 5 candles

Forums ProRealTime English forum ProOrder support Stop loss below the lowest of the last 5 candles

  • This topic has 13 replies, 4 voices, and was last updated 2 years ago by avatarJS.
Viewing 14 posts - 1 through 14 (of 14 total)
  • #191533

    Hello,

    How do you place your stop loss below the lowest of the last 5 candles (at the time of entry)?

    I tried with :

    but this piece of code gives random stops because many times the price closed below the last 5 lows without the trade being closed (as you can see in the screenshot)

    And most importantly, I don’t want to have a trailing stop, I want to use a fixed stop loss, which is below the last 5 lows AT THE TIME OF BUY.
    How do I code this type of stop ?
    Thank you for your help 🙂

    #191537

    deleted

    (sorry, I misread your post, my reply would not have been relevant)

    #191541

    Try above

    #191561
    JS

    Hi OlivierTrader2020,

    If you want a fixed StopLoss try this:

    #191563

    Thank you for your answer.
    As you can see in the 1st screenshot, it seems that we can’t use the code lines with the final “LOW”.

    As you can see in the 2nd screenshot, when we remove the low, it does not close the trade at the last 5 lows at the time of entry.

    #191566

    we can’t use the code lines with the final “LOW”.

    JS got it right below! 🙂

    Also … did JS fixed SL work?

    #191567
    JS

    The right code is: Lowest[5](Low) and not Lowest[5]Low

    The SL above is a fixed SL under your entry price.

    #191568

    Hi JS,

    Thank you for your answer.
    As you can see in the screenshot, it looks like close the trade at if the close is below the current 5 candlestick low.

    However as you can see in the screenshot, it does not close the trade at the level of the last 5 lows at the time of entry (extension of the blue line) :

    #191571

    Indeed, the brackets allow to use (Low).
    However, this does not generate a fixed sl but a tracking sl.
    I think we are close to the solution 🙂

    1 user thanked author for this post.
    #191574
    JS

    Hoi Olivier,

    The idea of a fixed StopLoss is:

    For example:

    You buy at 100

    Your fixed StopLoss is 10

    Then only when the Close crosses under 90 (100 – 10) your position will be closed.

    What you are showing in your screenshots is a trailing stop and not a fixed StopLoss.

    #191575
    JS

    Hi Olivier,

    Line 1 of the code “If Not LongOnMarket …” prevent the code from recalculation the SL when on market so the StopLoss will be fixed (not changing).

    #191580

    In the different screenshots I have shown you the results of the different codes received which generate trailing stops and not fixed stops.

    Sorry if it was not clear and you are right to point it out, you should not take into account the bottom of the Donchian Channel of 5 periods over the entire duration of the trade.
    Its display shows the extension of the level at which it is located when the trade is triggered.

    You will find in the last screenshot what is expected as a fixed stop with the dotted extension of the blue line. These dotted lines correspond to the low of the last 5 candles at the time the trade is triggered.

    #191581

    Hi JS,

    Unfortunately, even if you remove “If Not LongOnMarket …”, the code still generates errors.

    For example in the screenshot below:
    the 1st trade should close at the same level as the 2nd trade.
    The 2nd trade should close earlier

    #191587
    JS

    Hi Olivier,

    Don’t remove “If Not LongOnMarket…” from the code, otherwise your SL will be recalculated with every new bar…

    In the bar, where your Buy condition is true, the SL will be calculated according to “Close – Lowest[5](Low)”, then your SL is a fixed number.

    In the next bar, your buy order is executed on the Open of that bar. Your order price (TradePrice) is the Open of that bar.

    Your actual SL is now: TradePrice – SL

    Hope it is clear…(not easy to explain)  😉

     

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

Create your free account now and post your request to benefit from the help of the community
Register or Login