Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How can I close all positions when an unrealised profit is hit?

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

    How can I close all positions when an unrealised profit is hit?

    Hi, for example, I have multiple positions open, and overall (After profit loss calculation) I am in profit, for example, $50 I want to close all the running positions. They can be mixed like one is buying the other is selling.

    How can I make a strategy for this?

    Thanks
    Sarder


    When unrealized profit reaches $50

    Click image for larger version

Name:	image.png
Views:	233
Size:	10.3 KB
ID:	1229465


    close all running positions

    Click image for larger version

Name:	image.png
Views:	213
Size:	9.9 KB
ID:	1229466


    #2
    Sounds like you're asking about 'Flatten Everything'.

    Good reading here.

    Comment


      #3
      Hello sarder2008,

      bltdavid may be suggesting to use Account.Flatten() to flatten a collection of instruments.
      https://ninjatrader.com/support/help...t8/flatten.htm

      As an example of using linq to select a list of instruments that have an open position.
      Code:
      myAccount.Positions.Where(x => x.MarketPosition != MarketPosition.Flat).Select(x => x.Instrument)
      Use the Addon approach to get the account unrealizedpnl.
      Code:
      if (Account.Get(AccountItem.UnrealizedProfitLoss), Currency.UsDollar) >= 50)
      {
      // Do something;
      }



      https://ninjatrader.com/support/help...ccountitem.htm
      Chelsea B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      58 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      34 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      195 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      360 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      281 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X