Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order Profit Loss (PL)

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

    Order Profit Loss (PL)

    Hi,

    I would like to see PL of the given IOrder (assuming it was either a position entry, closed by a corresponding exit order, or, an exit order, with a corresponding entry order).

    Please confirm that the following code is correct way for doing that:

    I am talking about unmanaged code

    Code:
    private bool TryGetOrderPL(IOrder order, bool asEntry, out double pl)
            {
                bool found = false;
                pl = 0.0;
                for (int i = Performance.AllTrades.Count - 1; i >= 0; i--)
                {
                    Trade trade = Performance.AllTrades[i];
                    bool me = (asEntry ? trade.Entry.Order : trade.Exit.Order) == order;
                    if (me)
                    {
                        found = true;
                        pl += trade.ProfitCurrency * trade.Quantity;
                    }                
                }
                return found;
            }
    Thank you.
    Last edited by alex.nt; 10-21-2012, 01:03 PM.

    #2
    Alex,

    Have you tested it? It looks ok from here. From our help guide :

    Trade.ProfitCurrency
    A double value representing profit in currency for one traded unit. Multiply this value by the trade Quantity to get the total profit in currency for the trade.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Well, it appears to work fine, just wanted to confirm. Nevertheless, I would expect that we could have a built in facility for that

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      647 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      368 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      108 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      571 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      573 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X