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 WHICKED, Today, 02:02 PM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by selu72, Today, 02:01 PM
        0 responses
        3 views
        0 likes
        Last Post selu72
        by selu72
         
        Started by f.saeidi, Today, 12:14 PM
        8 responses
        21 views
        0 likes
        Last Post f.saeidi  
        Started by Mikey_, 03-23-2024, 05:59 PM
        3 responses
        49 views
        0 likes
        Last Post Sam2515
        by Sam2515
         
        Started by Russ Moreland, Today, 12:54 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Erick  
        Working...
        X