Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 pechtri, 06-22-2023, 02:31 AM
      10 responses
      124 views
      0 likes
      Last Post Leeroy_Jenkins  
      Started by judysamnt7, 03-13-2023, 09:11 AM
      4 responses
      59 views
      0 likes
      Last Post DynamicTest  
      Started by ScottWalsh, Yesterday, 06:52 PM
      4 responses
      36 views
      0 likes
      Last Post ScottWalsh  
      Started by olisav57, Yesterday, 07:39 PM
      0 responses
      7 views
      0 likes
      Last Post olisav57  
      Started by trilliantrader, Yesterday, 03:01 PM
      2 responses
      22 views
      0 likes
      Last Post helpwanted  
      Working...
      X