Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unlocked strategy not showing

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

    Unlocked strategy not showing

    Hi.
    I have just unlocked one of my saved strategies and made some manual changes to it. It is compiling fine, but it doesn't show on the graph as one of the available strategies for use. What could be causing that? Thank you.

    #2
    Hi danfra, thanks for writing in.

    Are there any initialization errors in the Log tab of the Control Center?

    Kind regards,
    -ChrisL

    Comment


      #3
      Indeed there is. It is saying Error on calling 'OnStateChange' method: 'AddDataSeries' cannot be called from this state. However, I simply copied the instructions from the tutorial, as follows:

      protected override void OnStateChange()
      {
      if (State == State.Configure)
      {
      // Add a 5 minute Bars object - BarsInProgress index = 1
      AddDataSeries(BarsPeriodType.Minute, 5);

      Comment


        #4
        Hi danfra, thanks for your reply.

        Configure is the correct state to call this from. Could you copy/paste your entire OnStateChanged method so I can have a look?

        Kind regards,
        -ChrisL

        Comment


          #5
          Sure. The code is for a strategy using the 1-minute candle, but I also want to add a condition that uses the 15-minute candle.

          protected override void OnStateChange()
          {
          if (State == State.SetDefaults)
          {
          Description = @"Enter the description for your new custom Strategy here.";
          Name = "DMICrossUnlocked";
          Calculate = Calculate.OnBarClose;
          EntriesPerDirection = 1;
          EntryHandling = EntryHandling.AllEntries;
          IsExitOnSessionCloseStrategy = true;
          ExitOnSessionCloseSeconds = 30;
          IsFillLimitOnTouch = false;
          MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
          OrderFillResolution = OrderFillResolution.Standard;
          Slippage = 0;
          StartBehavior = StartBehavior.WaitUntilFlat;
          TimeInForce = TimeInForce.Gtc;
          TraceOrders = false;
          RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
          StopTargetHandling = StopTargetHandling.PerEntryExecution;
          BarsRequiredToTrade = 20;
          // Add a 15 minute Bars object - BarsInProgress index = 1
          AddDataSeries(BarsPeriodType.Minute, 15);
          // Disable this property for performance gains in Strategy Analyzer optimizations
          // See the Help Guide for additional information
          IsInstantiatedOnEachOptimizationIteration = true;
          StopLoss = 1;
          TakeProfit = 1;
          }
          else if (State == State.Configure)
          {
          }
          else if (State == State.DataLoaded)
          {
          EMA1 = EMA(Close, 200);
          DM1 = DM(Close, 14);
          SetProfitTarget("", CalculationMode.Price, TakeProfit);
          SetStopLoss("", CalculationMode.Price, StopLoss, false);
          }
          }

          Comment


            #6
            Hi danfra, thanks for your reply.

            The call to AddDataSeries is in State.DataLoaded, move that line of code to the "else if (State == State.Configure)" part of the method.

            Kind regards,
            -ChrisL

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by DannyP96, 05-18-2026, 02:38 PM
            1 response
            85 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 05-11-2026, 05:56 AM
            0 responses
            143 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 05-10-2026, 08:12 PM
            0 responses
            83 views
            0 likes
            Last Post CarlTrading  
            Started by Hwop38, 05-04-2026, 07:02 PM
            0 responses
            256 views
            0 likes
            Last Post Hwop38
            by Hwop38
             
            Started by Mindset, 04-21-2026, 06:46 AM
            0 responses
            334 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Working...
            X