Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 Haiasi, Today, 06:53 PM
          1 response
          3 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by ScottWalsh, Today, 06:52 PM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by ScottW, Today, 06:09 PM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by ftsc2022, 10-25-2022, 12:03 PM
          5 responses
          256 views
          0 likes
          Last Post KeyonMatthews  
          Started by Board game geek, 10-29-2023, 12:00 PM
          14 responses
          244 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Working...
          X