Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Provide Account Selector in indicator parameter settings

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

    Provide Account Selector in indicator parameter settings

    Hi Ninja experts,

    I'm developing an indicator which will place trades using CreateOrder(). For this I need to choose an account for trade (like sim101). What I need is to add the account selector in the indicator parameter settings so that I can choose an account while applying indicator on a chart. I have tried the following code which compiles successfully but crashes NT8 when I try to load the indicator on the chart instead of the listing available accounts in my Ninja. I feel I'm missing something due to which the end result is not achieved. Here is the code I included for this:

    #region Properties
    [NinjaScriptProperty]
    [XmlIgnore]
    [Display(Name="My Account", Order=1, GroupName="Parameters")]
    public AccountSelector AS
    {
    get {return AS;}
    set{AS = new AccountSelector() ;}
    }
    #endregion

    I request you to advise/help me on this issue. Thanks for your time and consideration.







    #2
    Hi Mubeen, thanks for posting. An account selector property for the UI is written as:

    Code:
    [TypeConverter(typeof(NinjaTrader.NinjaScript.Accou ntNameConverter))]
    public string AccountName { get; set; }
    Then you will use this string to set up the Account object:

    State.Configure:
    Code:
    lock (Account.All)
        myAccount = Account.All.FirstOrDefault(a => a.Name == AccountName);
    Then check to make sure myAccount is not null then you can use and submit orders to the account. There is a full example here:


    Kind regards,
    -ChrisL

    Comment


      #3
      Thank you so much Chris, your advice worked for me. This platform has always been useful for me whenever I am stuck some where. Thanks.

      Comment


        #4
        Hello ChrisL,
        Do you still have a link to the full example in #2? I went to the link above, but it says Page not Found.

        Comment


          #5
          Hello again ChrisL,
          I'm also wondering if there's a way to do this that will give me a drop-down menu to select which ATM strategy I'm currently using. Or if there's a way to have the ATM strategy I've selected in the Chart Trader be called into my indicator.

          Comment


            #6
            Please try this link:

            Comment


              #7
              Is there an equivalent of this for Instruments? I'd like an easy way to add an instrument picker to an instrument's settings.

              Originally posted by NinjaTrader_ChrisL View Post
              Hi Mubeen, thanks for posting. An account selector property for the UI is written as:

              Code:
              [TypeConverter(typeof(NinjaTrader.NinjaScript.Accou ntNameConverter))]
              public string AccountName { get; set; }
              Then you will use this string to set up the Account object:

              State.Configure:
              Code:
              lock (Account.All)
              myAccount = Account.All.FirstOrDefault(a => a.Name == AccountName);
              Then check to make sure myAccount is not null then you can use and submit orders to the account. There is a full example here:


              Kind regards,
              -ChrisL

              Comment


                #8
                Hello kevinenergy,

                The NinjaTrader.Gui.Tools.InstrumentSelector will do the job.
                https://ninjatrader.com/support/foru...90#post1090890

                Where the property is used, be sure to check the value is not null.
                https://ninjatrader.com/support/help...references.htm
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_ChrisL View Post
                  Hi Mubeen, thanks for posting. An account selector property for the UI is written as:

                  Code:
                  [TypeConverter(typeof(NinjaTrader.NinjaScript.Accou ntNameConverter))]
                  public string AccountName { get; set; }
                  Then you will use this string to set up the Account object:

                  State.Configure:
                  Code:
                  lock (Account.All)
                  myAccount = Account.All.FirstOrDefault(a => a.Name == AccountName);
                  Then check to make sure myAccount is not null then you can use and submit orders to the account. There is a full example here:


                  Kind regards,
                  -ChrisL
                  Hello, sorry to re open this topic.
                  The solution you provide works perfectly with sim accounts.
                  For instance, I save the selected account name to the indicator parametter and reload the saved account when we change time frame, ect..
                  I retriewe all sim account when i do it, but, using a real one is doesn't re appear, do you know why please?

                  Comment


                    #10
                    Found, it's because of the "!apex!apex" added on the name, but this part of the name is not registered ...

                    Comment


                      #11
                      Hello TradeForge,

                      There is the Account.DisplayName (as it shows in the Account drop-down) and the Account.Name which is the full name of the account.
                      Chelsea B.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      605 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      351 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      105 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      560 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      561 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X