Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop is getting cancelled while position is still open

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

    Stop is getting cancelled while position is still open

    For reference, I'm basing my script off of the ProfitChaseStopTrailExitOrders example here: https://forum.ninjatrader.com/forum/...ing#post802269

    I'm trying to scale in to a position, so I have 2 entries (with different signal names) and 1 target and 1 stop (tied to no entry signal). My target is only for half of the position, leaving the other half to run. My issue is that when the target hits, it is cancelling the stop even though the runners are still active. An outline of the events:
    1. First entry, qty 2
    2. Set target, qty 1
    3. Set stop, qty 2
    4. --price moves--
    5. Second entry, qty 2
    6. Amend target, qty 2
    7. Amend stop, qty 4
    8. --price moves--
    9. Target hit, qty 2; still have 2 runners
    10. Stop is cancelled by system due to "position being closed", even though position is still open
    I'm obviously misunderstanding something here, but I would have thought that by not tying the target or stop to a particular entry, it would just be based off of the global position. I attached a log of the events to help clarify.
    Attached Files

    #2
    Hello pshift,

    Thank you for your post.

    I understand you have 2 entries and would like to have 1 profit target and leave the second entry to run. As for the stop loss, if you want a stop in place for both entries you will likely need to configure two stops with different signal names that are tied to each entry with the fromEntrySignal property. Even if you want the stops to behave in the same manner, it is best to create separate stops/targets tied to each entry rather than trying to use one stop or target that applies to multiple separate entries.

    For more information on using signal names in exit methods, please see the "FromEntrySignal - Using Signal Names in Exit Methods" information here:Please let us know if we may be of further assistance.

    Comment


      #3
      I suspected that creating multiple stops and targets was going to be the solution, but for my own edification - why is it cancelling the stop while the position is still open? Since I'm not specifying an entry signal, the documentation seems to infer that the order applies to the whole position. In this case the whole position is still open, so I would expect the stop to still be valid. I'm just curious what is tying the stop to the first entry signal when I explicitly did not do so myself.

      Comment


        #4
        Hello pshift,

        Thank you for your reply.

        Without a reduced sample of your strategy to test this out, I suspect the answer to your question may have to do with the historical order fill processing. In a backtest, order fills are based on OHLC values and not processed in the same way as they would be on incoming market data. If you were to test the strategy for the same period of time on the Playback connection, you may experience different results where the stop loss quantity is modified rather than it being canceled thinking the position was closed. Another item you could consider if you want to have a stop loss for the entire position without being tied to an entry signal is setting the quantity based on the Position.Quantity and use ChangeOrder() when necessary if you are using isLiveUntilCanceled orders:Please let me know if I may be of further assistance.

        Comment


          #5
          I see, thanks for the info.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          20 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          119 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          63 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          41 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          45 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X