Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

using timer events with replay data

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

    using timer events with replay data

    i have a timer that fires some code. it's a timers.timer, not sure it's the best one for the purpose though but anyway, i want to test the script with replay data as fast as possible.

    i want the timer not to miss any second and so far i have managed to have it following up correctly with the replay player up to x4 when timer is set to 100ms.

    after that, it starts miss some seconds here and there, when factoring up replay speed despite of setting timer interval to a lower speed like 50ms or 10ms.

    results were taken via prints to output window.

    to get the relative current time i used Joydeep suggestion written here:


    how can i get a faster testing rate?

    #2
    Hi savekad, would you have an example you can email us to let your case run in MR here on our end? We could be reached at support at ninjatrader dot com

    Comment


      #3
      attached is a sample.

      within it, when running the script above x4 data rate on the replay control window, you can see in the output window that there are missed seconds.
      Attached Files

      Comment


        #4
        Thanks for the sample, we will look into and get back to you.

        Comment


          #5
          Hello savekad,
          Thanks for your note and I am replying for Bartrand.

          If I ran the code at 50X on ES data, then I am getting the prints as below:
          12/16/12 10:06:59 PM
          12/16/12 10:07:04 PM
          12/16/12 10:07:04 PM
          12/16/12 10:07:09 PM
          12/16/12 10:07:09 PM
          12/16/12 10:07:10 PM
          12/16/12 10:07:14 PM
          12/16/12 10:07:14 PM
          If you are taking about the missing time between the 2 Timer queries, then unfortunately it is expected depending on the number of available quotes / second and the replay speed.
          JoydeepNinjaTrader Customer Service

          Comment


            #6
            so what is the way of increasing the replay speed without loosing seconds?

            the main idea is to use a timer which fires some code every second and to test it with market replay at a high speed, without loosing code calls.

            Comment


              #7
              Hello savekad,
              As an alternative if you try Printing the output/calling the method from OnMarket data event then does it fulfill your requirement.

              Code:
              //in variable
              int sec = -1;
              
              //in OnMarketData
              protected override void OnMarketData(MarketDataEventArgs e)
              {
                      if (e.Time.Second != sec)
              	{
              		sec = e.Time.Second;
              		Print(e.Time);
              	}
              }
              JoydeepNinjaTrader Customer Service

              Comment


                #8
                wow so basically i can just pass the whole timer thing if all i want is a code that runs every second right??

                * just thought of another thing: if there won't be any data coming for more than one second - i will miss some calls because the code won't be executed... how can we work around that?
                Last edited by savekad; 01-10-2013, 01:49 AM.

                Comment


                  #9
                  Hello savekad,
                  OnMarketData will trigger whenever any bid, ask or last price gets updated. Thus your functions get updated even if there is no trades as bid / ask gets constantly updated.

                  However it does not guarantee that bid / ask will get updated every second, and in such scenario you will miss some calls. To avoid that you have to assign a timer only which however has its own limitation in market replay at > 50X speed.
                  JoydeepNinjaTrader Customer Service

                  Comment


                    #10
                    i can deal with x50 replay but i couldn't get it to print all calls beyond x4 speed. why is that?
                    you can see the code earlier in this thread.

                    Comment


                      #11
                      Hello savekad,
                      Even if I set the timer interval at 1 then also I am getting the gaps between two calls.
                      Code:
                      timer.Interval = 1;
                      It seems the dataset (I am testing on ES) has far too many ticks than the timer tick interval, and at high replay speed it is simply cant keep cope with the incoming ticks.
                      JoydeepNinjaTrader Customer Service

                      Comment


                        #12
                        i had an idea. do you by anyway see it possible to achieve what i want by adding another Bars object of 1 second bars and use it as a timer? the timer tick will simply be FirstTickOfBar within OnBarUpdata. does it make sense?

                        Comment


                          #13
                          Hello savekad,
                          If there are no quotes, then there will be no OnBarUdpate and you will face the same scenario. OnMarketData seems a better option since even if there is no trade, bid/ask data gets changed.

                          You can also try testing it in the OnMarketDepth event, which update more frequently than OnBarUpdate and OnMarketData.


                          Please make sure to download Level II market replay data if add the OnMarketDepth event in your code.
                          JoydeepNinjaTrader Customer Service

                          Comment


                            #14
                            i'll try that. thank you very much for your thoughts

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                            0 responses
                            672 views
                            0 likes
                            Last Post Geovanny Suaza  
                            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                            0 responses
                            379 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by Mindset, 02-09-2026, 11:44 AM
                            0 responses
                            111 views
                            0 likes
                            Last Post Mindset
                            by Mindset
                             
                            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                            0 responses
                            575 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by RFrosty, 01-28-2026, 06:49 PM
                            0 responses
                            582 views
                            1 like
                            Last Post RFrosty
                            by RFrosty
                             
                            Working...
                            X