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