Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order methods vs bar closure

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

    Order methods vs bar closure

    First situation: According to the NT7 Manual, OnBarUpdate is called either on the close of the current bar or on every tick, depending on the setting of CalculateOnBarClose.

    Reading that literally, if CalculateOnBarClose is true, I would expect that OnBarUpdate would only be called once every time a bar is completed. So, if on a 5 minute chart, once every 5 minutes exactly at the 5 minute mark.

    First observation: I see trades being entered at intra-bar times even with CalculateOnBarClose set to true.

    First question: What is the correct behaviour to expect for OnBarUpdate in relation to CalculateOnBarClose and ticks?

    Second situation: According to the NT7 Manual, once a trade is entered with a managed entry method (e.g. EnterShort), it must be re-entered every time OnBarUpdate is called or the position will be cancelled. That implies that the conditions that were tested to initiate the entry must remain true throughout the life of the position.

    Second observation: Trades persist even after the initial entry conditions have changed.

    Second question: What is the actual behaviour of the managed approach in this respect?

    Thanks for your kind advice.
    Multi-Dimensional Managed Trading
    jeronymite
    NinjaTrader Ecosystem Vendor - Mizpah Software

    #2
    jeronymite, welcome to our forums:

    Correct is that the bar update with CalculateOnBarClose = true would only be called once your bar is completed, it would not update with intrabar ticks seen then - however you would need to keep in mind NT is event based and not time based, so if you see no trade for example then there would also be no bar update seen. In a fairly liquid market though it would be hitting your time stamp expectations 99% of the time normally.

    Trades can be entered intrabar, as the order is send for example on the bar close, but would be working for the bar then, so you could definitely see an intrabar fill here.

    Trades will persist unless you exit them or the ExitOnClose handling set per default would take over, the will not be closed automatically by NT, the part of the manual you read concerns entries with non market orders - those would be expiring on the bar they were placed on if not filled. So that meaning then: if you trade condition for entry is still true and your limit order expires, you would need to resubmit then on the next bar until filled.

    Comment


      #3
      Thanks, Bertrand. That's very helpful.

      Now, if I want to completely duplicate the behaviour of Backtest in the Live environment, I would really be saying that I want all actions (enter, exit, stop loss, profit target,etc) to be calculated and therefore actioned ONLY at bar close, since that is the only information that Backtest has, right?

      So, how would I implement that in the live environment? I can set CalculateOnBarClose to be true at the start of Initialize() but is that sufficient?

      Thanks!
      Multi-Dimensional Managed Trading
      jeronymite
      NinjaTrader Ecosystem Vendor - Mizpah Software

      Comment


        #4
        You're welcome - CalculateOnBarClose in backtesting will always be 'true'.

        This will not change how orders are filled live - there's simply a difference in backtesting vs live trading, backtesting being a close approximation, but of course market dynamics are always realtime only and not known in advance.

        You can backtest in Market Replay to be able to see how your strategy fares with recorded realtime data and thus having access to the tick formation of the replayed bars for better simulated fills, stops...



        That would be the recommending cycle to go through before trading live with a script.

        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
        369 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
        572 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