Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

real-time vs backtesting discrepancy

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

    real-time vs backtesting discrepancy

    Using the SampleMACrossOver System that comes with NT, in real-time the system is trading as I expect it to.

    However, backtesting with exactly the same parameters I see two issues.

    1. Occasionally the backtesting takes the trade on the next bar, and a few pennies different from what the real-time system traded.

    2. Once last week the system traded immediately at the open of the opening session bar, whereas backtesting now does not show a trade on that opening bar.

    I understand real-time results will necessarily be different from backtesting, but given that the MA crossover points on the real-time chart look like they line up exactly as they do on the backtesting Chart tab, then why wouldn't the backtesting pick up the trade on the opening session bar?

    #2
    Hello,

    1- This is expected. Please review this link:
    http://www.ninjatrader-support.com/H...sBacktest.html


    2- When you attach a strategy change the Min. Bars Required feild. This link will help:


    DenNinjaTrader Customer Service

    Comment


      #3
      Thanks, Ben.

      Regarding my question #2 and your response #2, it seems whether or not the backtester takes a trade on the session opening bar isn't related to the minimum number of bars when there are more than enough bars present.

      The session on May 28th had a crossover during the final session bar. On the opening bar of the session for May 29th, in real-time the system took the trade immediately at the open (instead of at the close of the first bar, as expected, but that's a different question). Turned out to be a fantastic trade.

      Using the backtester with the default number of 20 minimum bars, five months of 60-min bars is about 700 bars up through yesterday's (May 29th) session. The backtester chart shows the same crossover on the final bar of May 28th, yet backtester did not record a trade on the May 29th opening bar.

      Comment


        #4
        Hello,

        I'm not sure what is going on, but it is likely that it is something within you strategy.

        To test it, use the SampleMACrossOver strategy and see if you can reproduce the behavior. If so, tell us how to reproduce it and provide screen shots of what you are seeing.

        However, does your strategy use incoming tick data in real time? If so, the backtester only works off of closed bar information. So this means that the staregy will confirm a signal on one bar, then execute it on the next bar. The trades may look "late", but they are not due to the fact that backtesting is based on closed bar information.
        DenNinjaTrader Customer Service

        Comment


          #5
          The attached screenshot is of backtesting the SampleMACrossOver strategy supplied with NT.

          I'm trying to deconstruct and understand why the backtester did not register a long entry trade on the opening bar of the May 29th session whereas the same strategy automated in real-time did.

          Thanks,
          Attached Files

          Comment


            #6
            Hello,

            Do you understand the last part of my most recent post?

            With the screen shot I was hoping you could reproduce the issue in real-time and backtest and show me the two situations. However I'm pretty sure my last post explains it.

            Let me know if you have questions.
            DenNinjaTrader Customer Service

            Comment


              #7
              Ben,

              Forgive me for not having answered that last question. No, the SampleMACrossOver system isn't using tick data as the parameter 'Calculate on bar close' is set to 'True.'

              I do have the screenshot (176K) of real-time, but I didn't upload it because I haven't figured out how to reduce the file size to below the 97K limit.

              Neither Paint, Picasa, nor Windows Media Player allow adjustment of file size, and I no longer have access to Photoshop.

              Comment


                #8
                Ok, I simply resized the chart window, then re-saved it as a screenshot and that reduced the file size.

                To summarize, I'm using the SampleMACrossover system supplied with NT, and I haven't made any changes to the code.

                In real-time (screenshot attached to this post), the system took the trade immediately at the open of the May 29th opening bar.

                In backtesting, that trade was not taken.

                Discrepancies between backtesting and real-time necessarily must occur; understanding this particular discrepancy will go a long ways towards answering this and other questions about NT software.
                Attached Files

                Comment


                  #9
                  lself,

                  Backtesting results are always done with CalculateOnBarClose = true. I am assuming you are running this set to false in real-time. The differences between these modes are profound. In real-time you will be able to trade immediately on a cross, while in backtesting you can only trade at the next available tradeable location. This location is always the open of the next bar.

                  In backtesting you have a signal bar which is evaluated at that bar's close. If it decides to trade the trade will show up on the next bar. That is what you are seeing and that is most likely the source of your discrepancies.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Thanks, Josh.

                    1. As I mentioned in post #7, the I had not changed the default setting of CalculateOnBarClose=True of the real-time system.

                    2. Regardless of the above, it seems the backtesting should have registered a trade on the May 29th opening bar given that the crossover occurred on the prior bar.


                    Again, my question isn't about why there's a discrepancy between real-time and backtesting but, rather, it's about why the backtester didn't register this particular trade.

                    Comment


                      #11
                      lself,

                      Only way you to tell is if you trace the order in that particular instance. Please try making a tweak to the strategy and adding TraceOrders = true in the Initialize() method.
                      Josh P.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Jimmyk, 01-26-2018, 05:19 AM
                      6 responses
                      835 views
                      0 likes
                      Last Post emuns
                      by emuns
                       
                      Started by jxs_xrj, 01-12-2020, 09:49 AM
                      6 responses
                      3,291 views
                      1 like
                      Last Post jgualdronc  
                      Started by Touch-Ups, Today, 10:36 AM
                      0 responses
                      10 views
                      0 likes
                      Last Post Touch-Ups  
                      Started by geddyisodin, 04-25-2024, 05:20 AM
                      11 responses
                      62 views
                      0 likes
                      Last Post halgo_boulder  
                      Started by Option Whisperer, Today, 09:55 AM
                      0 responses
                      9 views
                      0 likes
                      Last Post Option Whisperer  
                      Working...
                      X