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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      64 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      35 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      59 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      62 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      51 views
      0 likes
      Last Post CarlTrading  
      Working...
      X