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

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
    Chris L.NinjaTrader Customer Service

    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:
            Chris L.NinjaTrader Customer Service

            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

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by bortz, 11-06-2023, 08:04 AM
                47 responses
                1,606 views
                0 likes
                Last Post aligator  
                Started by jaybedreamin, Today, 05:56 PM
                0 responses
                9 views
                0 likes
                Last Post jaybedreamin  
                Started by DJ888, 04-16-2024, 06:09 PM
                6 responses
                19 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by Jon17, Today, 04:33 PM
                0 responses
                6 views
                0 likes
                Last Post Jon17
                by Jon17
                 
                Started by Javierw.ok, Today, 04:12 PM
                0 responses
                15 views
                0 likes
                Last Post Javierw.ok  
                Working...
                X