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 Davide999, 05-18-2023, 03:55 AM
      4 responses
      554 views
      1 like
      Last Post kcwasher  
      Started by Stanfillirenfro, Today, 07:23 AM
      2 responses
      9 views
      0 likes
      Last Post Stanfillirenfro  
      Started by rexsole, Today, 08:39 AM
      2 responses
      6 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by cmtjoancolmenero, Yesterday, 03:58 PM
      6 responses
      29 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by gbourque, Today, 06:39 AM
      2 responses
      14 views
      0 likes
      Last Post gbourque  
      Working...
      X