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

Account RealizedPnL

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

    Account RealizedPnL

    Hello,

    I am trying to get the Account Realized Profit Loss to string but it disappears every time NinjaScript reloads on Chart.

    The RealizedPnL appears only after placing a trade when using code:

    private void OnAccountItemUpdate(object sender, AccountItemEventArgs e)
    if (e.AccountItem == AccountItem.RealizedProfitLoss)
    LastRPnL = e.Value;

    How do I get the Realized Profit Loss for the day, or SinceNewSession, regardless of placing a trade or chart refresh?

    #2
    Hello KINGKODA,

    Thank you for the post.

    While using the OnAccountItemUpdate event, you would need to wait for an account update for your script to see that change. This means if your script sees an update, and then you reload the script it would clear that data and wait for another update.

    To check values at any given time, you would need to access the account directly instead of waiting for those events. You could use the addon Account.Get method with an AccountItem to retrieve variable values from a specific account:




    The values you get from this method would be the general account values.


    Please let me know if I may be of additional assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you Jesse,

      Could you show me a sample of how to use the addon Account.Get method with an AccountItem?

      I'm not sure where it's placed, still under OnAccountItemUpdate, or OnStateChange?
      Last edited by KINGKODA; 06-08-2018, 12:25 PM.

      Comment


        #4
        Hello KINGKODA,

        Thank you for the reply.

        Because this is a method of the account object, you can use it wherever you have an instance to the account. If you wanted to use this in OnBarUpdate for example:

        Code:
        Print(myAccount.Get(AccountItem.RealizedProfitLoss, Currency.UsDollar));
        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        18 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        1 view
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        6 views
        0 likes
        Last Post Javierw.ok  
        Started by timmbbo, Today, 08:59 AM
        2 responses
        10 views
        0 likes
        Last Post bltdavid  
        Started by alifarahani, Today, 09:40 AM
        6 responses
        41 views
        0 likes
        Last Post alifarahani  
        Working...
        X