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 CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      388 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      260 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      218 views
      1 like
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      302 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      268 views
      0 likes
      Last Post CarlTrading  
      Working...
      X