Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Limit Amount of Calculations

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

    Limit Amount of Calculations

    Hello,

    I currently have the issue that my NT freezes when I apply an indicator.

    As this should end up being part of a strategy I would highly appreciate your feedback.

    I believe this code is part of the issue:
    for(int a = 0; a < 1441; a = a++)
    {
    if (Time[a].DayOfWeek != Time[a-1].DayOfWeek)
    {
    firstBarOfDay = a;
    Log("Bars Since Session Start " + firstBarOfDay, NinjaTrader.Cbi.LogLevel.Information);
    break;
    }
    }
    I am currently testing parts of the strategy on an indicator, I believe this calculation is done for every bar (similar to e.g. a MA, which is displayed for every bar and therefore needs to be calculated for every bar displayed), freezing NT (especially as 3 more for loops or following). It only freezes NT, my machine continues to have more than enough free resources ...

    How can I configure this, that NT only runs this once, for the current day and for the current bar? Hence the whole process is only done once. I.e. starts with the current bar and then goes back once until it finds the first bar of today ... that's it. The for loop should be done there.

    If I can configure this I could test the parts of the strategy as the indicator and run the strategy. I have not waited for more than 5min to see if NT comes back online but this would not be suitable in a live situation anyways.

    Thank you.
    Cheers tosaxx

    #2
    Welcome to our forums, you could for example compare the CurrentBar with the total bar count to determine the last bar on your chart, so only process then if (CurrentBar <= Count - 1) ...

    Comment


      #3
      Thanks for the reply, your idea would however mean that every bar will still be processed as all bars are <= Count - 1.

      Anyways, I found a different way to get it done.
      Thanks again.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by argusthome, Yesterday, 10:06 AM
      0 responses
      18 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      17 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      14 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      9 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      38 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X