Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Live trading lags backtest by 1 bar

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Live trading lags backtest by 1 bar

    Attached is a screenshot of the chart with a strategy running on it. Between live and backtest, it report taking trades at the same time (same timestamp between live execution and backtest reported trade), however, on the chart it shows the backtest executing 1 bar earlier - why is this?
    Attached Files

    #2
    Hello samish18,

    From the image I cant tell which trade you are referring to as one image excludes the bar time stamps.

    That may be an expected difference, generally you will see some differences between realtime and backtest. To confirm the logic happened exactly the same between the tests you can add prints to debug that use case. We have a guide that goes over that here:

    Comment


      #3
      I attached the execution from the live trades and the backtest results - this is a terrible discrepancy, but some level of erroneous results is returned with every backtest and every strategy. NInjatrader is used for its ability to operate automated strategies - please fix this aspect of the product
      Attached Files

      Comment


        #4
        Hello samish18,

        From only the executions I wouldn't be able to tell what happened different, that would require debugging the strategy as described in the link I provided. There are expected differences between historical testing and realtime testing so there will most likely be some discrepancies between tests. For a backtest to exactly match realtime every aspect of the test must be exactly identical so the strategy calculates the same and produces the same executions. To know its working identically would require adding debugging to the script.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        116 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        61 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        40 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        43 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        82 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X