Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trades executing slowly - how to increase the speed of the execution

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

    Trades executing slowly - how to increase the speed of the execution

    Hi, My strategy should execute trade at candle close(if conditions meet). However, in the ninjaScript output window, i see the trades getting executed at 04/03/02 th second after the candle closes. Why is it taking 3-4 seconds for just verifying few if conditions and executing a trade(either entering or closing a trade).

    Are there any ways to improve the performance of the execution so that the trade gets executed at 1st second instead of 3rd or 4th second. In the world of trading, i hope you understand how important a second or two is(especially for scalp/day traders).

    Screenshot of the NS output window :

    Click image for larger version

Name:	image.png
Views:	493
Size:	33.0 KB
ID:	1311534

    Also, note that this performance stat is during after hours(at around 8 PM), when the market is not volatile. So i am concerned a bit because i am worried how it would perform during NY market hours ( 9:30 AM EST to 4:00 AM).

    Please share the best ways to improve the script and improve the NT performance of system performance(if any). I am on a windows laptop if that helps you.​

    #2
    Hello psangram,

    Compare your PC Clock with https://www.time.gov/

    If you are not in sync:
    • Shutdown NinjaTrader *important
    • Windows 10
      • Navigate to the Windows Control Panel
      • Select Clock and Region -> then click 'Set the time and date'
        (Or click 'Date and Time' if this is visible)
      • Click on Internet Time tab
      • In the Server: drop-down select time.nist.gov
      • Click Update
    • Windows 11
      • Open Settings
      • Click on Time & language.
      • Click the Date & time page on the right side.
      • Under the “Additional settings” section, click the Sync now button.
    • If the message that appears says 'successful', your PC clock should now be updated
      If not, select a different server from the Server: drop-down and try again (repeat until one of the servers is successful)
    • Restart NinjaTrader
    • Connect to a data feed
    • Reload All Historical Data *important
    Below are a few links to 3rd party educational sites with steps to synchronize with internet time.

    Windows 7 - http://mintywhite.com/windows-7/7mai...t-time-how-to/

    Windows 10 - https://www.windowscentral.com/how-m...ers-windows-10
    - http://www.windows10update.com/2015/...t-time-server/

    Windows 11 - https://pureinfotech.com/fix-clock-out-sync-windows-11/

    Close all open workspaces, and in a new workspace open a new blank chart with no template applied so no other scripts can be contributing to a performance impact.
    Add the strategy to the blank chart.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by psangram View Post
      Hi, My strategy should execute trade at candle close(if conditions meet). However, in the ninjaScript output window, i see the trades getting executed at 04/03/02 th second after the candle closes. Why is it taking 3-4 seconds for just verifying few if conditions and executing a trade(either entering or closing a trade).

      Are there any ways to improve the performance of the execution so that the trade gets executed at 1st second instead of 3rd or 4th second. In the world of trading, i hope you understand how important a second or two is(especially for scalp/day traders).

      Screenshot of the NS output window :

      Click image for larger version

Name:	image.png
Views:	493
Size:	33.0 KB
ID:	1311534

      Also, note that this performance stat is during after hours(at around 8 PM), when the market is not volatile. So i am concerned a bit because i am worried how it would perform during NY market hours ( 9:30 AM EST to 4:00 AM).

      Please share the best ways to improve the script and improve the NT performance of system performance(if any). I am on a windows laptop if that helps you.​
      Maybe you need a faster computer or server, I know everyone in my disc groups are running our automated strategies on ninjamobiletrader vps. In the NT logs files it's milliseconds between the strategy calculation and order submission / execution.

      Comment


        #4
        Originally posted by backtester831 View Post

        Maybe you need a faster computer or server, I know everyone in my disc groups are running our automated strategies on ninjamobiletrader vps. In the NT logs files it's milliseconds between the strategy calculation and order submission / execution.
        I do agree that there is always good to have a better computer and there is no limit to it.
        but to execute a very simple strategy, i think my setup should work perfectly w/o any delay.

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello psangram,

          Compare your PC Clock with https://www.time.gov/

          If you are not in sync:
          • Shutdown NinjaTrader *important
          • Windows 10
            • Navigate to the Windows Control Panel
            • Select Clock and Region -> then click 'Set the time and date'
              (Or click 'Date and Time' if this is visible)
            • Click on Internet Time tab
            • In the Server: drop-down select time.nist.gov
            • Click Update
          • Windows 11
            • Open Settings
            • Click on Time & language.
            • Click the Date & time page on the right side.
            • Under the “Additional settings” section, click the Sync now button.
          • If the message that appears says 'successful', your PC clock should now be updated
            If not, select a different server from the Server: drop-down and try again (repeat until one of the servers is successful)
          • Restart NinjaTrader
          • Connect to a data feed
          • Reload All Historical Data *important
          Below are a few links to 3rd party educational sites with steps to synchronize with internet time.

          Windows 7 - http://mintywhite.com/windows-7/7mai...t-time-how-to/

          Windows 10 - https://www.windowscentral.com/how-m...ers-windows-10
          - http://www.windows10update.com/2015/...t-time-server/

          Windows 11 - https://pureinfotech.com/fix-clock-out-sync-windows-11/

          Close all open workspaces, and in a new workspace open a new blank chart with no template applied so no other scripts can be contributing to a performance impact.
          Add the strategy to the blank chart.
          Thank you for your inputs. I tried everything mentioned but it still shows a difference in the time.

          I am attaching the video. Please focus on 3 times.
          1. timer on the website
          2. time on the chart(bar timer)
          3. time on the windows.


          1 & 3 lag by a second almost. Website time is 1 sec ahead of windows time.
          1 & 2 lag by 2 seconds. Website time is 1 sec ahead of bar timer on NT chart.
          2 & 3 lag by a second. windows time is 1 sec ahead of bar timer on NT chart.


          Overall, bar timer on NT chart is > 2 secs delayed. Can you review the attached video and suggest a way to improve so that all 3 times would be perfectly in sync.

          Comment


            #6
            Click image for larger version

Name:	image.png
Views:	462
Size:	445.8 KB
ID:	1312325​Sorry, this website did not allow me to send the video. So i am adding the screenshot which describes what i mentioned in my previous reply

            Comment


              #7
              Hello psangram,

              May I confirm after syncing a message showed that the sync was successful?

              I am not able to reproduce on my end which would suggest the issue is still an out of sync PC Clock.

              This may also be due to latency. May I ask where the computer is physically located?
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_ChelseaB View Post
                Hello psangram,

                May I confirm after syncing a message showed that the sync was successful?

                I am not able to reproduce on my end which would suggest the issue is still an out of sync PC Clock.

                This may also be due to latency. May I ask where the computer is physically located?
                Yes, it did say sync was successful. Laptop is in Atlanta, George at my home.

                Comment


                  #9
                  Originally posted by psangram View Post

                  Yes, it did say sync was successful. Laptop is in Atlanta, George at my home.
                  Should i restart my laptop?(which i haven't done)
                  I only restarted NT.

                  Comment


                    #10
                    Originally posted by psangram View Post

                    Should i restart my laptop?(which i haven't done)
                    I only restarted NT.


                    No need to restart the laptop.. but why monitor NS Output for times ... NS Output is the lagard when the NT8 client is busy.

                    NS Output should be ignored ... accurate execution times are found in the log files.

                    Hedge

                    Comment


                      #11
                      If you still see execution lag... See execution log when only using a new super thin workspace with only a single chart.

                      If you still see execution lag... time to research the data lag from your internet connection to the NT Execution servers

                      Hedge

                      Comment


                        #12
                        Hello psangram,

                        The PC Clock must be in perfect sync with the internet time.

                        After this only NinjaTrader must be restarted, not the entire computer.

                        Your screenshot is showing the PC Clock is still lagging behind internet time which is likely causing the issue.

                        If syncing isn't working, it might be necessary to try and manually change the PC time so this is in sync with internet time. This is fairly difficult to do, but I'm not sure of another way to sync the PC Clock.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by hedgeplay View Post



                          No need to restart the laptop.. but why monitor NS Output for times ... NS Output is the lagard when the NT8 client is busy.

                          NS Output should be ignored ... accurate execution times are found in the log files.

                          Hedge
                          It makes sense to not at look at NS output for times(bar timer indicator).
                          Where do i find the log files?

                          Comment


                            #14
                            Originally posted by NinjaTrader_ChelseaB View Post
                            Hello psangram,

                            The PC Clock must be in perfect sync with the internet time.

                            After this only NinjaTrader must be restarted, not the entire computer.

                            Your screenshot is showing the PC Clock is still lagging behind internet time which is likely causing the issue.

                            If syncing isn't working, it might be necessary to try and manually change the PC time so this is in sync with internet time. This is fairly difficult to do, but I'm not sure of another way to sync the PC Clock.
                            I repeated the same steps(from your initial thread) multiple times and finally the PC clock and the internet time are in perfect sync.
                            Then now i compared the bar timer with the PC time, which is still lagging by a second.
                            Is this normal because since bar timer is also an indicator, which might have a slight delay?

                            In this case, how do i now exactly confirm if my NT time is in sync with the PC time?
                            Last edited by psangram; 08-01-2024, 05:10 PM.

                            Comment


                              #15
                              Hello psangram,

                              You could adjust the PC Clock to be 1 second early.

                              An indicator has to wait for a tick to be received before it updates, and charts update every 250 milliseconds.

                              If there is heavy resource demand this could also cause delays from a performance impact.

                              The log files are located in Documents\NinjaTrader 8\log.
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              62 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              40 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              21 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              23 views
                              0 likes
                              Last Post TheRealMorford  
                              Started by Mindset, 02-28-2026, 06:16 AM
                              0 responses
                              51 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Working...
                              X