Trailing Stop Loss Enhancement

Forums ProRealTime English forum ProOrder support Trailing Stop Loss Enhancement

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

    Hi team,

    I developed the below trailing stop code and appreciate your support for additional enhancement to get better results. Also, where is the correct place inside the code I have to place the trailing Stop Loss code (Inside the entry or exit position or in the end of the whole code because I got different results in everyplace, I inserted the code.

    Thanks

     

    1 user thanked author for this post.
    #237614

    Hi,
    I have reviewed your code and noticed a few points that we can improve to optimize the behavior of the trailing stop.
    1)Resetting stoploss on every bar: As your code stands, the stoploss is reset to 0 on each bar due to the third line in your code, which makes it start from 0 on every candle. This can interfere with the correct functioning of the trailing stop. A solution would be to initialize the stoploss only once using the ONCE instruction, ensuring that the values are not reset constantly.
    2)Separate the stoploss condition for longs and shorts: It’s important to manage the stop separately for long and short positions. This will avoid any confusion in tracking the trailing stop for each position type.
    3)Reset the stoploss only when the position has exited: In your current code, you reset the stoploss inside the LONGONMARKET or SHORTONMARKET conditional blocks (it means every bar). Instead, I suggest moving the reset of the stoploss outside of those blocks, so that it only resets when we are no longer in the position, ensuring that we have completely exited the market.

    Here’s a modified version of the code with these adjustments:

    2 users thanked author for this post.
    #237626

    Thank you so much Ivan I really appreciate your support and efforts.

    #237663

    Hi Iván

    Do you know why it’s not working with tick-by-tick mood in backrest?

    Thanks

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