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 Hwop38, 05-04-2026, 07:02 PM
      0 responses
      162 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      312 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      245 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      350 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      179 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Working...
      X