Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How do you prevent a strategy from submitting orders when the market is closed?

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

    How do you prevent a strategy from submitting orders when the market is closed?

    Hello,

    I have made a strategy in strategy builder, and although I have "end on session close" configured properly, the strategy will still submit orders when the market is closed, triggering a margin call.

    How do I make the strategy not submit orders during a closed session in strategy builder? I see "first bar of session" but not "end of session" in strategy builder.

    Manually inputting a time restriction is not ideal since I trade multiple instruments with different market hours.

    #2
    Is this happening during your live trading?

    It might be best to put a time based check into your code, this would
    ensure that no orders are submitted after a certain specific time (say,
    5 mins before market close).

    I used this Google search, it found lots of helpful links.

    Comment


      #3
      Hello,

      Thank you for your response.

      Yes this is happening during live trading which triggered a margin call.

      I am aware of how to do time restrictions, but since I trade multiple instruments which have different market open and close times, I want to make the strategy only make trades during market open without having to manually enter these market hours over and over every time I set up a strategy. I want the strategy to use "instrument settings" for trading hours.

      I want to be able to do this in strategy builder.

      Comment


        #4
        Hello burmaz,

        The strategy would be following the TradingHours template, and would not be processing data or submitting orders outside of those hours.

        What Trading hours template is applied in the Data Series when running the script?

        Synchronization orders are different. When using Wait until flat Synchronize Account or Immediately Submit Synchronize Account start behaviors, these synchronization orders will be submitted immediately as the strategy is enabled. These orders will be marked as so on the Orders tab of the Control Center.
        https://ninjatrader.com/support/help..._positions.htm

        Last, the Exit on session close takes place before the end of the session, so the exit orders have time to fill. It is possible with the logic, to enter new trades after the exit on session close event has occurred. It is possible to code in the logic to prevent order submissions after the exit on close until the end of the session trading hours using a SessionIterator.
        Below is a link to an example.
        NinjaTrader Community, A common inquiry is that the Exit on close didn't work in a NinjaScript Strategy because there is a position after the exit on close should have occurred. When viewing the log we often find that the Exit on close does indeed exit the position shortly before the end of the session (based on the Exit on
        Last edited by NinjaTrader_ChelseaB; 10-31-2021, 04:03 PM.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello burmaz,

          The strategy would be following the TradingHours template, and would not be processing data or submitting orders outside of those hours.

          What Trading hours template is applied in the Data Series when running the script?

          Synchronization orders are different. When using Wait until flat Synchronize Account or Immediately Submit Synchronize Account start behaviors, these synchronization orders will be submitted immediately as the strategy is enabled. These orders will be marked as so on the Orders tab of the Control Center.
          https://ninjatrader.com/support/help..._positions.htm

          Last, the Exit on session close takes place before the end of the session, so the exit orders have time to fill. It is possible with the logic, to enter new trades after the exit on session close event has occurred. It is possible to code in the logic to prevent order submissions after the exit on close until the end of the session trading hours using a SessionIterator.
          Below is a link to an example.
          https://ninjatrader.com/support/foru...ose#post100666


          Hello,

          I'm using the "instrument settings" time template.

          I looked at the link you posted and it looks like it is about hard coding the solution. How do I do this on strategy builder?

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          85 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          48 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          29 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          32 views
          0 likes
          Last Post TheRealMorford  
          Started by Mindset, 02-28-2026, 06:16 AM
          0 responses
          67 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X