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


    close all running positions

    Click image for larger version

Name:	image.png
Views:	203
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 NullPointStrategies, Today, 05:17 AM
      0 responses
      52 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      130 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      70 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      44 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      49 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X