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

AccountItem.UnrealizedProfitLoss doesn't work

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

    AccountItem.UnrealizedProfitLoss doesn't work


    Hello,
    I have a strategy that shows me the account balance, the name and the balance of open positions. When I connect this strategy in “Sim101” everything works correctly but when I connect it to my real account, it does not show me the balance of open operations (I'm using AccountItem.UnrealizedProfitLoss). It shows onlye the name and account balance. How can I solve this issue?
    Thanks in advance.

    #2
    Hello soyjesus,

    Thanks for your post.

    AccountItems will be reflective for what we see in the Accounts tab of the Control Center. The availability of these fields will depend on the brokerage technology for the account. As the Sim101 account is managed locally on your PC, all fields are available. For a grid that breaks down what AccountItems are available with the account you are using, please see the Accounts tab documentation in the help guide. I've provided a link below.



    If you would like to calculate unrealized PnL on your own, you could check Account.Positions for open positions, and then use Position.GetUnrealizedProfitLoss with the current price of that instrument to get the unrealized PnL for that position. Adding these together will reflect the total unrealized PnL on the account.

    Account.Positions - https://ninjatrader.com/support/help...ns_account.htm

    Position.GetUnrealizedProfitLoss() - https://ninjatrader.com/support/help...profitloss.htm

    We look forward to being of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Hello Jim,

      Thanks for your answer. I need to know which is the total balance of my account in real time. And I need to know how many positions there are opened (by strategies, manually and about all the instruments, not only the instrument of my chart). Could you give any idea how to do it, please?

      Comment


        #4
        Helklo soyjesus,

        Thanks for your question.

        Please see my previous reply for checking the Account.Positions collection. This will tell you your open positions on the account. For each open Position in the collection, you can use Position.GetUnrealizedProfitLoss with the current market price for each symbol.

        You could use an indicator that adds a data series for each symbol you plan to trade with so you can supply the current market price to GetUnrealizedProfitLoss.

        You could also consider subscribing to MarketData events for that symbol once you see you have an open position on that symbol. This can be used to get the current price for that symbol.

        Subscribing to MarketData events - https://ninjatrader.com/support/help...marketdata.htm

        You can then total the Unrealized PnL and subtract it from AccountItem.CashValue.

        Please let me know if you have any questions.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by zstheorist, Today, 07:52 PM
        0 responses
        3 views
        0 likes
        Last Post zstheorist  
        Started by pmachiraju, 11-01-2023, 04:46 AM
        8 responses
        149 views
        0 likes
        Last Post rehmans
        by rehmans
         
        Started by mattbsea, Today, 05:44 PM
        0 responses
        5 views
        0 likes
        Last Post mattbsea  
        Started by RideMe, 04-07-2024, 04:54 PM
        6 responses
        33 views
        0 likes
        Last Post RideMe
        by RideMe
         
        Started by tkaboris, Today, 05:13 PM
        0 responses
        5 views
        0 likes
        Last Post tkaboris  
        Working...
        X