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 NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      54 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      131 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      73 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      44 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      49 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X