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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      656 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      371 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      109 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      574 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      579 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X