Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

indicators will not work inside strategy.

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

    indicators will not work inside strategy.



    greetings to all,



    nt support is unavailable over the weekend so i am rushing to post these situations before the cut off time.



    i have a number of automated strategies and i have decided to lease 2 of them through nt's ecosystem website. i have been working towards this objective for weeks now.










    first of all, i need to modify my indicators and strategies in order to protect my intellectual property.


    and concealing the plots and values for my indicators outside of the use that my strategies make of them has been a gigantic source of frustration for me.



    working with information i received in the threads i shared above, i created the simplest possible sample indicator in order to modify it until i felt that it would not plot but still would be usable inside a strategy.



    so i have these two indicators, one will plot, the other will not. and i thought i was making progress as both will compile and the strategy builder will make them both available:



    Code:
    
    #region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.DrawingTools;
    #endregion
    
    //This namespace holds Indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators
    {
        public class zzz00slss10 : Indicator
        {
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description                                    = @"zzz00slss10.";
                    Name                                        = "zzz00slss10";
                    Calculate                                    = Calculate.OnBarClose;
                    IsOverlay                                    = false;
                    DisplayInDataBox                            = false;
                    DrawOnPricePanel                            = true;
                    DrawHorizontalGridLines                        = false;
                    DrawVerticalGridLines                        = false;
                    PaintPriceMarkers                            = false;
                    ShowTransparentPlotsInDataBox                 = true;
                    ArePlotsConfigurable                         = true;                
                    IsVisible                                     = true;                
                    ScaleJustification                            = NinjaTrader.Gui.Chart.ScaleJustification.Right;                
                    IsSuspendedWhileInactive                    = false;
                    AddPlot(new Stroke(Brushes.Black, 4), PlotStyle.Dot, "zzz00slss10p.");
                }
                else if (State == State.Configure)
                {
                }
            }
    
            protected override void OnBarUpdate()
            {
                 Value[0] = Low[0];
            }
    
            #region Properties
    
            [Browsable(false)]
            [XmlIgnore]
            public Series<double> Sls00indicator0001p
            {
                get { return Values[0]; }
            }
            #endregion
    
        }
    }
    
    #region NinjaScript generated code. Neither change nor remove.
    
    namespace NinjaTrader.NinjaScript.Indicators
    {
        public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
        {
            private zzz00slss10[] cachezzz00slss10;
            public zzz00slss10 zzz00slss10()
            {
                return zzz00slss10(Input);
            }
    
            public zzz00slss10 zzz00slss10(ISeries<double> input)
            {
                if (cachezzz00slss10 != null)
                    for (int idx = 0; idx < cachezzz00slss10.Length; idx++)
                        if (cachezzz00slss10[idx] != null &&  cachezzz00slss10[idx].EqualsInput(input))
                            return cachezzz00slss10[idx];
                return CacheIndicator<zzz00slss10>(new zzz00slss10(), input, ref cachezzz00slss10);
            }
        }
    }
    
    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
        public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
        {
            public Indicators.zzz00slss10 zzz00slss10()
            {
                return indicator.zzz00slss10(Input);
            }
    
            public Indicators.zzz00slss10 zzz00slss10(ISeries<double> input )
            {
                return indicator.zzz00slss10(input);
            }
        }
    }
    
    namespace NinjaTrader.NinjaScript.Strategies
    {
        public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
        {
            public Indicators.zzz00slss10 zzz00slss10()
            {
                return indicator.zzz00slss10(Input);
            }
    
            public Indicators.zzz00slss10 zzz00slss10(ISeries<double> input )
            {
                return indicator.zzz00slss10(input);
            }
        }
    }
    
    #endregion
    
    
    
    
    ​

    #2




    this is the second version of the indicator. this one seems to not be visible as is the purpose of this endeavor.




    Code:
    
    
    
    
    #region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.DrawingTools;
    #endregion
    
    //This namespace holds Indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators
    {
        public class zzz00slss11 : Indicator
        {
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description                                    = @"zzz00slss11.";
                    Name                                        = "zzz00slss11";
                    Calculate                                    = Calculate.OnBarClose;
                    IsOverlay                                    = false;
                    DisplayInDataBox                            = false;
                    DrawOnPricePanel                            = true;
                    DrawHorizontalGridLines                        = false;
                    DrawVerticalGridLines                        = false;
                    PaintPriceMarkers                            = false;
                    ShowTransparentPlotsInDataBox                 = false;
                    ArePlotsConfigurable                         = false;                
                    IsVisible                                     = false;                
                    ScaleJustification                            = NinjaTrader.Gui.Chart.ScaleJustification.Right;                
                    IsSuspendedWhileInactive                    = false;
                    AddPlot(new Stroke(Brushes.Transparent, 4), PlotStyle.Dot, "zzz00slss11p.");
                }
                else if (State == State.Configure)
                {
                }
            }
    
            protected override void OnBarUpdate()
            {    
                 Value[0] = Low[0];
            }
    
            #region Properties
    
            [Browsable(false)]
            [XmlIgnore]
            public Series<double> Sls00indicator0001p
            {
                get { return Values[0]; }
            }
            #endregion
    
        }
    }
    
    #region NinjaScript generated code. Neither change nor remove.
    
    namespace NinjaTrader.NinjaScript.Indicators
    {
        public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
        {
            private zzz00slss11[] cachezzz00slss11;
            public zzz00slss11 zzz00slss11()
            {
                return zzz00slss11(Input);
            }
    
            public zzz00slss11 zzz00slss11(ISeries<double> input)
            {
                if (cachezzz00slss11 != null)
                    for (int idx = 0; idx < cachezzz00slss11.Length; idx++)
                        if (cachezzz00slss11[idx] != null &&  cachezzz00slss11[idx].EqualsInput(input))
                            return cachezzz00slss11[idx];
                return CacheIndicator<zzz00slss11>(new zzz00slss11(), input, ref cachezzz00slss11);
            }
        }
    }
    
    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
        public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
        {
            public Indicators.zzz00slss11 zzz00slss11()
            {
                return indicator.zzz00slss11(Input);
            }
    
            public Indicators.zzz00slss11 zzz00slss11(ISeries<double> input )
            {
                return indicator.zzz00slss11(input);
            }
        }
    }
    
    namespace NinjaTrader.NinjaScript.Strategies
    {
        public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
        {
            public Indicators.zzz00slss11 zzz00slss11()
            {
                return indicator.zzz00slss11(Input);
            }
    
            public Indicators.zzz00slss11 zzz00slss11(ISeries<double> input )
            {
                return indicator.zzz00slss11(input);
            }
        }
    }
    
    #endregion
    
    
    
    
    ​

    Comment


      #3



      i then applied this same treatment to other indicators and created the simplest strategy possible; a price - moving average cross.



      this is the sma that is included with the nt platform, just modified so that it will not plot.




      Code:
      #region Using declarations
      using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.ComponentModel.DataAnnotations;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
      using System.Windows;
      using System.Windows.Input;
      using System.Windows.Media;
      using System.Xml.Serialization;
      using NinjaTrader.Cbi;
      using NinjaTrader.Gui;
      using NinjaTrader.Gui.Chart;
      using NinjaTrader.Gui.SuperDom;
      using NinjaTrader.Data;
      using NinjaTrader.NinjaScript;
      using NinjaTrader.Core.FloatingPoint;
      using NinjaTrader.NinjaScript.DrawingTools;
      #endregion
      
      // This namespace holds indicators in this folder and is required. Do not change it.
      namespace NinjaTrader.NinjaScript.Indicators
      {
          
          public class zzz00slss01 : Indicator
          {
              private double priorSum;
              private double sum;
      
              protected override void OnStateChange()
              {
                  if (State == State.SetDefaults)
                  {
                      Description                                    = @"zzz00slss01.";
                      Name                                        = "zzz00slss01";
                      Calculate                                    = Calculate.OnBarClose;
                      IsOverlay                                    = false;
                      DisplayInDataBox                            = false;
                      DrawOnPricePanel                            = true;
                      DrawHorizontalGridLines                        = false;
                      DrawVerticalGridLines                        = false;
                      PaintPriceMarkers                            = false;
                      ShowTransparentPlotsInDataBox                 = false;
                      ArePlotsConfigurable                         = false;                
                      IsVisible                                     = false;                
                      ScaleJustification                            = NinjaTrader.Gui.Chart.ScaleJustification.Right;                
                      IsSuspendedWhileInactive                    = false;
                      AddPlot(new Stroke(Brushes.Transparent, 4), PlotStyle.Dot, "zzz00slss01p.");
                      
      
                      AddPlot(Brushes.Goldenrod, NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameSMA);
                  }
                  else if (State == State.Configure)
                  {
                      priorSum    = 0;
                      sum            = 0;
                  }
              }
      
              protected override void OnBarUpdate()
              {
                  if (BarsArray[0].BarsType.IsRemoveLastBarSupported)
                  {
                      if (CurrentBar == 0)
                          Value[0] = Input[0];
                      else
                      {
                          double last = Value[1] * Math.Min(CurrentBar, 3);
      
                          if (CurrentBar >= 3)
                              Value[0] = (last + Input[0] - Input[3]) / Math.Min(CurrentBar, 3);
                          else
                              Value[0] = ((last + Input[0]) / (Math.Min(CurrentBar, 3) + 1));
                      }
                  }
                  else
                  {
                      if (IsFirstTickOfBar)
                          priorSum = sum;
      
                      sum = priorSum + Input[0] - (CurrentBar >= 3 ? Input[3] : 0);
                      Value[0] = sum / (CurrentBar < 3 ? CurrentBar + 1 : 3);
                  }
              }
      
              #region Properties
              
              #endregion
          }
      }
      
      #region NinjaScript generated code. Neither change nor remove.
      
      namespace NinjaTrader.NinjaScript.Indicators
      {
          public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
          {
              private zzz00slss01[] cachezzz00slss01;
              public zzz00slss01 zzz00slss01()
              {
                  return zzz00slss01(Input);
              }
      
              public zzz00slss01 zzz00slss01(ISeries<double> input)
              {
                  if (cachezzz00slss01 != null)
                      for (int idx = 0; idx < cachezzz00slss01.Length; idx++)
                          if (cachezzz00slss01[idx] != null &&  cachezzz00slss01[idx].EqualsInput(input))
                              return cachezzz00slss01[idx];
                  return CacheIndicator<zzz00slss01>(new zzz00slss01(), input, ref cachezzz00slss01);
              }
          }
      }
      
      namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
      {
          public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
          {
              public Indicators.zzz00slss01 zzz00slss01()
              {
                  return indicator.zzz00slss01(Input);
              }
      
              public Indicators.zzz00slss01 zzz00slss01(ISeries<double> input )
              {
                  return indicator.zzz00slss01(input);
              }
          }
      }
      
      namespace NinjaTrader.NinjaScript.Strategies
      {
          public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
          {
              public Indicators.zzz00slss01 zzz00slss01()
              {
                  return indicator.zzz00slss01(Input);
              }
      
              public Indicators.zzz00slss01 zzz00slss01(ISeries<double> input )
              {
                  return indicator.zzz00slss01(input);
              }
          }
      }
      
      #endregion

      Comment


        #4



        and this is the strategy.



        everything will compile, there are no error messages on the logs, however, the same strategy using the ordinary sma included with nt will generate trades but a version using this modified sma will end up blank.


        żwhat can nt advise in this case?


        i still have the same objective as weeks ago, create versions of my indicators that can be used in my strategies but will not plot and will not display their values in other forms.




        Code:
        
        
        
        #region Using declarations
        using System;
        using System.Collections.Generic;
        using System.ComponentModel;
        using System.ComponentModel.DataAnnotations;
        using System.Linq;
        using System.Text;
        using System.Threading.Tasks;
        using System.Windows;
        using System.Windows.Input;
        using System.Windows.Media;
        using System.Xml.Serialization;
        using NinjaTrader.Cbi;
        using NinjaTrader.Gui;
        using NinjaTrader.Gui.Chart;
        using NinjaTrader.Gui.SuperDom;
        using NinjaTrader.Gui.Tools;
        using NinjaTrader.Data;
        using NinjaTrader.NinjaScript;
        using NinjaTrader.Core.FloatingPoint;
        using NinjaTrader.NinjaScript.Indicators;
        using NinjaTrader.NinjaScript.DrawingTools;
        #endregion
        
        //This namespace holds Strategies in this folder and is required. Do not change it.
        namespace NinjaTrader.NinjaScript.Strategies
        {
            public class zzz00slssample0 : Strategy
            {
                private zzz00slss01 zzz00slss011;
        
                protected override void OnStateChange()
                {
                    if (State == State.SetDefaults)
                    {
                        Description                                    = @"zzz00slssample0";
                        Name                                        = "zzz00slssample0";
                        Calculate                                    = Calculate.OnBarClose;
                        EntriesPerDirection                            = 1;
                        EntryHandling                                = EntryHandling.AllEntries;
                        IsExitOnSessionCloseStrategy                = false;
                        ExitOnSessionCloseSeconds                    = 30;
                        IsFillLimitOnTouch                            = false;
                        MaximumBarsLookBack                            = MaximumBarsLookBack.TwoHundredFiftySix;
                        OrderFillResolution                            = OrderFillResolution.Standard;
                        Slippage                                    = 1;
                        StartBehavior                                = StartBehavior.WaitUntilFlat;
                        TimeInForce                                    = TimeInForce.Gtc;
                        TraceOrders                                    = false;
                        RealtimeErrorHandling                        = RealtimeErrorHandling.IgnoreAllErrors;
                        StopTargetHandling                            = StopTargetHandling.PerEntryExecution;
                        BarsRequiredToTrade                            = 20;
                        IsInstantiatedOnEachOptimizationIteration    = true;
                    }
                    else if (State == State.Configure)
                    {
                    }
                    else if (State == State.DataLoaded)
                    {                
                        zzz00slss011                = zzz00slss01(Close);                
                    }
                }
        
                protected override void OnBarUpdate()
                {
                    if (BarsInProgress != 0)
                        return;
        
                    if (CurrentBars[0] < 5)
                        return;
                    
                    if ((Position.MarketPosition != MarketPosition.Short)
                        && (Close[0] < zzz00slss011[0]))
                    {
                        EnterShort(1, @"sen");
                    }
                    
                    if ((Position.MarketPosition != MarketPosition.Long)
                        && (Close[0] > zzz00slss011[0]))
                    {
                        EnterLong(1, @"len");
                    }
                    
                }
            }
        }


        Comment


          #5
          Hello rtwave,

          The best way to do this would be to manually code the strategy and in the indicator use a Series<double> instead of AddPlot. That prevents it from displaying anything but the strategy could still use the series data. That will prevent you from using the builder.

          Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.


          The other way would be to use AddPlot with a transparent plot, that would prevent the plot from showing up when the indicator is manually applied but the plot would still be visible in the builder.

          To know why the strategy was not working you would have to add prints and output the values you are seeing. That would let you explore the situation further.

          Comment


            #6




            people with nt,



            i hope i'm understanding this correctly.


            from the information provided in this other thread below i understood that it is not possible to use indicators that do not contain addplot commands in strategies. regardless of one using nt's strategy builder or not.






            if nt says that such indicators can be used, i will now try to create indicators that contain no addplot commands, and only tseries values.




            regarding the sample indicators i have posted, those indicators already contain transparent plots.


            and one of these settings below prevents the sample indicator i shared from being used as a component in strategies. it would be hard to believe if nt cannot tell why that is happening and which of these settings is causing this behavior. the indicator is the exact same sma that is included with the nt platform.


            IsOverlay = false;
            DisplayInDataBox = false;
            DrawOnPricePanel = true;
            DrawHorizontalGridLines = false;
            DrawVerticalGridLines = false;
            PaintPriceMarkers = false;
            ShowTransparentPlotsInDataBox = false;
            ArePlotsConfigurable = false;
            IsVisible = false;
            ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
            IsSuspendedWhileInactive = false;
            AddPlot(new Stroke(Brushes.Transparent, 4), PlotStyle.Dot, "zzz00slss01p.");
            Last edited by rtwave; 03-28-2025, 07:50 PM.

            Comment


              #7
              Hello rtwave,

              You can use indicators that do not have plots in strategies, just not the builder. You would have to manually code the strategy to call on the indicators Series instead of a plot. There is a reference sample that shows that here: https://developer.ninjatrader.com/do..._are_not_plots

              Comment


                #8


                nt support has been completely lacking on everything regarding distribution of proprietary code.




                _ a strategy that one will distribute needs checks so that it will only work for paying clients and for the period that has been paid. nt manuals and help guides are practically nonexistent. i have spent weeks trying to prepare my code for distribution but there are no examples or samples which i could work with anywhere.



                _ i then spent time trying to create versions of my indicators which could be used inside a strategy but would not plot or be usable otherwise. i created a strategy that is identical to nt's sample strategy and nt will accept the strategy and compile but the strategy will not generate a single trade in a backtest. and this is nt's very sample strategy. nt support has multiple times stated that the platform will be able to use inside a strategy indicators that will not plot, and i have provided several samples which prove that this is not the case. and nt support will not bother to check the code i have shared but will still reply that nt will work when i have proven it does not. nt support has also stated that i need to debug the code when it is nt's own sample strategy with minimally modified contents. and the modifications i have made are merely superficial and are exactly the modifications that nt support instructed me to make.


                i have asked for direction, followed the instructions and when i report that these instructions will not work nt support will just reply that the instructions work and that i should repair whatever it is that is not working.

                Comment


                  #9
                  Hello rtwave,

                  There are many samples and a full api guide linked below. The sample I previously linked does work to pass data which is not a plot from an indicator to a strategy. I would suggest first testing the sample to see how that demonstration works and then edit it so we can see what you changed vs the sample. Our support can't debug your code for you so we would need to redirect to you resources in the api guide known to already work for the purpose given or to use Print statements to debug the code while its running.

                  API guide: https://developer.ninjatrader.com/docs/desktop
                  Educational resources including samples: https://developer.ninjatrader.com/do...onal_resources
                  Exposing values from an indicator so a strategy can read it without using a plot: https://developer.ninjatrader.com/do..._are_not_plots

                  If you want a plot so the builder can use it you can use AddPlot with a transparent plot, that is the only way to hide the plot while maintaining the strategy builder use. If you want to completely hide plots or prevent other strategies from using the indicator in code you need to use a Series<double> as a public property so that you can manually code your strategy to use that specific series.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  647 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  368 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  108 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  571 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  573 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X