Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Optimize using list items in enum?

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

    Optimize using list items in enum?

    Recently, I added drop-down list feature using enum to select sides to trade: Long/Short/Both.

    However, when I go into Strategy Analyzer -> Backtest type: Optimization, I only see my defined values in the dropdown, that is Long, Short, Both.

    How can it be done to both 1) keep in drop-down list format and 2) have ability to run optimization test.

    #2
    Hello UnltraNix,

    Thanks for your post.

    Please post your enum code section and the properties section that shows the enum public property.

    Comment


      #3
      This one?
      public enum SideListF
      {
      Long,
      Short,
      Both,
      }
      And this one?
      [Display(GroupName = "Entry Parameters", Name="Sides To Trade", Description="Enter: Long Only/Short Only/Both")]
      public SideListF SideListV1
      {
      get { return SideListV; }
      set { SideListV = value; }
      }
      both public.

      only private is this, (after public class AI_ADX_Strategy : Strategy)
      private SideListF SideListV = SideListF.Both;
      and Switch part (nested in OnBarUpdate()
      switch (SideListV)
      {
      case SideListF.Long:
      {
      long1 = true;
      short1 = false;
      break;
      }

      case SideListF.Short:
      {
      long1 = false;
      short1 = true;
      break;
      }

      case SideListF.Both:
      {
      long1 = true;
      short1 = true;
      break;
      }

      }
      :

      Comment


        #4
        Hello UltraNIX,

        Thanks for your post.

        For a parameter to be optimized it must have the [NinjaScriptProperty] attribute applied to the property:

        [NinjaScriptProperty]
        [Display(GroupName = "Entry Parameters", Name="Sides To Trade", Description="Enter: Long Only/Short Only/Both")]
        public SideListF SideListV1
        {
        get { return SideListV; }
        set { SideListV = value; }
        }


        Reference: https://ninjatrader.com/support/help...yattribute.htm

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        80 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        40 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        64 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        64 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        54 views
        0 likes
        Last Post CarlTrading  
        Working...
        X