Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dynamic Enum List of Avaible Accounts

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

    Dynamic Enum List of Avaible Accounts

    Hello,

    I'm looking to get the Account size of a specific account chosen by the user. Is it possible to create an enum that gets populated when the indicator is added to the chart which the user can select from? I'm leaning towards yes, however, this may take a bit too much work. Would a user-submitted text field with the account name be a simpler and more streamlined approach to this problem?

    Thanks
    Unsuitable
    NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

    #2
    Hello Unsuitable,

    Thanks for your post.

    While this is undocumented and not officially supported, you could consider using the following TypeConverter on a string. I have attached an example which uses it.

    Code:
    [TypeConverter(typeof(NinjaTrader.NinjaScript.AccountNameConverter))]
    public string AccountName { get; set; }
    We look forward to assisting.
    Attached Files
    JimNinjaTrader Customer Service

    Comment


      #3
      Hello Jim,

      Aha that works perfectly! Quite a bit more simple than I thought it would be. This is out of the scope of the question, but will this cause compiling issues as it's using the NinjaTrader namespace?

      Thanks
      Last edited by Unsuitable; 02-23-2021, 12:14 PM.
      Unsuitable
      NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

      Comment


        #4
        Hello Unsuitable,

        I have not had issue including the example script in a DLL or compiling in Visual Studio.
        JimNinjaTrader Customer Service

        Comment


          #5
          Ok great, thanks for the help!
          Unsuitable
          NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

          Comment


            #6
            Hello Jim,

            This is more of a C# question. For the AccountName enum, could a custom value be added? For example, I would like to add "Use Custom Size" as the default value. At the moment a bool can be set to true to use a custom account size (there's a custom account size double input).

            Tried this to no avail. This is adding it at run time which I don't think is possible, but I don't necessarily want to add it at run time. Just add it as the first default value and remove the need for a bool variable.
            Code:
            AccountName.Insert(0, "Use Custom Account Size");
            Thanks
            Unsuitable
            NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

            Comment


              #7
              Hello Unsuitable,

              I couldn't suggest adding an element for the selector to have it use different functionality, but I may suggest using a bool for "Use Custom Size" that disables the the Account property when checked.

              An example that shows various ways to modify property grid behavior can be found below.

              https://ninjatrader.com/support/help...r_to_custo.htm
              JimNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by MatthewLesko, 02-01-2021, 07:50 AM
              5 responses
              115 views
              0 likes
              Last Post marcus2300  
              Started by kabott, Today, 03:17 AM
              0 responses
              1 view
              0 likes
              Last Post kabott
              by kabott
               
              Started by azuul, Today, 01:49 AM
              1 response
              12 views
              0 likes
              Last Post azuul
              by azuul
               
              Started by rtwave, Yesterday, 11:52 PM
              0 responses
              3 views
              0 likes
              Last Post rtwave
              by rtwave
               
              Started by tgn55, Yesterday, 09:51 PM
              0 responses
              4 views
              0 likes
              Last Post tgn55
              by tgn55
               
              Working...
              X