• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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:

    https://ninjatrader.com/support/help.../en-us/get.htm
    https://ninjatrader.com/support/help...ub=AccountItem

    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 hemlaguza, Today, 12:19 AM
        0 responses
        2 views
        0 likes
        Last Post hemlaguza  
        Started by sdauteuil, Yesterday, 11:02 PM
        1 response
        3 views
        0 likes
        Last Post sdauteuil  
        Started by Jschmelz, Yesterday, 04:45 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Marco  
        Started by sisenberg, Yesterday, 08:06 PM
        1 response
        11 views
        0 likes
        Last Post sisenberg  
        Started by priceisking, Yesterday, 07:44 PM
        0 responses
        8 views
        0 likes
        Last Post priceisking  
        Working...
        X