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

Understand of GetAccountValue and MasterInstrument

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

    Understand of GetAccountValue and MasterInstrument

    Hi guys,

    I'm going to trade some of my automated strategies in realtime, buy I have to understrand some values of GetAccountValue first. So please let me understand what is the proper way to use it to be able to apply money management to my strategies to get things work.

    I will use this simple example for better understand. Let's have account with size of $10 000 and let's go trade two futures instruments say FOO and BAR with same initial margins $1 000. Also let's have 2 strategies trading this instruments with actual state:
    • First strategy is in trade with 2 contracts over FOO with actual realized profit of +$500.
    • Second strategy is in trade with 1 contract over BAR with actual realized loss of -$200.


    And the questions:
    • How can I get the value of initial margin for any instrument?
      GetAccountValue(AccountItem.InitialMargin) or MasterInstrument.Margin ??
    • How can I get available account value?
      In this case 10000 - 2*1000 - 1000 = $7 000
      Is it GetAccountValue(AccountItem.CashValue) or GetAccountValue(AccountItem.TotalCashBalance)
    • What exactly do I get from AccountItem.RealizedProfitLoss?
      Is it same global value for all strategies (in this case +$300), or value related to any single strategy so +$500 if I call from FOO strategy and -$200 if I call from BAR strategy ??
    • How can I get realized account value?
      In this case 10000 + 500 - 200 = $10 300
      Is it TotalCashBalance + RealizedProfitLoss ??
    • StopLoss for BAR strategy is 1%, what is the best way to restate this CalculationMode.Percentage value to CalculationMode.Price value??
      Is it 0.01 * Close[0] * MasterInstrument.PointValue ??
      Ex.: 0.01 * 2587 * 20 = $517.4

    Hope you understand my questions.

    Thanks

    #2
    dalisdj,

    Unfortunately the MasterInstrument.Margin is unsupported code, however note that this MasterInstrument object is what is defined by your instrument manager.

    GetAccountValue(AccountItem.CashValue) would work to get the account value.

    Strategies are separate in all PnL calculation, so the RealizedProfitLoss is only from the strategy you are calling it from. You can read more about this here : http://www.ninjatrader.com/support/h..._account_p.htm

    GetAccountValue(AccountItem.CashValue) would return the realized account value here, but please note it only works on realtime data.

    Using CalculationMode.Price it would be the actual price of the stop loss you wanted, so something like : Close[0]*(1 - 0.01) should work.

    Please let me know if I may assist further.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Hi AdamP,

      thanks for your support. It helped me in most issues, but I'm still not sure about available account money.

      Let's say I have $10 000 account and active trades at total margin of $3 000. This means that I have available only maximum price of $7 000 to enter another trade, because size of $3 000 is blocked by my broker. So do I have to manage my strategies by my own to get available part of my account (in this case $7 000) if any position active?

      Comment


        #4
        Hello dalisdj,

        That will depend on what your brokerage account supports. Some brokerage technology does not provide the buying power or the cash value.

        http://www.ninjatrader.com/support/f...ead.php?t=5474

        So if you call GetAccountValue() on a supported information you will not need to manually calculate it. Otherwise, you would have to calculate this or manage this separately.

        Let us know if we can be of further assistance.
        JCNinjaTrader Customer Service

        Comment


          #5
          Hi AdamP,

          you still didn't answer to my question, but otherwise you let me know about really important issue of account value support. I didn't know about different support of each values and I see that my broker ZenFire support only two values, which should cause a problem in future. So thanks a lot you point me this.

          I would like to generalize my questlion: What is the difference between CashValue and TotalCashBalance?

          Comment


            #6
            Hi dalisdj.

            TotalCashBalance is not supported.

            Possible supported values of this are:
            AccountItem.BuyingPower
            AccountItem.CashValue
            AccountItem.RealizedProfitLoss

            More info here for GetAccountValue()
            Ryan M.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Mathias79, Today, 03:44 PM
            0 responses
            1 view
            0 likes
            Last Post Mathias79  
            Started by Austiner87, Today, 03:42 PM
            0 responses
            2 views
            0 likes
            Last Post Austiner87  
            Started by lorem, 04-25-2024, 09:18 AM
            19 responses
            81 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by joselube001, 05-10-2024, 12:17 PM
            6 responses
            29 views
            0 likes
            Last Post joselube001  
            Started by bigc0220, 09-18-2018, 09:16 AM
            6 responses
            2,584 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X