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 nandhumca, Today, 03:41 PM
                  0 responses
                  3 views
                  0 likes
                  Last Post nandhumca  
                  Started by The_Sec, Today, 03:37 PM
                  0 responses
                  3 views
                  0 likes
                  Last Post The_Sec
                  by The_Sec
                   
                  Started by GwFutures1988, Today, 02:48 PM
                  1 response
                  5 views
                  0 likes
                  Last Post NinjaTrader_Clayton  
                  Started by ScottWalsh, 04-16-2024, 04:29 PM
                  6 responses
                  33 views
                  0 likes
                  Last Post ScottWalsh  
                  Started by frankthearm, Today, 09:08 AM
                  10 responses
                  36 views
                  0 likes
                  Last Post frankthearm  
                  Working...
                  X