Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

unlock code optimization

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

    unlock code optimization

    Hi,

    It seems to me that everytime i unlock a strategy and add some code, I can no longer perform optimization. I've tried unlocking code as well as using the multi time frame strategy. I opened the multi time frame code, saved as my multi time frame and then I never see any optimization parameters.

    How can I optimize on any strategy after unlocking the code?

    Thanks,
    John

    #2
    John, would you mind attaching a sample script that you tried to optimize so we could review the properties you use? The sample MultiTimeFrame would indeed not have anything to optimize per se, so that outcome I would expect.

    Comment


      #3
      Hi Bertrand, below is my code. From using the UI, I can optimize base on my defined variables, but it seems as after I unlock the code, if I add any defined variable, or for the multi time frame code below, even with my defined variables, nothing shows up on the Optimization Wizard.


      public class Min1Min5Rsi2 : Strategy
      {
      #region Variables
      // Wizard generated variables
      private int rSI30 = 30; // Default setting for RSI30
      private int rSI70 = 70; // Default setting for RSI70
      private int eMA10 = 10; // Default setting for EMA10
      // User defined variables (add any user defined variables below)

      /// </summary>
      protected override void Initialize()
      {
      // Add a 5 minute Bars object to the strategy
      Add(PeriodType.Minute, 1);
      Add(PeriodType.Minute, 5);
      Add(RSI(2, 3));
      Add(EMA(10));

      CalculateOnBarClose = true;
      }

      protected override void OnBarUpdate()
      {

      if (BarsInProgress != 0)
      return;

      if (RSI(BarsArray[1], 2, 3)[0] < rSI30 && RSI(BarsArray[2], 2, 3)[0] > rSI70)

      {

      EnterLong(DefaultQuantity, "Long1");
      }

      Comment


        #4
        Hi john_robertson00,

        Variables must be made public for it to be optimized.

        Please take a look at the SMA indicator with the Period variable.

        In the Properties region at the bottom, please expand this and look at the public declaration for Period.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi Chelsea,

          Great stuff. I did not know I needed to make them public. After setting them, all shows up correctly in the optimization.
          Thanks,
          JR

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          85 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          47 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          29 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          32 views
          0 likes
          Last Post TheRealMorford  
          Started by Mindset, 02-28-2026, 06:16 AM
          0 responses
          67 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X