Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator loads very, very slow with 2 days of data

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

    Indicator loads very, very slow with 2 days of data

    This may be a hard one to help me with, but I thought I'd see if anyone has experienced anything like this... and hopefully solved it.

    I have an indicator that is 3037 lines long.... that's pretty long for me.

    I have a load time calculator built into my indicator so I can test code and see where it's inefficient.

    When I load 1 day of data, the indicator loads in .14 seconds. Works perfect.
    2 days of data takes 4.3 seconds
    10 days takes 5.1 seconds.

    It seems if there was a calculation slowing it down, then it would be proportional to the amount of data I load. It's not even close. the jump from 1 day to 2 is huge. then very small increase to get to 5 or 10 days.

    When I comment out everything in OnBarUpdate, it still takes 3.9 seconds to load 5 days. That makes no sense.

    This is the timer data that I output. Top line is loading 1 day, 2nd Line is loading 5 days. #rd line is 10 days. 4th line is 5 days with OnBarUpdate code all commented out.

    Click image for larger version

Name:	image.png
Views:	204
Size:	28.2 KB
ID:	1315346

    So I assume it has nothing to do with anything I do in OnStateChange or it would be slow even loading 1 day of data

    I assume it has nothing to do with OnBarUpdate or it would load quickly when I commented out all that code.

    I use OnRender for all drawing instead of the built-in Draw methods (that was a huge timesaver early on).


    Any idea what can make the indicator load extremely fast on 1 day, and so slow on 2 days?

    It takes 30 times longer to load 2 days compared to 1 day.
    it takes 1.18 times longer to load 10 days of data than to load 2.
    This makes no sense.

    Any suggestions are appreciated


    #2
    Hello cre8able,

    Thank you for your post.

    I would check first if the logic in OnBarUpdate or the logic in OnRender() is causing the performance hit.

    If you comment out all logic in OnRender() does the behavior continue?

    If you are creating a lot of new objects in OnRender, this can affect performance. Re-using these may improve the performance.

    https://forum.ninjatrader.com/forum/...606#post789606

    Comment


      #3
      thanks Gabby

      I tried commenting out all the logic on both OnBarUpdate and OnRender and neither helped....

      But I closed an re-opened NinjaTrader and everything ran very fast.

      I may have had it open for a few days while I was both writing code and trading. Maybe the combo built up too much "trash" in the background.

      is there a recommended frequency to restart NinjaTrader? Daily?

      Comment


        #4
        Hello cre8able,

        We do recommend restarting NinjaTrader at least once a day.

        Comment


          #5
          Originally posted by cre8able View Post
          This may be a hard one to help me with, but I thought I'd see if anyone has experienced anything like this... and hopefully solved it.

          I have an indicator that is 3037 lines long.... that's pretty long for me.

          I have a load time calculator built into my indicator so I can test code and see where it's inefficient.

          When I load 1 day of data, the indicator loads in .14 seconds. Works perfect.
          2 days of data takes 4.3 seconds
          10 days takes 5.1 seconds.

          It seems if there was a calculation slowing it down, then it would be proportional to the amount of data I load. It's not even close. the jump from 1 day to 2 is huge. then very small increase to get to 5 or 10 days.

          When I comment out everything in OnBarUpdate, it still takes 3.9 seconds to load 5 days. That makes no sense.

          This is the timer data that I output. Top line is loading 1 day, 2nd Line is loading 5 days. #rd line is 10 days. 4th line is 5 days with OnBarUpdate code all commented out.

          Click image for larger version

Name:	image.png
Views:	204
Size:	28.2 KB
ID:	1315346

          So I assume it has nothing to do with anything I do in OnStateChange or it would be slow even loading 1 day of data

          I assume it has nothing to do with OnBarUpdate or it would load quickly when I commented out all that code.

          I use OnRender for all drawing instead of the built-in Draw methods (that was a huge timesaver early on).


          Any idea what can make the indicator load extremely fast on 1 day, and so slow on 2 days?

          It takes 30 times longer to load 2 days compared to 1 day.
          it takes 1.18 times longer to load 10 days of data than to load 2.
          This makes no sense.

          Any suggestions are appreciated
          Ninjatrader is well known for its slow loading times. It's horrible at loading larger sets of data. Just a few days of tick data can take a very long time to load.
          A 20 year old 32-bit application such as Metatrader 4 is much faster than Ninjatrader at loading data. That says a lot really...
          I know it doesn't make sense for your indicator to load that slow and many of us developers have complained about this problem before (it's a trading platform that is supposed to load data fast), but nothing is done about it unfortunately since it is coded into the core of the platform.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          581 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          338 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          554 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          552 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X