Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT7 definition of CalculateOnBarClose

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

    NT7 definition of CalculateOnBarClose

    After having to jump through a few programming hoops to trigger an event close to the end of the bar in one of the other popular automated trading platforms I'm curious to work out how NT defines the end of the bar.

    At the programming level it seems quite clear (CalculateOnBarClose=true!). I'm aware that it's impossible to define precisely the bar close - it has to be a point in real time but that's why I'm asking this here.

    I also noticed via the backtest results that the CalculateOnBarClose event does not seem to trigger before the bar close event and the trade is registered as belonging to the next bar.

    The area of concern for me is around the market close not so much the bar close. Will it be down to my chosen broker whether to accept the order command if the automated trading script triggers after the bar, and the market, is closed?

    Thanks!

    #2
    Hello Zeeee,

    The bar closing event is indeed tied to the open of the next bar. Therefore can't know that it's been closed until a new one begins. There have been suggestions for a session ending event and this would help around market close situations. Unfortunately I can't offer any timeline on when or if this will be implemented.

    Yes, it will depend on your broker whether they accept or reject the order. You can experiment with different TimeInForce options for this case. For example: They may reject an order with TIF Day if submitted after market close.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Ta Ryan, sounds definitely like something to run past the broker.

      I agree, it would be nice to have a function similar to the ExitOnCloseSeconds but for OnBarUpdate (only where CalculateOnBarClose=true of course) so any script could be triggered by this event.

      Comment


        #4
        Hi Ryan, just want to confirm when the actual order would be sent by the strategy: immediately, or when the first tick comes in of the new bar?

        Comment


          #5
          zeeee,

          Depends what you have for your strategy settings in Tools>Options>Strategies>NinjaScript. If you select ImmediatelySubmit it will go right away. If you select WaitUntilFlat, it will wait till your strategy position is flat.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Hi Josh, I have tried changing the settings in that menu and also with the TIF settings but when I backtest (I don't have a live account yet) against indices the order will always open at the market price of the new bar rather than the close.

            Is the behaviour during backtesting different?

            Comment


              #7
              Hi zeeee,

              In a backtest, orders are submitted at the open of the next bar following the condition.

              During real time this is controlled by the CalculateOnBarClose settings. Orders are submitted either immediately when true or at bar close.

              Ryan M.NinjaTrader Customer Service

              Comment


                #8
                Thanks, I understand now. It seems odd that the backtesting should behave so differently. It's bothering us a bit already - backtesting in NT doesn't reflect our forward testing.

                Regards.

                Comment


                  #9
                  zeeee, you can add finer granularity to execute your orders to with the help of the concept shown here - http://www.ninjatrader.com/support/f...ead.php?t=6652

                  Comment


                    #10
                    Excellent, that's not unlike the solution I am using (successfully) in the other software package.

                    Thanks for your help!

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    647 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    368 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    108 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    571 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    573 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X