Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Different results between Market Replay and CQG live

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

    Different results between Market Replay and CQG live

    Hey guys.

    I have a problem with my indicator.
    The logic is simple.
    When the condition (Low[0] < Low[1]) is triggered, I store the Low of the previous bar, the High of the previous bar and the X.
    Then, when the High of the current bar reaches any of the previously saved values, I delete them.
    Finally, after all that, I put together the values that the price did not reach with the values that the price reached in a single list.

    The problem is: in Market Replay, the script works correctly. Now, when using live data from CQG, it doesn't work properly.

    I made two screenshots. One shows the correct result (Market Replay) and the other the wrong one.
    Where is the error?
    Thanks​

    Click image for larger version  Name:	1.png Views:	0 Size:	93.1 KB ID:	1224055

    Click image for larger version  Name:	2.png Views:	0 Size:	86.6 KB ID:	1224056
    Last edited by rafaelcoisa; 11-19-2022, 04:16 AM.

    #2
    Hello rafaelcoisa,

    When running this while connected to CQG, is this real-time or historical?

    You can print the State to find out.


    Below is a link to a forum post on comparing real-time, playback, and historical.
    Citizens of the NinjaTrader Community, A common question we hear from clients is 'why are results from backtest different from real-time or from market replay?'. Live orders are filled on an exchange with a trading partner on an agreed upon price based on market dynamics. Backtest orders are not using these market dynamics.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      It's real-time.did you have different results?​
      Last edited by rafaelcoisa; 11-17-2022, 11:37 AM.

      Comment


        #4
        Hello rafaelcoisa,

        Yes, when using Calculate.OnBarClose and having if (State == State.Historical) return; in the script and running this, shows the same Close[0] values in real-time as in Playback after downloading the playback data from the Market Replay Servers and playing this back.

        I've used the script that writes information to file that I have provided you, to test.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          I didn't understand what you said.
          Did you test the code I provided with if (State == State.Historical) and Calculate.OnBarClose and the result LIVE and Playback were the same? And, what about Calculate.OnEachTick? Did it work too, both LIVE and Playback have equal results?​
          Did you provide some code in your post? There's none there.​
          Thanks

          Comment


            #6
            Hello rafaelcoisa,

            I am not testing your code as you have not provided a reduced test script export that can be imported and tested. I am directly testing your claim that the Close[0] of the bar in real-time is different than Playback and no other code is being tested other than what you are inquiring about. I am finding this is not the case.

            Is your inquiry about the Close[0] being different in real-time than backtest? Or is your inquiry about the rest of the custom logic you have posted?

            Ticks can be different in playback and real-time as discussed in the video linked from the post. May I confirm you have watched this video and read the post?

            Yes, the RealtimeReplayHistoricalComparisonsExample_NT8 attached to the post I have linked is an exported script you can download import and test yourself.

            Attached is a screenshot of the post showing the downloadable script highlighted in a red square.

            Click image for larger version  Name:	2022-11-17_11-50-11.png Views:	0 Size:	77.7 KB ID:	1224103
            Last edited by NinjaTrader_ChelseaB; 11-17-2022, 12:58 PM.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              The Close you can read in the screenshot is not the OHLC Close.
              It's something like the condition (Low[0] < Low[1]) has been fulfilled and closed.
              My question revolves around this.
              Why is this condition triggered on Playback and not LIVE?
              On LIVE the condition is triggered for all bars but this one, no; which implies that the code that would have followed did not follow and resulted in "Open".
              And, the condition is so simple because it only takes into account the High of the CurrentBar that I think "granularity" is not a problem.​

              Last edited by rafaelcoisa; 11-19-2022, 04:17 AM.

              Comment


                #8
                Hello rafaelcoisa,

                If the condition is evaluating differently, then the values compared in the condition are different.

                If you are specifically referring to Low[0] < Low[1] condition, this would indicate the Low[0] or Low[1] is different.

                The script you have provided is not a reduced test script. I could run it, but this would not give information about which condition you are investigating and would not provide the values used in that condition.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  This is weird. Why would the results be different on my computer compared to yours?​

                  Comment


                    #10
                    Hello rafaelcoisa,

                    I have not provided you the output from testing printing the Close[0] with Calculate.OnBarClose, so you would not have any values to compare..

                    I can run the test script again and provide the output text files to you if you would like to compare.

                    It seems however, you are interested in the Low[0] and not the Close[0].
                    You should writing to file the values being used in your condition, in a reduced test script that only prints that data without any other logic (to avoid confusion).
                    As mentioned in the post, the time of ticks can be slightly different.

                    The video and script I have provided you demonstrates writing the bar data to file so this can be compared.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      I don't understand why you keep referring to Close and Low.
                      The condition I'm referring to is based on a High:
                      Code:
                      bool MAXifPriceReachLimit = High[0] >= MAXopenRedY[i];​

                      Comment


                        #12
                        Hello rafaelcoisa,

                        I was reacting your post..
                        Originally posted by rafaelcoisa View Post
                        It's something like the condition (Low[0] < Low[1]) has been fulfilled and closed.
                        My question revolves around this.
                        Why is this condition triggered on Playback and not LIVE?
                        It seems this was not the condition you are inquiring about however.

                        As mentioned, reduce the script to the one condition you are inquiring about and this will remove any confusion.

                        You should be writing to file the values used in the condition you are investing, whichever condition that may be.
                        Chelsea B.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        648 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        369 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        108 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        572 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        573 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X