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 CaptainJack, 05-29-2026, 05:09 AM
        0 responses
        163 views
        0 likes
        Last Post CaptainJack  
        Started by CaptainJack, 05-29-2026, 12:02 AM
        0 responses
        82 views
        0 likes
        Last Post CaptainJack  
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        125 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        206 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        184 views
        0 likes
        Last Post CarlTrading  
        Working...
        X