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

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.
    Gaby V.NinjaTrader Customer Service

    Comment


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

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by fx.practic, 10-15-2013, 12:53 AM
      5 responses
      5,404 views
      0 likes
      Last Post Bidder
      by Bidder
       
      Started by Shai Samuel, 07-02-2022, 02:46 PM
      4 responses
      95 views
      0 likes
      Last Post Bidder
      by Bidder
       
      Started by DJ888, Yesterday, 10:57 PM
      0 responses
      8 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by MacDad, 02-25-2024, 11:48 PM
      7 responses
      159 views
      0 likes
      Last Post loganjarosz123  
      Started by Belfortbucks, Yesterday, 09:29 PM
      0 responses
      8 views
      0 likes
      Last Post Belfortbucks  
      Working...
      X