• 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

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 pstrusi, Today, 09:06 AM
            0 responses
            8 views
            0 likes
            Last Post pstrusi
            by pstrusi
             
            Started by vpzdcv, Today, 02:31 AM
            0 responses
            11 views
            0 likes
            Last Post vpzdcv
            by vpzdcv
             
            Started by YevhenShynkarenko, Today, 01:22 AM
            1 response
            20 views
            0 likes
            Last Post YevhenShynkarenko  
            Started by ttodua, Today, 12:52 AM
            0 responses
            8 views
            0 likes
            Last Post ttodua
            by ttodua
             
            Started by ttodua, Today, 12:50 AM
            0 responses
            8 views
            0 likes
            Last Post ttodua
            by ttodua
             
            Working...
            X