Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DataSeries tracking PnL

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

    DataSeries tracking PnL

    I’m trying to use DataSeries to track intraday PnL on an hourly basis.

    I’m using a data series like so:

    Code:
                        if (Performance.AllTrades.Count != tradeCount)
                        {
                            tradeCount = Performance.AllTrades.Count;
    
                            foreach (Trade x in Performance.AllTrades)
                            {
                                if (x.Exit.Time.Date.CompareTo(Time[0].Date) == 0)
                                {
                                    dayPnL += x.ProfitCurrency;
    
                                }
    
                            }
    
                        }
    
                        int y = 0;
                        dayPnL = 0;
    
                        foreach (Position x in Positions)
                        {
    
                            dayPnL += x.GetProfitLoss(Closes[y][0], PerformanceUnit.Currency);
    
                            y++;
    
                        }
    
                        intraDayPnL.Set(dayPnL);
                        intraDayPnLList.Add(dayPnL);
    However, when using printing these values in OnTerminate I get 0 as the max and min (see below)

    Code:
                    double test = MAX(intraDayPnL, 200)[0];
    
                    double max = double.MinValue;
                    double min = double.MaxValue;
    
                    foreach (object item in intraDayPnLList) {
    
                        if (item is double)
                        {
                            if ((double)item > max) {
                                max = (double)item;
                            }
    
                            if ((double)item < min)
                            {
                                min = (double)item;
    
                            }
                        }
    
                    }
    
    
                    Print("The highest intra-day PnL is " + MAX(intraDayPnL, (intraDayPnL.Count - 1))[0]);
                    Print("The lowest intra-day PnL is " + MIN(intraDayPnL, (intraDayPnL.Count - 1))[0]);
    
                    Print("Highest list value " + max);
                    Print("Highest list value " + min);
    Yet, when using the list I created I get different values?

    Could you please help?

    #2
    Hello systemtrader10,

    Thank you for your post.

    I am investigating this further on my end and I will follow up with you shortly.

    Comment


      #3
      Hello systemtrader10,

      Thank you for your patience.

      I cannot recreate this on my end. The Output I am seeing when OnTermination() is called contains a value. However, if you could provide a simplified version of your script that we may test on our end to isolate this matter it would be most helpful.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      56 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      143 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      160 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      96 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      276 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X