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 NullPointStrategies, Today, 05:17 AM
          0 responses
          20 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          119 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          63 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          41 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          45 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X