Realtime trailing-stop not consistent to backtest

Forums ProRealTime English forum ProOrder support Realtime trailing-stop not consistent to backtest

Viewing 15 posts - 1 through 15 (of 18 total)
  • #98603

    The trailing stop I use is not consistent in real trading. I can’t figure out the reason, because sometimes it is and sometimes it isn’t! The backtest shows it correct.

    The cause is the trailing stop and there’s no profit-target.

    The question is, why is it selling at 0.35% sharp while that’s the level the trailing-stop should kick in? It works beautifully in the backtest, but it has to work realtime the same, all the time!

    The “underlaying” only purpose is to make this code adjustable for other markets.

    On 13 and 14th it worked correctly.

    In the screenshots there are 2 different strategies and both executed at the same time or about.

     

     

    Any idea’s?

    wait… could the cause be there’s no space between > 0 and then?

    priceexit1>0then

    that the backtest still works correctly, but realtime doesn’t?

    #98608

    priceexit1>0then

    Whenever I make that error (??then with no space) PRT flags up a syntax error message when I try to run backtest.

    Also an ! box shows in the left hand margin next to the line with the error?

    EDIT / PS

    Ha … strangely I don’t get a syntax error or the ! box … I just tried your code above on my platform.

    #98614

    Deleted, sorry

    #98616

    find & replace …same here! That’s strange indeed! and no error in backtest or setting it up live.

     

    Most likely that’s the cause and at the moment i’am just a bit annoyed with myself for letting that happen! An error notice would’ve been nice in the backtest.

    Strangly I can look so many times to a code and then only to notice it when posting here 🙂

     

    #98618

    Strangly I can look so many times to a code and then only to notice it when posting here

    Yeah same here … for me it is partly because the code appears with much more clarity / contrast on the PRC webpage and I always feel like I have catteracts / cloudy vision on the PRT coding window.

    All these failings will be sorted in version 11 ! ??

    #98619

    haha spot on & well said! I hope so in V11.

    #98692

    Coding issues topic should not be placed in the ProRealTime support forum, but in each independent forum depending of the subject: ProBuilder, ProBacktest or ProScreener. Thanks in advance 😉

    #98986

    fixed the issue above, but again realtime is not consistent with the backtest for the trailing stop!

    2 positions, different strategies about same time/level entry.

    One strategy get’s out at the wrong level, but both have same trailing-stop.

     

    In the backtest I have the same wrong result as realtime when I set settings to show only 25 units (everything lower than 10000 units ).

    Only from 10000 bars or higher it shows the trailing-stop as intended.

    Both strategy’s have

     

    Could it be that I’ve to increase that level?

     

    #98988

    pic compare; show units in backtest less than 10000 and bigger.

    #98999

    Position prices in backtests are always set at the exact price you are calculating the entries and exit, while in real time that prices could differ due to spread and slippage (with many different cause of slippage).

    #99005

    yeah though the market continued to go up after 0.35% gain but it sold at 0.35% give or take (because of slippage/positionprice/spread).

    I reworked the trailing stop a bit (same results in backtest), set the preloadbars to 50000 and post back after live results.

     

     

    #99159

    Happend again and I don’t know how to fix. Backtest does it correct, live-trading does not.

    Running two separate strategies version v1 and v2 which are identical besides exit-times on Friday and trailing-stop.

    adjusted preloadbars to 50000.

    v1 uses trailing-top 0.35% then 0.25% then 0.20% (switch to lower trailing-stop when gain > 0.45% and again when gain > 0.55%)

    v2 uses trailing-top 0.40% then 0.30%  then 0.20% (switch to lower trailing-stop when gain > 0.55% and again when gain > 0.60%)

     

    I adjusted the entry-price in the backtest to match the price in live trading so the real trade performance is correct.

    v1 exits when position-performance > 0.35% (time 11.26) and is sold at the close of next bar at time 11.27

    v2 exits when position-performance > 0.40% (time 11.26) and is sold at the close of next bar at time 11.27 (this version had positive slippage that’s why it reached 0.40% at the same time as v1)

     

    So one thing for sure. It’s directly related to the trailing stop.

    Is this a coding issue or is IG handeling of the stops incorrect? Because I can’t see the reason why it exits immediately when the first performance gains criteria are reached!

    #99352

    Seems to be solved after making small adjustments.

    I guess that when only the first trade in any backtest is wrong, then live trading is not reliable.

    The problem was not with IG handeling of the stops, but the code.

     

    #99616

    Here’s the correction I made.

    is replaced by (or changed back to the original)

    The difference in the backtest is the handling of the first trade but only when that trade uses a trailing-stop!

    The error became visible in live trading,  the trade didn’t activate the proper trailing-stop but exited on the level the trailing-stop should start.

    Besides this, it was missing some pointsize reference as below

    Hopefully it’s all good from now.

    #99618

    Thx Paul for the update. I already tried to test your code with some of my strategies but each time I tried, the backtest load time is infinite. Don’t you have the same issue?

Viewing 15 posts - 1 through 15 (of 18 total)

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