Fixed Stop Loss

Viewing 4 posts - 1 through 4 (of 4 total)
  • #221578

    Hi All

    I am struggling to see what I am doing wrong with my SL setting.

    I am trying to set a FIXED SL price according to the data when a trade is triggered using the highest price of the previous 5 bars + half the ATR.

    Am I coding it correctly? Are the codes in the correct place? The SL does not take effect when back-testing.

    Any assistance is appreciated.

     

    #221625

    Tradeindex must be referenced using PARENTHESES, not brackets. The last operation’s bar is TRADEINDEX or TRADEINDEX(1).

    Be warned that TRADEINDEX will be aware of the newly opened (or closed) trade at the closing of the candle, so lines 19-21 will only be executed from the second bar on…

    Bear in mind that TRADEINDEX is the bar when the last operation (be it Entry or Exit) is executed.

    I suggest replacing the last 6 lines as follows:

    #221667

    Thanks for the feedback Roberto.
    I seem to get the same results. No SL is set up.

    I’ve added the following screenshots with results where a trade is triggered and where a stop should be placed:
    1. My original code.
    2. The adjusted code with your changes.
    3. Replacing the code with a simple fixed 20-point SL.

    When I replace the code with a simple SET STOP LOSS 20, I get the required entry and exit.

     

    #221672

    My fault, I didn’t realize that you are setting your Stop Loss at a PRICE level, not a PRICE DIFFERENCE. Replace SET STOP LOSS with SET STOP PRICE as follows:

    1 user thanked author for this post.
Viewing 4 posts - 1 through 4 (of 4 total)

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