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 argusthome, 03-08-2026, 10:06 AM
      0 responses
      69 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      42 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      24 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      27 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      54 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X