Trailing stop loss

Forums ProRealTime English forum ProOrder support Trailing stop loss

Viewing 9 posts - 1 through 9 (of 9 total)
  • #135585

    Hello,

    I read an article on here regarding a trailing stop loss (https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/). I copied the exact code into one of my strategies, but I seem to be doing something wrong or understanding it incorrectly.

    As i understood it, the stop ploss would first activate when it has moved (in my code) 50 points, and place the stop loss (again, in my code) 8 points over entry. After this it would move the stop loss 8 points for every 8 points the position moves in my direction. But the backtests doesn’t show that. In my backtests the stop less gets placed very weirdly and doesn’t trail the price. Am i coding something wrong or is it how it is supposed to work?

    I have inserted a printscreen of the backtest as well as my code.

    Regards,
    Anton

     

     

    #135586

    Seems like the screenshot didn’t post(:

    #135598

    The price in your pic, where your mouse is sitting, is 27363.2 and you entry price was 27377.3, at that point you were suffering a loss, while your trailing stop would only activate when the closing price is at least 27377 + 50 pips.

    That’s why it is still 0.

     

    #135623

    The mouse placement was random, didn’t mean to point anything out with it.

    If you look at the plotted graph of the trailing sl and at the price, you can see that price moved a lot more than 8 points after the newsl got triggered, but it remained at the same pricelevel.

     

     

    #135631

    Count entry price + 50 pips.

    You are summing up wrong values.

    #135844

    okay, I dont think i fully understand unfortunately but how would I code for it to turn out the way i described before? I.e. the trailing stop gets activated when the price has moved 50 points/pips in my favour, and after that the trailing stop moves 8 points/pips up from the previous stop everytime the position moves 8 points/pips in my favour.

    #135851

    Yes, that’s correct.

    #136224

    I jump in with a follow upp question regarding the Trailing Stop Loss code.
    Is it possible to graph the “trailing” on a code running Live?

    #136225

    No, but you could run the same strategy in backtest at same time as running in ProOrder and then you will see the TS using GRAPH in backtest.

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

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