Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can I lighten CPU load this way?

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

    Can I lighten CPU load this way?

    Back when I was using TradeStation there was a trick to save some CPU cycles in coding and I would like to see if it would work in NT (if I understand OnBarUpdate() correctly). This applies to CalculateOnBarClose = false; If OnBarUpdate() is "true" even if more volume comes in at the same price (changing Volume[0] but not Close[0]), then if I just check for a change in Close[0], I can skip the indicator calculations on all indicators THAT USE PRICE ONLY (not Volume) by immediately issuing a "return;" in the code. Of course, during highly volatile times Close[0] changes constantly, so not any savings there, but in "normal" times it might help - if it worked that way. Does it?

    #2
    Tarkus11,

    You could save the current price Close[0] to a variable, then with CalculateOnBarClose = false; compare the Close[0] to the variable, returning if they are the same.
    TimNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Tim View Post
      Tarkus11,

      You could save the current price Close[0] to a variable, then with CalculateOnBarClose = false; compare the Close[0] to the variable, returning if they are the same.
      Ok - thx for the confirmation

      Comment


        #4
        I just tested that in an indicator and I get gaps.

        Dan
        eDanny
        NinjaTrader Ecosystem Vendor - Integrity Traders

        Comment


          #5
          Hi eDanny,

          Perhaps you can contact Tarkus11 to see his implementation, as I have not tested this on my end.
          TimNinjaTrader Customer Service

          Comment


            #6
            Sorry - I was specifically looking at this for minimizing calc time on my TPO chart (where I also have to account for the Initial Balance time if Close[0] doesn't change at that particular moment). For other indicators I'm not sure how it would work, though if the indicator is using # of bars (like an Average) you would obviously have to account for the new bar in the Average length (maybe using FirstTickOfBar or a counter as a flag...)

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by JTizz, Today, 01:20 PM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by omermirza, Today, 12:39 PM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_Jim  
            Started by mballagan, Today, 01:02 PM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_Kate  
            Started by larkmail, Today, 12:30 PM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Kate  
            Started by Danila, Today, 11:08 AM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X