Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

IncludeCommission doesn't work

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

    IncludeCommission doesn't work

    Hello,

    I have used "IncludeCommission = false" in my strategy but it doesn't work. For example, when the strategy buy and sell with the same price the value of lastTrade.ProfitTicks it's a decimal number equal to the commission of the broker, and it would be equal to zero.

    #2
    Hello soyjesus,

    Thank you for your note.

    IncludeCommission would only affect the behavior of the strategy in a historical backtest, either on historical data in a chart or in the Strategy Analyzer for a backtest. Are you running the strategy in real time on the Sim account or are you looking at a backtest in the Strategy Analyzer?

    Thanks in advance; I look forward to assisting you further.

    Comment


      #3
      Ok, I'm running the strategy in real time and I need to know the profit of last trade. Is there any way to do it?

      Comment


        #4
        Hello soyjesus,

        Thank you for your reply.

        You would get that from the TradeCollection. The first example on this page shows how to get the PnL of the most recently closed trade:



        Please let us know if we may be of further assistance to you.

        Comment


          #5
          Yes Kate, but the PnL apply the commission too. I need the Profit/Loss without commission.

          Comment


            #6
            Hello soyjesus,

            Thank you for your reply.

            Try adding the commissions back to the profit:

            Code:
            // Accesses the last trade in the strategy
            // and prints out the gross profit to the output window
            if (SystemPerformance.AllTrades.Count > 1)
            {
            Trade lastTrade = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1];
            
            Print("The last trade gross profit is " + (lastTrade.ProfitCurrency + lastTrade.Commission));
            }
            Please let us know if we may be of further assistance to you.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            62 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            134 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            75 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
            50 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X