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

Unmanaged Approach Cancelling Existing Orders On Start

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

    Unmanaged Approach Cancelling Existing Orders On Start

    I've got an issue with my unmanaged strategy whereby if its restarted, and there's an open position, the existing exit orders are being cancelled when the strategy starts - but not the position.

    I don't want either to be cancelled. I want to be able to stop a strategy that's in a position and restart at some stage without it cancelling existing orders or positions.

    I was able to reproduce this on the attached strategy which I found on these forums;

    1. Enable strategy from chart with StartBehavior.ImmediatelySubmit
    2. Market order is filled with stop exit order.
    3. Uncheck enabled in the strategies tab of control center
    4. Recheck enabled in the strategies tab of control center

    This results in the previous position's stop order being cancelled, but the position left open. And then a second position and its stop order is submitted.

    How can I stop this from happening?
    Attached Files

    #2
    Here's a simpler example
    Attached Files

    Comment


      #3
      Unmanaged Approach Cancelling Existing Orders On Start

      [I accidentally posted this in the NT7 Forum Earlier, so have re-posted it here]

      I've got an issue with my unmanaged strategy whereby if its restarted, and there's an open position, the existing exit orders are being cancelled when the strategy starts - but not the position.

      I don't want either to be cancelled. I want to be able to stop a strategy that's in a position and restart at some stage without it cancelling existing orders or positions.

      I was able to reproduce this on the attached strategy which I found on these forums;

      1. Enable strategy from chart with StartBehavior.ImmediatelySubmit
      2. Market order is filled with stop exit order.
      3. Uncheck enabled in the strategies tab of control center
      4. Recheck enabled in the strategies tab of control center

      This results in the previous position's stop order being cancelled, but the position left open. And then a second position and its stop order is submitted.

      How can I stop this from happening?
      Attached Files

      Comment


        #4
        Hello reach4thelasers,

        Thanks for writing in today.

        The behavior you are witnessing with working orders being canceled when restarting the strategy is expected. When you restart a strategy, or enter a strategy when you have open orders, the Start Behavior functionality controls how those current orders are handled and how the entering strategy should behave when there are current working orders.

        The Start Behavior functionality is controlled by these settings:
        • Wait until flat
        • Wait until flat, synchronize account
        • Immediately submit
        • Immediately submit, synchronize account
        • Adopt account position
        • Synchronize all strategies


        Wait until flat is the default behavior where the strategy will cancel all current orders and wait 40 seconds for the orders to cancel before submitting orders of its own.

        I suggest you try Adopt account position with your strategy. Please bear in mind you must add the logic to catch if you are entering the the strategy in a long or short position as well as any corner cases you may run into.

        For more information on Start Behavior and syncing account positions, please refer to the documentation below. Please also refer to the IsAdoptAccountPositionAware section of the documentation for enabling the Adopt account position option.

        Syncing Account Positions - https://ninjatrader.com/support/help..._positions.htm

        IsAdoptAccountPositionAware - https://ninjatrader.com/support/help...itionaware.htm

        Please let me know if you have any further questions.
        JimNinjaTrader Customer Service

        Comment


          #5
          Hey Jim

          Thanks for the quick response.

          I don't understand how this is expected behavior. I'm literally disabling the strategy, and re-enabling immediately. Therefore the strategy position is the same as it was a few seconds ago.

          Furthermore, how is it in any way acceptable for Ninjatrader to "unprotect" a position - leaving it naked and exposing my account to the risk of huge losses. This should never be allowed to happen under any circumstances.

          I don't understand the logic behind closing the protective orders, but leaving the position open - or how this could in any way be a desirable or expected feature? Such talk is madness!!

          It could blow-out my whole account. Seriously can you tell me a use-case for this expected feature aside from zeroing people's accounts?

          It wouldn't be hard to make Ninjatrader recognise that the open position is the same as the new strategy position, and the bracket orders are protecting that position, and just let things continue..... THAT is expected behavior. Not exposing users to risk of massive losses by unprotecting open positions.

          Comment


            #6
            Hello reach4thelasers,

            The behavior you are looking for would be outlined in Adopt account position, Immediately submit, or Immediately submit, synchronize account. By default, the Wait until flat behavior is used because it expects the least from the strategy author to maintain the current position.

            Adopt account position, Immediately submit, and Immediately submit, synchronize account contain the following rule:
            Any active orders on the account previously generated by the strategy that does not match* an active strategy order will be cancelled. Should the strategy be unable to cancel and receive confirmation on the cancellation of these orders within 40 seconds the strategy will not start and an alert will be issued.

            A previously generated order is considered to match an active strategy order when the order action, order type, quantity, limit price, and stop price are exactly identical.
            Wait until flat uses the following rule:
            When your strategy starts it will check for any active orders previously generated by the strategy on your account and cancel those first. Should the strategy be unable to cancel and receive confirmation on the cancellation of these orders within 40 seconds the strategy will not start and an alert will be issued.
            Please let me know if I may be of further assistance.
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Sparkyboy, Today, 10:57 AM
            0 responses
            1 view
            0 likes
            Last Post Sparkyboy  
            Started by TheMarlin801, 10-13-2020, 01:40 AM
            21 responses
            3,916 views
            0 likes
            Last Post Bidder
            by Bidder
             
            Started by timmbbo, 07-05-2023, 10:21 PM
            3 responses
            152 views
            0 likes
            Last Post grayfrog  
            Started by Lumbeezl, 01-11-2022, 06:50 PM
            30 responses
            809 views
            1 like
            Last Post grayfrog  
            Started by xiinteractive, 04-09-2024, 08:08 AM
            3 responses
            11 views
            0 likes
            Last Post NinjaTrader_Erick  
            Working...
            X