Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Access to performance metrics

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

    Access to performance metrics

    My strategy requires access to various performance metrics:

    (1) <net profit> + <open position profit> - <total commissions paid>
    While I've been able to find TradesPerformance.NetProfit, I could not find the other fields. Obviously, NinjaTrader knows these values - how can I access them?

    (2) I would really like to create my own performance metrics object and use it's values in the strategy. I have added methods to access the values I am after to my custom performance metrics object. However, it seems I can't access these values from the strategy. Is there a sample available showing how to do that?


    Thank you,
    best regards, Felix

    #2
    I've been able to partially answer my own question:
    1)
    double netProfit = SystemPerformance.AllTrades.TradesPerformance.NetP rofit;
    double totalCommission = SystemPerformance.AllTrades.TradesPerformance.Tota lCommission;

    2)


    However, the question regarding the open position profit still stands. This is what I have been trying:
    double openPositionProfit = 0;
    for (int i = 0; i < Positions.Length; i++)
    {
    switch(Positions[i].MarketPosition)
    {
    case MarketPosition.Long:
    openPositionProfit += Positions[i].GetUnrealizedProfitLoss(PerformanceUnit.Currency, Closes[i][0]);
    break;
    }
    }


    Unfortunately the value returned by that code is nowhere close to correct. This may or may not be related to the fact that I am scaling position sizes on a daily basic, which might screw up the accuracy of the average entry price. Is there a better way to do this?

    Thank you,
    best regards, Felix

    Comment


      #3
      filed a bug here: http://ninjatrader.com/support/forum...387#post479387

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      81 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      42 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      64 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      66 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      54 views
      0 likes
      Last Post CarlTrading  
      Working...
      X