Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dropdown Menu

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

    Dropdown Menu

    I have created a strategy that has 3 separate methods of calculations to obtain a long entry. See below code example. I want the user to be able to select from a drop down menu when adding the strategy to select either 1, 2 or 3. What do i add to my code so that there is a drop down menu?

    protected override void OnBarUpdate()
    {​
    if(CalcMethod ==1)
    {
    Calculations.....
    }
    if(CalcMethod ==2)
    {
    Calculations.....
    }​ if(CalcMethod ==3)
    {
    Calculations.....
    }​
    }

    Right now I have it set up so that user can enter 1, 2 or 3 when adding the strategy to the chart (using Ninjascript properties - see below) but if they mistakenly put a value greater than 3 then the strategy doesn't execute.

    [NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Select Calc Method", GroupName = "NinjaScriptStrategyParameters", Order = 0)]
    public int CalcMethod
    { get; set; }​

    #2
    Hello algospoke,

    Thank you for your post.

    You can use an enum to create a drop-down menu with a list of options for the user to choose from in the Strategy Parameters.

    Please see this sample script which demonstrates (this is an indicator example, however you can implement this in your strategy as well):



    If you have any further questions, please let us know.

    Comment


      #3
      Awesome Gaby! That worked. Thanks for the quick response

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      87 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      132 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      65 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      118 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      67 views
      0 likes
      Last Post PaulMohn  
      Working...
      X