Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Routine timing

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

    Routine timing

    Hi, I'm coding an ATS in C# (VS2019) using NTClient.dll
    I'm checking the routine execution time, I use a timer, interval 20ms
    I've noticed that about every 16 cycles there's one much slower, see the attacched image
    What could be the cause?
    Attached Files

    #2
    Hello dieci,

    You are asking about the amount of time before a method returns a value?

    I can test this using a timer and calling data, I appreciate your patience.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea, no, I'm referring to the amount ot time to run my routine

      Here another example timer interval 10ms, almost all the point are below 10ms but some of them no...I'd like to know why and how to avoid them


      Comment


        #4
        Hello dieci,

        If the timer is not being used to time how long it takes to receive a return value from an API method call, what are you timing exactly?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi Chelsea, I'll try to explain better
          The timer is to run my routine every 20ms, so every 20ms I call the NTClient.dll to get the last value, make my checks and run my code
          Usually this takes about 5ms to get run but some times it takes much more, as you can see from the pictures
          This is a snippet...maybe it's more clear

          st = new System.Diagnostics.Stopwatch();

          private void TmData_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
          {
          if (NTClient == null)
          return;

          st.Start();
          .
          ...here is my routine in which I call NTClient to get info or to make an entry and do my checks...
          .

          st.Stop();

          //write a log file with a different name every hours
          sw.WriteLine(DateTime.Now.ToString("HHmmss") + "\t" + st.ElapsedTicks.ToString());
          }

          So usually from the beginning to the end it takes about 5ms, sometimes it take much more, but as you can see from the picture it seems that those hight times have a certain logic, they repeats
          with a quite regular interval
          I'd like to know how to avoid that, what could I check
          Hope to have been clear

          Comment


            #6
            Hello dieci,

            It still looks like you are timing how long it takes to return a value from an API call to NinjaTrader.

            Or are you timing your own custom logic?

            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi, I'm timing my own custom logic
              I'd like to know how long it takes to run my entire code, not just an API call
              I'm trying with a program that just executes a for cycle without any API call and also there there are some times it takes much more, maybe is a C# or Windows issue...

              Comment


                #8
                Hello dieci,

                As this is an inquiry about your own custom logic in an external application and not about the NinjaTrader API this would fall outside of what our support is able to assist with.

                This thread will remain open for any community members that would like to assist.

                You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our business development follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Hi Chelsea, if I had needed help I'll send a message
                  Thanks for now

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Gianpiero, 12-01-2022, 09:55 AM
                  2 responses
                  16 views
                  0 likes
                  Last Post Gianpiero  
                  Started by dweems, Yesterday, 12:56 PM
                  3 responses
                  14 views
                  0 likes
                  Last Post dweems
                  by dweems
                   
                  Started by pistolpee, 11-30-2022, 11:39 AM
                  8 responses
                  119 views
                  1 like
                  Last Post Eagle1gl  
                  Started by ballboy11, Today, 09:18 AM
                  0 responses
                  6 views
                  0 likes
                  Last Post ballboy11  
                  Started by set2win, Today, 08:10 AM
                  0 responses
                  13 views
                  0 likes
                  Last Post set2win
                  by set2win
                   
                  Working...
                  X