Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Gross Profit accumulating NetPofit?

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

    Gross Profit accumulating NetPofit?

    Hello,

    I'm a ittle confused ...

    I'm attempting to access GrossProfit: Print( " Gross Profit " + SystemPerformance.AllTrades.TradesPerformance.Gros sProfit.ToString(format));

    However what see is that it is printing out the accumulation of NetProfit not Gross Profit as can be seen in the print log:

    07-20-2023 09:33:11 Strategy: Entering Long Market $4,591.00
    07-20-2023 09:33:11 OnOrderUpdate: Order PROFIT TARGET is completely Filled. Order Name: Profit target
    07-20-2023 09:33:11 OnPositionUpdate: PROFIT (GROSS) $100.00 Commission $24.40 Net Profit $75.60 Gross DayProfit $100.00 Gross Strategy Profit $100.00 Net Strategy Profit $563.60
    07-20-2023 09:33:11 Gross Profit $75.60
    07-20-2023 10:08:12 Entering Short Market $4,584.00
    07-20-2023 10:08:12 OnOrderUpdate: Order PROFIT TARGET is completely Filled. Order Name: Profit target
    07-20-2023 10:08:12 OnPositionUpdate: PROFIT (GROSS) $100.00 Commission $24.40 Net Profit $75.60 Gross DayProfit $200.00 Gross Strategy Profit $200.00 Net Strategy Profit $688.00
    07-20-2023 10:08:12 Gross Profit $151.20​

    Is this the expected behaviour?

    Many Thanks, Caesar.

    #2
    Hello Skechers,

    What is the code for other print that you are using?

    The AllTrades collection includes historical trades so that may be where the discrepancy is coming from. When using AllTrades you generally need to use extra logic to isolate a specific sessions values.

    Comment


      #3
      This is in OnUpdatePosition:

      // When a position is closed, add the last trade's Profit to the currentPnL
      LastTrade = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1];
      Commission = LastTrade.Commission;
      EntryPrice = LastTrade.Entry.Price;
      ExitPrice = LastTrade.Exit.Price;
      OrderAction = LastTrade.Exit.Order.OrderAction.ToString();
      OrderType = LastTrade.Exit.Order.OrderType.ToString();

      // Profit Target hit
      if (LastTrade.ProfitCurrency > 0)
      {
      if (OrderAction == "Sell")
      {
      TradeDelta = ExitPrice - EntryPrice;
      GrossProfit = DeltaPriceToProfit(TradeDelta) * ContractQuantity;
      }
      else if (OrderAction == "BuyToCover")
      {
      TradeDelta = EntryPrice - ExitPrice;
      GrossProfit = DeltaPriceToProfit(TradeDelta) * ContractQuantity;
      }

      DayProfit = DayProfit + GrossProfit;
      StrategyProfit = StrategyProfit + GrossProfit;
      StrategyCommission = StrategyCommission + Commission;

      PrintLog(1, " OnPositionUpdate: PROFIT (GROSS) " + GrossProfit.ToString(format) + " Commission " + Commission.ToString(format) + " Net Profit " + (GrossProfit - Commission).ToString(format) + " Gross DayProfit " + DayProfit.ToString(format) + " Gross Strategy Profit " + StrategyProfit.ToString(format) + " Net Strategy Profit " + (StrategyProfit + StrategyCommission).ToString(format));
      Draw.Square(this, "Profit " + CurrentBar, true, 0, Low[0] - SecondaryPlotGap * 15 - SecondaryPlotOffset - PrimaryPlotOffset, Brushes.Lime, true);
      PrintCSV(LogWindow, "Profit," + ContractQuantity + "," + OrderAction + "," + OrderType + "," + EncodeComma(EntryPrice.ToString(format)) + "," + EncodeComma(ExitPrice.ToString(format)) + "," + EncodeComma(GrossProfit.ToString(format)) + "," + EncodeComma(Commission.ToString(format)) + "," + EncodeComma((GrossProfit - Commission).ToString(format)));

      PrintLog( 1, " Gross Profit " + SystemPerformance.AllTrades.TradesPerformance.Gros sProfit.ToString(format));
      }​

      Comment


        #4
        Hello Skechers,

        While I wouldn't be able to comment on the custom calculation you are doing I can provide a link which outlines how the platform calculates these values. You can find details on how the platform calculates net profit and gross profit in the following link.


        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        87 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        132 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        65 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        118 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        67 views
        0 likes
        Last Post PaulMohn  
        Working...
        X