Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy placing an order on the opening bell

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

    Strategy placing an order on the opening bell

    Hello,

    I am experiencing issues where my strategies are submitting and executing orders right on the opening bell and I am unable to understand why.

    My strategies are set to 'Calculate.OnBarClose', use the 'US Equities RTH' trading hours template and to prevent any order execution on the open I have added this line of code...

    Code:
    if (State == State.Realtime && ToTime(Time[0]) >= 092900 && ToTime(Time[0]) < 093100) return;​
    In my mind if a strategy is on the M5 timeframe then the first time the strategy will evaluate the conditions will be on the close of the first candle of the session, so at 9:35am EST. Or do I have that wrong? Is the first time the strategy evaluates the conditions on the close of the bar before the open i.e the close of the 9:30am candle?

    The odd thing about this behaviour is that after the trade stopped out, I ran the Strategy Performance "Real Time & Historical" and the trade wasn't recorded on the list of trades. when it occurred previously on another strategy, I also ran a backtest after the close and the trade wasn't on the list of trades either. I used high order fil resolution with tick data for both of these checks.

    It has happened to me a handful of times before on other strategies but I've never understood why, it is not consistent on a single strategy. I don't believe this is the expected behaviour.

    Other than waiting until 9:31am to manually enable my strategies can you offer any advice?

    Thanks,

    Neil

    #2
    Hello Neil,

    If the strategy is in real-time and the time is after 9:29 am and before 9:31 am, then return and do nothing.
    (If the time is before 9:29 am and after 9:31, then continue running code below)

    To confirm, you want the script to be able to continue running the code as long as the time not between 9:29 and 9:31, is this correct?
    So any time during the day except for these few minutes, is this correct?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      NinjaTrader_ChelseaB, that is kind of correct. I added the line of code to try to prevent this issue form arising after I'd already experienced it. I thought that if trades were being opened on the opening bell then prevented my strategy from doing anything between 9:29am and 9:31am then any order which may have been placed at the open wouldn't be placed. It turns out this isn't working.

      The crux of this issue is that I do not know why my strategy executes a trade at the opening bell, I can understand an order being placed after the first bar of the session but not before that bar has even formed.

      Are strategies evaluated on at the close of the candle before the open or should they only be evaluated after the close of the first candle after the open?

      Comment


        #4
        Hello burtoninlondon,

        Have you added debugging prints and enabled TraceOrders to understand why the order is being submitted when it is being submitted?

        Below is a link to a support article on adding debugging prints to understand behavior.


        Do you have an order being submitted outside of market hours which is filling when the market opens?

        What is the name of the order?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          NinjaTrader_ChelseaB, thanks for the info, I'll take a look at the article.

          I've checked my executions and the trades are being placed 1 second before market open i.e 09:29;59. There should be no reason for this given that the strategy is trading on US Equities RTH trading hours template and I've got the return and do nothing statement in my code to prevent trades between 09:29 and 09:31.

          Neil

          Comment


            #6
            Hello Neil,

            Please provide the print output text file so that I may assist.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            110 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            59 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            37 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            41 views
            0 likes
            Last Post TheRealMorford  
            Started by Mindset, 02-28-2026, 06:16 AM
            0 responses
            78 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Working...
            X