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 arvidvanstaey, Today, 02:19 PM
          4 responses
          11 views
          0 likes
          Last Post arvidvanstaey  
          Started by samish18, 04-17-2024, 08:57 AM
          16 responses
          61 views
          0 likes
          Last Post samish18  
          Started by jordanq2, Today, 03:10 PM
          2 responses
          9 views
          0 likes
          Last Post jordanq2  
          Started by traderqz, Today, 12:06 AM
          10 responses
          18 views
          0 likes
          Last Post traderqz  
          Started by algospoke, 04-17-2024, 06:40 PM
          5 responses
          48 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X