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 Mindset, 04-21-2026, 06:46 AM
          0 responses
          87 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          132 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          68 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by cmoran13, 04-16-2026, 01:02 PM
          0 responses
          118 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          67 views
          0 likes
          Last Post PaulMohn  
          Working...
          X