Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to access Account Balance via Ninja Script

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

    How to access Account Balance via Ninja Script

    Hi,

    Unable to access my account balance / values within script, trying to replicate something like this:

    I tried to get the AccountItem Values for my live account with Rithmic without success. The CashValue does not seem to be up to date and the different kinds of


    Simple test code snippet:

    Account a = Account.All.First(t => t.Name == "Sim101");
    AcctBalance = a.Get(AccountItem.NetLiquidation, Currency.UsDollar);
    Print("NetLiquidation = " + AcctBalance);



    The problem appears to be my account name "t.Name" string:

    The exact line of code I am using (name & number obscured):

    Account a = Account.All.First(t => t.Name == "Joe Blow Trader!Mirus!123456");

    The display name (Joe Blow Trader!Mirus!123456) in account details does includes spaces & I have tried removing space).

    The response I'm receiving in the output window:

    Strategy 'STRATEGY301': Error on calling 'OnBarUpdate' method on bar 11: Sequence contains no matching element

    Works fine when using Account a = Account.All.First(t => t.Name == "Sim101");

    The output / response I receive : NetLiquidation = 100179.93

    So it appears my Display Name does not match the account name?

    How / where do I find my correct account t.Name?

    And is there a method to enumerate through all NT connected accounts myself to discover syntax for all brokerage connections?

    i.e. Get Account.All.XXXXX? (instead of using First / FirstOrDefault)

    ​Thanks!

    #2
    Hello, thanks for writing in. You can find the exact account name to use by printing out each Name property e.g.

    Code:
    foreach(var a in Account.All)
        Print(a.Name);  //notice each name that gets printed, use this in Account a = Account.All.First(t => t.Name == "AccountName");
    Kind regards,
    -ChrisL​

    Comment


      #3
      Thanks! That did the trick,

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      163 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      84 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      126 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      207 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      185 views
      0 likes
      Last Post CarlTrading  
      Working...
      X