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

Unable to escape whitespace in username

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

    Unable to escape whitespace in username

    Hey, my account name is Foo Bar and I'm trying to define it thusly:

    private readonly string accountName = "Foo Bar";

    There are no errors during compile but the indicator is not in fact recognizing that as a valid account name.

    Using this to designate the sim account works flawlessly:

    private readonly string accountName = "Sim101";

    So the issue is the whitespace. I've tried every combination of escapes and unicode characters I can find and consulted C# documentation extensively, nothing seems to be taking.

    Both examples compile without issues in the NinjaScript editor, but only the Sim101 actually works.

    Note that I've tried this on another production account without a whitespace in the name on a different NinaTrader deployment and it works, so its really quite clear at this point that the only issue is the whitespace.

    Thoughts?

    #2
    Hi lolstockaments, thanks for posting. The Display name might not be the same as the actual name. Print out the string for the Account name and you will use this to initialize the account:

    Code:
    if (State == State.SetDefaults)
    {
        //...
        lock (Account.All)
            foreach(Account a in Account.All)
            {
                Print(a.Name);
            }
    }
    Open a New>NinjaScript Output window then open up the Strategies menu from a chart and look at the listed accounts. Copy/paste the account name into the private readonly string accountName = ""; variable.

    Kind regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Worked like an absolute charm, thanks so much Chris, cheers.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by ursavent, Today, 12:54 PM
      0 responses
      2 views
      0 likes
      Last Post ursavent  
      Started by Mizzouman1, Today, 07:35 AM
      3 responses
      17 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by RubenCazorla, Today, 09:07 AM
      2 responses
      13 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by i019945nj, 12-14-2023, 06:41 AM
      7 responses
      82 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by timmbbo, 07-05-2023, 10:21 PM
      4 responses
      158 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Working...
      X