Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Reduce CPU load for CalculateOnBarClose = false

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

    Reduce CPU load for CalculateOnBarClose = false

    Hi,

    I'm trying to reduce the CPU load of an indicator, that does run with
    CalculateOnBarClose = false
    I'm only doing calculations with the last price, no volume or tick count...

    Would this be possible with a variable, that stores the last price and checks for a change and if there is no change in price returns?

    How would this look like?

    Thanks

    Thomas

    #2
    Hello td_910,
    Yes, it is possible to do so with a price based indicator and you will witness substantial performance enhancement.

    A sample code will be like:

    in Variable:
    Code:
    double lastClose = 0;
    in OnBarUpdate
    Code:
    if (!FirstTickOfBar && Close[0] == lastClose) return;
    
    lastClose = Close[0];
    //rest of the code.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Many thanks Joydeep.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      53 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      34 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      100 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      180 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      170 views
      0 likes
      Last Post CarlTrading  
      Working...
      X