Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 traderqz, Today, 12:06 AM
      2 responses
      4 views
      0 likes
      Last Post traderqz  
      Started by RideMe, 04-07-2024, 04:54 PM
      5 responses
      28 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by f.saeidi, Today, 08:13 AM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by DavidHP, Today, 07:56 AM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by kujista, Today, 06:23 AM
      3 responses
      11 views
      0 likes
      Last Post kujista
      by kujista
       
      Working...
      X