Trailing stop goes backwards

Forums ProRealTime English forum ProRealTime platform support Trailing stop goes backwards

Viewing 3 posts - 1 through 3 (of 3 total)
  • #152303

    Hello,

    I have this problem with my ‘algo’ and it is driving me crazy. I see in Demo and in real that very often the trailing stop goes backwards, and it is not supposed to do that. Once a new profit has been achieved it must stay at that position. My TS is defined as a moving trailing stop, just hidden behind the EMA(9) and moving along the price, in long and short trades.

    It moves back even after a candle has closed, discarded because the average price position in the current candle changes.

    To simplify the code:

    If TS
    ts1 = CLOSE – EMA9[0]
    SET STOP TRAILING ts1
    endif

    Is there any axplanation for this behavior?? I can change instead for a dynamic stop loss, but the trailing is the right tool for this purpose.

    Thanks in advance

    ———————

    my original code equivalent is this:

    if TS
    trailmargin = EMA9[0]*ts1MMA1/100
    ts1 = CLOSE – (MMA1[0]- trailmargin)
    SET STOP TRAILING TS1
    endif

    #152311

    Always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read. Thank you 🙂

    Change your line to:

    so that it can only raise, never fall!

     

    #152387

    Hello,

    Yes, now it is working right. The only (minor) issue comes when it opens a new candle. For an instant the calculation does not have a reference and it can go up or down with no sense, it only takes 0’1 sec to get a new price and also sometimes it is slightly below the previous TS, I think we cannot avoid this situation, only happens with a new candle.

    As a sequence when it should always go upwards in Nasdaq, these are the numbers: 12.392 – 12.396 – 12.402 – (!) 12.399 – 12.403 – 12.407 – (!) 12.405 – 12.408 – …

    Thanks for your help

     

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

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