Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

'OnBarClose' acts lik 'OnPriceChange'

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

    'OnBarClose' acts lik 'OnPriceChange'

    Hello,

    I have Calculate= Calculate.OnBarClose in the SetDefaults state but OnBarUpdate() executes whenever price changes. Why is that ...? Thanks for the help.

    Steven

    #2
    Check Calculate in strategy settings.

    Comment


      #3
      Oh yes, the setting in strategy is OnPriceChange. Thanks. Any way to override the setting upon the script running so I dont need to check here and there?

      Comment


        #4
        In State.Configure or State.DataLoaded you could just add the line "Calculate = Calculate.OnBarClose". What this does, basically, is that if the user changes it to OnPriceChange, it changes it back. You also, potentially, could hide that input in the user interface so that the user of the strategy cannot change it, especially if it is overwritten in the code.

        If this were not a strategy but an indicator, you have to be more cautious, in that if you develop an indicator that only works with OnBarClose yet someone else builds a strategy that hosts your indicator and the strategy runs OnPriceChange or OnEachTick, NT will force your indicator to run in that same calculation mode. For that situation, if it is not practical to "fix" it so your indicator works intrabar, I would recommend that you throw an exception e.g. "if (Calculate != Calculate.OnBarClose) throw new Exception(this.Name + " only works with Calculate mode OnBarClose");" so at least they know what's wrong. What you should definitely NOT do is pretend like that isn't a possibility and just blaze forward assuming everyone will leave it at OnBarClose.
        Bruce DeVault
        QuantKey Trading Vendor Services
        NinjaTrader Ecosystem Vendor - QuantKey

        Comment


          #5
          Clear. Thank you Bruce. /Steven

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          43 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          20 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          29 views
          1 like
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          46 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          38 views
          0 likes
          Last Post CarlTrading  
          Working...
          X