Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unrealized PnL calculation...

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

    Unrealized PnL calculation...

    I'm attempting to shorten up the unrealized profit calculation script. There will be a lot of indexes but just for example's sake...

    If I am wanting to use...

    for (int i = 0; i < 2; i++)
    {
    unrlzdPnl += Positions[i].GetProfitLoss(Closes[i][0],PerformanceUnit.Points);
    }

    is this equivalent to my old way of..

    unrlzdPnl = ((Positions[0].GetProfitLoss(Closes[0][0],PerformanceUnit.Points)) + (Positions[1].GetProfitLoss(Closes[1][0],PerformanceUnit.Points)));

    It doesn't seem to be from the print statements. Any idea how I can use the first way to replicate the second?
    Last edited by Delta007; 03-12-2014, 09:07 PM.

    #2
    Delta007, for the first you would need to reset the tracker on each bar update for example, otherwise it would just continue to cumulate across all trades seen which is not what you seek...

    Comment


      #3
      How would the tracker be reset, would this be something with BIP or a bool, or simply just putting the statement within the OBU method?

      Comment


        #4
        Would just set it to 0.0 at your OBU update start, so it only builds the sum of the positions across the indices and would not cumulate.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        572 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        331 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        549 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        550 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X