Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

how to calculate profits

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

    how to calculate profits

    i have multi scalein and scaleouts for my strategy.. So my custom trade object will have multiple entries and exits. How do i programatically find out what the strategy gains are after every trade as the NT performance objects would be matching in different order,
    for eg. Click image for larger version

Name:	JC4fjLj[1].png
Views:	184
Size:	60.6 KB
ID:	1309110 if u can see from screenshot, NT treats it as 2 trades. all i want is to programmaical find out how much money i had made after the oriiginal and scale1 values are closed.
    it is not clear from the documentation if the SystemPerformance.AllTrades.TradesPerformance.Perf ormanceMetrics represents all the trades in the system or only the trade that was run from my running strategy

    #2
    Hello junkone,

    It would be recommended to use a unique entry order with each entry quantity set to the amount you want to scale in or out, and have the exit orders from entry signals attached to the signal names of the entries.

    Below is a link to an example.


    That said, each exit order would initiate a new trade object in the SystemPerformance.AllTrades collection.

    If you wanted to add the profit from the last number of trades together, you could do this in a for loop
    Code:
    int numberOfTradesToAdd = 3; // this could be incremented from 0 from OnExecutionUpdate() when the exit orders fill
    Code:
    double combinedProfit = 0;
    
    for (int index = SystemPerformance.AllTrades.Count - 1; index > SystemPerformance.AllTrades.Count - 1 - numberOfTradesToAdd; index--)
    {
    thisTrade = SystemPerformance.AllTrades[index];
    Print(string.Format("entry: {0}, exit: {1}, ProfitCurrency: {2}", thisTrade.Entry.Name, thisTrade.Exit.Name, thisTrade.ProfitCurrency));
    combinedProfit += thisTrade.ProfitCurrency;
    }
    
    Print(string.Format("combined profit of last {0} trades: {1}", numberOfTradesToAdd, combinedProfit));
    }
    Below is a link to the help guide which provides sample code on getting the last trades information.

    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I am doing what you are suggesting. However, i want to make sure that SystemPerformance.AllTrades is specific to the running strategy and not on the overall NT system!!! Is that a valid assumption

      Comment


        #4
        Hello junkone,

        Yes, that is correct. The SystemPerformance collection only holds trades made by the instance of the strategy.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        39 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        124 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        64 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        41 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X