Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Close position closes also the strategy

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

    Close position closes also the strategy

    Hi, in my code I need to flatten a position for a single instrument. I'm using Account.Positions.FindByInstrument(Instrument).Clo se() which works OK regarding closing the position, but it also closes (disables) the strategy. Is there a call that closes a position but keeps the strategy runnig? Or any parameter of the strategy to set? Any help, even undocumented or unsupported :-), appreciated. Thank you.

    #2
    Hello mantak007,

    Thank you for your post.

    You can use the barsInProgess index to submit Exit() methods to the instrument in your strategy. For information on using multiple instruments in your strategy please visit the following link: http://www.ninjatrader.com/support/h...nstruments.htm
    For information on the Managed Order Methods in NinjaScript please visit the following link: http://www.ninjatrader.com/support/h...d_approach.htm

    Please let me know if I may be of further assistance.

    Comment


      #3
      Hi Patrick, thank you for the info, unfortunately I'm using unmanaged approach in my strategy. I just need to close a position even if it has been opened by another strategy, by click in DOM, anywhere. Will this work too?

      Comment


        #4
        Hello mantak007,

        Thank you for your response.

        The barsInProgressIndex is present in the SubmitOrder() method as well: http://www.ninjatrader.com/support/h...ubmitorder.htm

        You cannot use the strategy to close positions that were opened from other strategies or order entry windows. You can however sync the account position on start up of the strategy, for information on syncing your account position and strategy position please visit the following link: http://www.ninjatrader.com/support/h..._positions.htm

        Please let me know if I may be of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        671 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        379 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        111 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        575 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        582 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X