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 NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        56 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        132 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        73 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        49 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X