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:	229
Size:	10.3 KB
ID:	1229465


    close all running positions

    Click image for larger version

Name:	image.png
Views:	209
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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      90 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      137 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      120 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      69 views
      0 likes
      Last Post PaulMohn  
      Working...
      X