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


    close all running positions

    Click image for larger version

Name:	image.png
Views:	206
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, 03-31-2026, 09:41 PM
      1 response
      79 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      63 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      63 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      54 views
      0 likes
      Last Post CarlTrading  
      Working...
      X