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 charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      51 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      142 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      160 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      96 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      275 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X