backtest not same result as live

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #197190 quote
    ullle73
    Participant
    Senior

    can someone tell me why backtest does not show nearly the same results as live?

    test is on dax40, 2 points spread.

    // adr: 40, TP: 130, SL: 60, trail: 50, 3,19 gain to loss, 45% win, 24 break even, 2500 euro. 11,73% DD
    
    
    
    DEFPARAM CumulateOrders = FALSE
    IF Not OnMarket THEN
    MyExit = 0
    ELSE
    c1 = 0
    ENDIF
    // ADR Average Daily Range
    MyADR       = average[20,0](Dhigh(1) - Dlow(1))
    //
    IF (Time = 000000) OR ((Time > 000000) AND (Time < Time[1])) THEN
    MyHI     = high
    MyLO     = low
    c1       = 0
    ENDIF
    IF Time <= 090000 THEN
    MyHI     = max(MyHI,high)
    MyLO     = min(MyLO,low)
    MyRange  = MyHI - MyLO
    c1       = ((MyRange / MyADR) * 100) < x //75
    ENDIF
    IF Time >= 090000 AND c1 THEN
    BUY       0.5 Contract AT MyHI + y * pipsize STOP
    SELLSHORT 0.5 Contract AT MyLO - y * pipsize STOP
    SET TARGET pPROFIT PL //40
    SET STOP   pLOSS   SL //80
    ENDIF
    IF MyExit = 0 THEN
    IF (LongOnMarket AND (close - TradePrice) >= t * pipsize) OR (ShortOnMarket AND (TradePrice - close) >= tS * pipsize) THEN //27.5 37.5
    MyExit = TradePrice
    ENDIF
    ENDIF
    IF MyExit > 0 THEN
    SELL      AT MyExit STOP
    EXITSHORT AT MyExit STOP
    ENDIF
    //GraphOnPrice TradePrice coloured(0,0,255,255)
    //GraphOnPrice MyHI       coloured(0,128,0,200)
    //GraphOnPrice MyLO       coloured(255,0,0,255)
    //Graph close - TradePrice
    //Graph c1
    //Graph MyADR
    //Graph MyRange
    
    wrong.jpg wrong.jpg
    #197203 quote
    robertogozzi
    Moderator
    Master
    This has been addressed many times. Here you can find an answer by Nicolas https://www.prorealcode.com/topic/backtesting-and-demo-account-algo-doesnt-match-live-algo/#post-175691, which I am posting:

    This is a non-exhaustive list of the elements that can impact a live trading strategy and create differences with a demo account and/or backtests, that could help you:

    • Spread
    • Slippage
    • Orders rejections due to one of the above reason, but also because of the allowed distance from current price to put pending orders (known as “minimal distance”)
    • Different trading hours (ProOrder code launched in a different time zone / custom hours, by the user)
    • Coding problem: division by zero error, null or negative periods for indicators, ..
    • Lack of responsiveness of IG demo servers (if IG is the broker), although this has improved considerably since last year.
    • Make backtests without tick-by-tick option
    • “set stop trailing” instruction that give IG the total control of your stoploss, can be moved differently between accounts due to points above
    • Limited risk accounts and their rules
    • Guaranteed stoploss rules and fees
    • Starting a strategy at a different time (1 hour or even 1 minute later): depending on the code of the strategy, the results of some calculations could be different.
    • Margin required on the trading account (no demo or backtest tests are made on this subject)
    • Overnight and overweekend fees

    Because backtests are only tested on history with no connection to live market , you may encounter differences with real live trading environment subject to spread enlargement, slippage, etc. If your stop hasn’t move, there must be information of an error into your orders rejected list you can consult with CTRL+O. IG orders list history may be also helpful!

    #197214 quote
    ullle73
    Participant
    Senior
    yes ive seen that one before, cut cant see why backtest only takes 1 pos and live took 5?   what i can see is my system is ok on all points:  
    • Spread – OK
    • Slippage – OK
    • Orders rejections due to one of the above reason, but also because of the allowed distance from current price to put pending orders (known as “minimal distance”) – NONE
    • Different trading hours (ProOrder code launched in a different time zone / custom hours, by the user) – SAME
    • Coding problem: division by zero error, null or negative periods for indicators, .. – NO?
    • Lack of responsiveness of IG demo servers (if IG is the broker), although this has improved considerably since last year. 
    • Make backtests without tick-by-tick option – USED WITH TICK-BY-TICK
    • “set stop trailing” instruction that give IG the total control of your stoploss, can be moved differently between accounts due to points above – NOT USING
    • Limited risk accounts and their rules – NO
    • Guaranteed stoploss rules and fees – NOT USING
    • Starting a strategy at a different time (1 hour or even 1 minute later): depending on the code of the strategy, the results of some calculations could be different.
    • Margin required on the trading account (no demo or backtest tests are made on this subject) – MARGIN OK
    • Overnight and overweekend fees – NEVER HELD OVERNIGHT
    #197220 quote
    GraHal
    Participant
    Master
    What about 3rd from bottom? Try again starting both BT and Live at exactly same time?? Just a few thoughts trying to help.
    #197246 quote
    ullle73
    Participant
    Senior
    oh, forgot to enter that, both backtest and live are on 30 min.
    #197250 quote
    GraHal
    Participant
    Master
    Launch BT and Live again at the exact same time?
    A possible answer to above question would be … Yes I started both Backtest and Live on Wednesday 13 July at 21:00 hrs (UTC+1). I’m not being facetious 🙂 above is the quickest way (for me) to show that the 3rd from bottom in Nicolas List is not about Timeframe. The bullett point is referring to clock time. Mostly it makes no difference, but it just might … if your code contains certain calculations etc.
    ullle73 thanked this post
    #197253 quote
    ullle73
    Participant
    Senior
    oh, now i understand. I ditched that algo, cant risk it taking 5 losses in a couple of minutes when it should only take one pos. Thanks though!
    GraHal thanked this post
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

backtest not same result as live


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
ullle73 @jonas_rydqvist Participant
Summary

This topic contains 6 replies,
has 3 voices, and was last updated by ullle73
3 years, 7 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/12/2022
Status: Active
Attachments: 1 files
Logo Logo
Loading...