Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MB Trading Account Cash Value

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

    MB Trading Account Cash Value

    Hi there,

    Despite reading a number of posts about retrieving the account value for my current MB Trading live account, I struggle to do so.

    From within a strategy which is enabled and run on the relevant account I execute:
    Code:
    GetAccountValue(AccountItem.CashValue)
    ...and all I get back is 0.

    It seems to work fine for the sim account though. I also read somewhere that the value is only accessible once you are in a trade - if so, is there a suggestion on how to retrieve the account value for position sizing purposes (i.e. prior to entering a trade).

    I also just noticed that the account tab in NT is showing NULL for all MB trading accounts as well (which wasn't the case yesterday).

    The strategy is running on the AUD/USD chart, so the template is Forex which is basically 24/6, so that shouldn't be it either...

    Any help would be appreciated.

    Regards
    Frank

    #2
    Hi Frank, but you would be sure to access the value in your script on realtime bars, correct?

    Would it change after you've placed a limit order off the market manually on the live account and then cancelled it immediately?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand,

      Thanks for your reply. Have embedded the following code in my strategy:

      Code:
      protected override void OnBarUpdate()
              {			
      			#region Auto Trade Management
      			
      			// Live processing only.
      			if(Historical)
      				return;
      			
      			// Let's make sure we have sufficient bars. 
      			if (CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired)
      		        return;
      			
      			// Let's check and update the order state every minute.
      			if (BarsInProgress != 1) // Ignore all but the 1min chart.
      				return;
      
      			// Let's retrieve the current account value.
      			if(!acctValIsSet)
      			{
      				P("Retrieving account values.");
      				foreach(Account a in NinjaTrader.Cbi.Globals.Accounts)
      				{
      					P(a.Name+","+a.GetAccountValue(AccountItem.CashValue,Currency.Euro));				
      				}
      				acctVal = this.GetAccountValue(AccountItem.CashValue);
      				P("Set the account value to "+acctVal.ToString());
      				acctValIsSet = true;
      			}
      }
      The strategy is running on my live account. After manually placing a limit order on the same underlying within the chart trader and then running the strategy I get the following output:

      11/15/2013 10:46 AM - 5853: Retrieving account values.
      11/15/2013 10:46 AM - 5853: L23xxxx,0.00€
      11/15/2013 10:46 AM - 5853: 857xxxx,0.00€
      11/15/2013 10:46 AM - 5853: 500xxxx,0.00€
      11/15/2013 10:46 AM - 5853: Sim101,0.00€
      11/15/2013 10:46 AM - 5853: Set the account value to 0

      If I look at the accounts tab all accounts are have MBT as the 'connection' and I see in the cash value column:
      L23xxxx - blank (NT7 forex Live acct)
      857xxxx - blank (NT7 forex Demo acct)
      500xxxx - 9834.13 (MT4 forex demo account)
      Sim101 - 99481.85

      So I guess NT is picking up 1 of 3 accounts from MBT and the code is not even picking up the Sim101 account anymore.

      Hmmmmmm.
      Frank

      Comment


        #4
        Frank, please try working with the exact GetAccountValue call as shown here in our documentation - http://www.ninjatrader.com/support/h...etAccountValue

        The variation you have attempted to use including the currency part would not be something we could support or would have tested exhaustively to comment.

        Would your outcome then change?

        Thanks
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Hi Bertrand,

          Have tried already. Actually, you have two different Methods of GetAccointValue which is odd.
          A) One version when you call it straight from the Strategy as in this.GetAccountValue. It takes exactly one argument (CashValue etc)
          B) the one you call via cbi.accounts.... takes two arguments only. There is no override for only one argument.

          Maybe one is intended to be used from an indicator an one from the strategy? My code above uses both independently and neither works.

          Other ideas? Could you run my code on your end and check it works? What else could cause this? Account connections, it being forex accounts, templates?

          Regards,
          Frank

          Comment


            #6
            Frank, I've just run a test and those documented values work correctly from a strategy script for me -

            if (!Historical)
            {
            Print(GetAccountValue(AccountItem.CashValue));
            Print(GetAccountValue(AccountItem.BuyingPower));
            Print(GetAccountValue(AccountItem.RealizedProfitLo ss));
            }
            BertrandNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by habeebft, Today, 07:27 AM
            1 response
            14 views
            0 likes
            Last Post NinjaTrader_ChristopherS  
            Started by AveryFlynn, Today, 04:57 AM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_Erick  
            Started by Max238, Today, 01:28 AM
            4 responses
            38 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by r68cervera, Today, 05:29 AM
            1 response
            10 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by geddyisodin, Today, 05:20 AM
            1 response
            14 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X