Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi Instrument Current Net PNL for the day

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

    Multi Instrument Current Net PNL for the day

    Hello NT Support,

    I have a multi instrument strategy where I'm trying to track on each bar close, the current net PNL for the day to monitor the highs and lows (similar to MFE / MAE) across both closed positions and open positions. For example I need to be able to answer the question:

    On this date the strategy made $X in net PNL however during that day the net pnl was as low as $Y and as high as $T.
    Net PNL being both closed trades and open unrealized PNL.

    I understand I can iterate through my current open positions to get the unrealized PNL with something similar to the following:

    Note: TradedSymbols is an internal collection I use to track every instrument I'm trading along with specific settings for that instrument and how it trades it.
    Code:
    double pnl = 0;
    
    for (int i = 0; i < TradedSymbols.Count; i++)
    {
        pnl += Positions[i].GetUnrealizedProfitLoss(PerformanceUnit.Currency, Closes[i][0]);
    }
    I assume the above will give me the unrealized PNL for all open positions at that moment in time. The question is how would I (or can I) get the closed PNL for that trading day? I would assume I could do something like:

    Code:
    SystemPerformance.AllTrades.TradesPerformance.Currency.CumProfit;
    But my assumption is that this will include all trades for prior days. Can the current day be captured or do I have to manually track this in code? Thanks.

    #2
    If we can't capture the realized PNL for the day only then perhaps it's good enough to look at thee AllTrades.TradesPerformance before any trades are taken for the day as the starting point then subtract that from the same value throughout the day including the unrealized pnl? Just wondering if there is a more straightforward way. Thanks.

    Comment


      #3
      Ok that seems to work, answered my own question, the following worked for those that find this in the future:

      Code:
      double BalanceLow = double.MaxValue;
      double BalanceHigh = 0;
      double BalancePriorDay = 0;
      
      private void CollectAccountInfo()
      {
          double pnl = SystemPerformance.AllTrades.TradesPerformance.Curr ency.CumProfit - BalancePriorDay;
      
          for (int i = 0; i < TradedSymbols.Count; i++)
          {
              if(Positions[i].MarketPosition != MarketPosition.Flat)
                  pnl += Positions[i].GetUnrealizedProfitLoss(PerformanceUnit.Currency, Closes[i][1]);
          }
      
          BalanceLow = Math.Min(BalanceLow, pnl);
          BalanceHigh= Math.Max(BalanceHigh, pnl);
      }
      
      protected override void OnBarUpdate()
      {
          if[BarsInProgress == 0)
              CollectAccountInfo();
      
          if(BarsInProgress == 0 && BarsArray[0].IsFirstBarOfSession)
          {
              BalanceLow = double.MaxValue;
              BalanceHigh = 0;
              BalancePriorDay = SystemPerformance.AllTrades.TradesPerformance.Currency.CumProfit;
          }
      }
      This is a modified/simplified version for example purposes....
      Last edited by fxRichard; 01-28-2021, 06:09 AM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      51 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      127 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      69 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      42 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      46 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X