Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Errors in PlayBack

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

    Errors in PlayBack

    Good morning,

    I'm getting strong errors using PlayBack, I'm developing a Strategy and it works in 1 second chart (Calculate.OnBarClose).

    Running Playback the trades are opened with error time and price, it seems a delay of 1 second in the time/price of trade.
    The error is only in orders, the calculation of the indicators, print etc ...all work fine.

    At first I thought in a code mistake but finally I tested it with "Sample MA crossover" and you can see in the image the strange different behavior between the 2 charts.
    With red arrow I show you the fail trades.

    Running the PlayBack the two charts and trades are exactly the same. Reloading the strategy (right chart), it shows the proper trades and ere different from first chart.

    In playback it should to submit the trades at the close of bar (at first tick (price) of next bar), and in historic load it works fine.
    Running Playback most of the time it open and show the trade at finish of the next bar (time and price).

    Can you test it at your side and suggest me how could be the problem please?
    Many thanks

    Click image for larger version

Name:	imagen.png
Views:	143
Size:	181.0 KB
ID:	1342014

    #2
    Hello ClauTrade,

    See the support articles below about intra-bar granularity and differences between real-time and backtest (historical).



    If these are market orders, I would suspect the script is not being run with Calculate.OnBarClose.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea,

      sorry but I'm not sure that I need intra-bar granularity as I want to run in onbar calculation.

      In my own script I use more BarSeries and I added "Range 1 bar" for better (intra-bar) precision. I run Script in Calculate.OnBarClose. I have no problem in RealTime data and Backtest ... only I have this issue in Playback real time!

      Please note that for my example test I used the default "Sample MA crossover" script (not mine)! I confirm that in both charts the set is Calculate.OnBarClose.

      In this case, as it is used and expected OnBarClose calculation, I think that the result of playback in real time (running) should be the same of historical (loading script), is it true?

      If you want you could test it, is very fast, 2 identical charts (1 second bar), same script, run playback for a pair of minutes, and then reload only one for historical. Have you the same result in both case?

      Let me know please. many thanks!





      Comment


        #4
        Hello ClauTrade,

        Range bars do not show the full market prices as these only create a new bar when the price exceeds the set number of ticks.
        This causes orders to appear filled outside of the bar in real-time.
        In historical orders are only filled with end of bar information.

        Try using a 1 minute chart, using Calculate.OnBarClose. Is the behavior the same?

        By submitting the orders to a 1 tick series (intra-bar granularity), the orders placed at the same date and time will have a similar fill price between historical (when the chart is reloaded), playback, and real-time.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello,

          about 1 range, I know it, it was just an example, I've not used it in my test example, I used "Sample MA crossover", sure you know well how it works, easy and simple script.

          Testing in 1 minute, it was more difficult to see the error (as there are 60 seconds in one bar) but, how can you see in the image, the trade in real time is de-synchronized from the open bar.

          Please note that all is with Playback (not back-test).

          The following note is from the playback page:

          Note: When using market replay, the NinjaTrader core market data updates occur at the granularity provided by the market data provider. However, the NinjaTrader user interface only visually updates in 1-second intervals for performance optimizations. Even though the NinjaTrader UI's are only visually updating at 1-second intervals, orders, indicators, and strategies will calculate just as they were running in real-time.​

          The issue is that the strategy submit order on bar close but the playback process order with delay (I think one second before).

          Real Time on the left (error with red arrow)
          Historical on the right (correct with green arrow)

          Click image for larger version

Name:	imagen.png
Views:	175
Size:	113.6 KB
ID:	1342074

          Comment


            #6
            Hello ClauTrade,

            Can you add a bid series to the chart and reproduce once more?

            I suspect the bid price market update where the order filled in real-time playback was different than the last price used to build the bars.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hello,

              yes, I tested it with bid but is the same.
              Have you see the difference in price in first post (image)? It seems a fail in the trade execution, too much range to be a spread last/ask/bid.

              Anyway I just send a mail support with a new script and documentation of test, I did new script to test in tick chart trying to understand whats happening.

              Keep in touch ... thanks.

              Comment


                #8
                Hello ClauTrade,

                Adding the bid series to the chart is not meant to change the result, this is meant to visually show the bid prices on the chart to see if the spread of the ask and bid is causing the order to not fill at a price point with in the last data.

                I should have noted to make the bid series a different color to distinguish these from the last data used for the primary chart bars.

                Can you provide a screenshot of the chart?
                Chelsea B.NinjaTrader Customer Service

                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