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 CarlTrading, 03-31-2026, 09:41 PM
            1 response
            47 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            23 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            33 views
            1 like
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            51 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            42 views
            0 likes
            Last Post CarlTrading  
            Working...
            X