Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

How to get the P&L from the brokers software?

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

    How to get the P&L from the brokers software?

    Hi,

    I am trying to get the P&L from the TWS of IB.
    See photo attached. I am trying to get the realized P&L when I am closing a trade (-629.04)

    I can't seem to get it. Here is what I tried:

    Print("Net profit is: " + SystemPerformance.RealTimeTrades.TradesPerformance .NetProfit);
    Print("Total commission is: " + SystemPerformance.RealTimeTrades.TradesPerformance .TotalCommission);

    NetProfit gives me a number of: -600
    TotalCommision gives me a number of: 0

    Thanks for helping.

    #2
    Hello zoharcho

    Thank you for the post.

    The prints you have shown would be the values from your strategies virtual performance where as the picture of IB is the actual account value. To access the actual account values you could use the Account property and its Get method. The Get method takes an Account Item: https://ninjatrader.com/support/help...ub=accountitem



    Code:
    Account.Get(AccountItem.RealizedProfitLoss, Currency.UsDollar)
    You can find details on what account values the varous providers offer in the following link: https://ninjatrader.com/support/help...TheAccountsTab

    I look forward to being of further assistance.


    JesseNinjaTrader Customer Service

    Comment


      #3
      Great explanation.

      I see that every broker sends different information regarding the realized P&L.

      1) I thought of maybe doing it using the execution.Commission interface, on the function OnExecution. Will it get the proper value for the commission?


      2) If the answer is yes, will it get the proper value of the commission for all the brokers?

      Thanks, your explanation is really good, I instantly understand, thumbs up.

      Comment


        #4
        Hello zoharcho,

        As all brokers are different I couldn't say if that would be reported for all of them. If there is commission provided with the execution you could use that however I don't know if that would equal the account PnL you pictured when added to the overall PnL. You could try printing the values for both the execution commission and the strategy Pnl or account PnL to check if it matches what you had pictured.


        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Thank you Jesse

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by DavidHP, Today, 07:56 AM
          0 responses
          0 views
          0 likes
          Last Post DavidHP
          by DavidHP
           
          Started by Aviram Y, 08-09-2023, 09:04 AM
          10 responses
          298 views
          0 likes
          Last Post MrHump
          by MrHump
           
          Started by jpapa, Today, 07:22 AM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by kevinenergy, 02-17-2023, 12:42 PM
          116 responses
          2,758 views
          1 like
          Last Post kevinenergy  
          Started by franatas, 12-04-2023, 03:43 AM
          7 responses
          106 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X