Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Entry Counter Indicator

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

    Entry Counter Indicator

    Hello,

    I am trying to develop an indicator that colors the bars depending on the parameters that I use for my Entries.

    I would like to know how can I count how many times this parameters have been met during the current day. I have 3 Entries depending in some parameters (Long or Short Entry) and 3 diferent colors for each Entry.


    How can I count how many bars have met this parameters during the current day and draw the counting in the chart?

    Please take in to account that I have 2 more entries. should I make an indicator for each one or one indicator for all would be okey?


    For Example, one of my Entries:

    Code:
    protected override void OnBarUpdate()
            {
            if (BarsInProgress != 0)
                    return;
    
                if (CurrentBars[0] < 1)
                    return;
    
                // Set 1 - Long Entry
                if ((Close[0] > SMA1[0])
                     && (CrossAbove(EMA1, EMA2, 1))
                     && (EMA2[0] > SMA1[0]))
                {
                    BarBrush = Brushes.Yellow;
    
                    TextFixed MyDrawText = Draw.TextFixed(this, "tag1", "SEC ALC = " + Count, TextPosition.TopLeft);
                    MyDrawText.Alignment = TextAlignment.Left;
                }
    
                // Set 2 - Short Entry
                if ((Close[0] < SMA1[0])
                     && (CrossBelow(EMA1, EMA2, 1))
                     && (EMA2[0] < SMA1[0]))
                {
                    BarBrush = Brushes.Yellow;
    
                    TextFixed MyDrawText = Draw.TextFixed(this, "tag2", "                                            SEC BAJ = " + Count, TextPosition.TopLeft);
                    MyDrawText.Alignment = TextAlignment.Left;
                }​
    Click image for larger version

Name:	image.png
Views:	314
Size:	12.4 KB
ID:	1274536

    Thanks!

    #2
    Hello tradingnasdaqprueba,

    The easiest way to do that would be to make an int variable and then increment it each time the condition is true. To reset it daily you can make a condition checking for IsFirstBarOfSession

    https://ninjatrader.com/support/help...htsub=firstbar ofsession

    A simple example is the following:

    Code:
    private int counter;
    protected override void OnBarUpdate()
    {
       if (Bars.IsFirstBarOfSession)
        {
            counter = 0;
        }
       if ((Close[0] > SMA1[0])
       && (CrossAbove(EMA1, EMA2, 1))
       && (EMA2[0] > SMA1[0]))
       {​
    
           counter++;
        }
    }​
    For other entries you could use the same indicator if you wanted, you would just add additional conditions to the indicator. If you wanted to count the conditions individually you can make as many of the int variables as you want to do counts.

    Comment


      #3
      Hello Jesse,

      Thanks for your Support, I would need some help more.

      I made separate indicators for my different entries, I made the First one (lets call it "X") and the second one "Y".

      In the X indicator works everything perfect and counts every entry very well... but for the Y entry I copied and pasted the code from X and change the conditions... its very extrange because when I leave the same code as the X entry it shows the same counting as expected, but when I change the code with the new conditions of the Y entry, the text in the chart disappears...

      Here the code and some images so you can understand everything:

      CODE FOR THE X ENTRY:

      Code:
      [HASHTAG="t3322"]region[/HASHTAG] 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 ContadorSector : Indicator
      {
      private SMA SMA1;
      private EMA EMA1;
      private EMA EMA2;
      private int counter1;
      private int counter2;
      
      protected override void OnStateChange()
      {
      if (State == State.SetDefaults)
      {
      Description = @"Enter the description for your new custom Indicator here.";
      Name = "ContadorSector";
      Calculate = Calculate.OnBarClose;
      IsOverlay = false;
      DisplayInDataBox = true;
      DrawOnPricePanel = true;
      DrawHorizontalGridLines = true;
      DrawVerticalGridLines = true;
      PaintPriceMarkers = true;
      ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
      //Disable this property if your indicator requires custom values that cumulate with each new market data event.
      //See Help Guide for additional information.
      IsSuspendedWhileInactive = true;
      }
      else if (State == State.Configure)
      {
      }
      else if (State == State.DataLoaded)
      {
      SMA1 = SMA(Close, 50);
      EMA1 = EMA(Close, 10);
      EMA2 = EMA(Close, 20);
      }
      }
      
      protected override void OnBarUpdate()
      {
      if (Bars.IsFirstBarOfSession)
      {
      counter1 = 0;
      }
      if ((Close[0] > SMA1[0])
      && (CrossAbove(EMA1, EMA2, 1))
      && (EMA2[0] < SMA1[0]))
      {​
      
      counter1++;
      TextFixed MyDrawText = Draw.TextFixed(this, "tag1", "X ALCISTA = " + counter1, TextPosition.TopLeft);
      MyDrawText.Alignment = TextAlignment.Left;
      }
      
      if (Bars.IsFirstBarOfSession)
      {
      counter2 = 0;
      }
      if ((Close[0] < SMA1[0])
      && (CrossBelow(EMA1, EMA2, 1))
      && (EMA2[0] > SMA1[0]))
      {​
      
      counter2++;
      TextFixed MyDrawText = Draw.TextFixed(this, "tag2", " X BAJISTA = " + counter2, TextPosition.TopLeft);
      MyDrawText.Alignment = TextAlignment.Left;
      }
      }
      }
      }
      
      [HASHTAG="t3322"]region[/HASHTAG] NinjaScript generated code. Neither change nor remove.
      
      namespace NinjaTrader.NinjaScript.Indicators
      {
      public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
      {
      private ContadorSector[] cacheContadorSector;
      public ContadorSector ContadorSector()
      {
      return ContadorSector(Input);
      }
      
      public ContadorSector ContadorSector(ISeries<double> input)
      {
      if (cacheContadorSector != null)
      for (int idx = 0; idx < cacheContadorSector.Length; idx++)
      if (cacheContadorSector[idx] != null && cacheContadorSector[idx].EqualsInput(input))
      return cacheContadorSector[idx];
      return CacheIndicator<ContadorSector>(new ContadorSector(), input, ref cacheContadorSector);
      }
      }
      }
      
      namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
      {
      public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
      {
      public Indicators.ContadorSector ContadorSector()
      {
      return indicator.ContadorSector(Input);
      }
      
      public Indicators.ContadorSector ContadorSector(ISeries<double> input )
      {
      return indicator.ContadorSector(input);
      }
      }
      }
      
      namespace NinjaTrader.NinjaScript.Strategies
      {
      public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
      {
      public Indicators.ContadorSector ContadorSector()
      {
      return indicator.ContadorSector(Input);
      }
      
      public Indicators.ContadorSector ContadorSector(ISeries<double> input )
      {
      return indicator.ContadorSector(input);
      }
      }
      }
      
      #endregion


      CODE FOR THE Y ENTRY:

      Code:
      [HASHTAG="t3322"]region[/HASHTAG] 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 ContadorTarde : Indicator
      {
      private SMA SMA1;
      private EMA EMA1;
      private EMA EMA2;
      private int counter1;
      private int counter2;
      
      protected override void OnStateChange()
      {
      if (State == State.SetDefaults)
      {
      Description = @"Enter the description for your new custom Indicator here.";
      Name = "ContadorTarde";
      Calculate = Calculate.OnBarClose;
      IsOverlay = false;
      DisplayInDataBox = true;
      DrawOnPricePanel = true;
      DrawHorizontalGridLines = true;
      DrawVerticalGridLines = true;
      PaintPriceMarkers = true;
      ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
      //Disable this property if your indicator requires custom values that cumulate with each new market data event.
      //See Help Guide for additional information.
      IsSuspendedWhileInactive = true;
      }
      else if (State == State.Configure)
      {
      }
      else if (State == State.DataLoaded)
      {
      SMA1 = SMA(Close, 50);
      EMA1 = EMA(Close, 10);
      EMA2 = EMA(Close, 20);
      }
      }
      
      protected override void OnBarUpdate()
      {
      if (Bars.IsFirstBarOfSession)
      {
      counter1 = 0;
      }
      if ((Close[0] > SMA1[0])
      && (CrossAbove(EMA1, EMA2, 1))
      && (EMA2[0] < SMA1[0]))
      
      {​
      counter1++;
      TextFixed MyDrawText = Draw.TextFixed(this, "tag1", " Y = " + counter1, TextPosition.TopLeft);
      MyDrawText.Alignment = TextAlignment.Left;
      }
      
      if (Bars.IsFirstBarOfSession)
      {
      counter2 = 0;
      }
      if ((Close[0] < SMA1[0])
      && (CrossBelow(EMA1, EMA2, 1))
      && (EMA2[0] > SMA1[0]))
      
      {​
      counter2++;
      TextFixed MyDrawText = Draw.TextFixed(this, "tag2", " Y = " + counter2, TextPosition.TopLeft);
      MyDrawText.Alignment = TextAlignment.Left;
      }
      
      }
      }
      }
      
      [HASHTAG="t3322"]region[/HASHTAG] NinjaScript generated code. Neither change nor remove.
      
      namespace NinjaTrader.NinjaScript.Indicators
      {
      public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
      {
      private ContadorTarde[] cacheContadorTarde;
      public ContadorTarde ContadorTarde()
      {
      return ContadorTarde(Input);
      }
      
      public ContadorTarde ContadorTarde(ISeries<double> input)
      {
      if (cacheContadorTarde != null)
      for (int idx = 0; idx < cacheContadorTarde.Length; idx++)
      if (cacheContadorTarde[idx] != null && cacheContadorTarde[idx].EqualsInput(input))
      return cacheContadorTarde[idx];
      return CacheIndicator<ContadorTarde>(new ContadorTarde(), input, ref cacheContadorTarde);
      }
      }
      }
      
      namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
      {
      public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
      {
      public Indicators.ContadorTarde ContadorTarde()
      {
      return indicator.ContadorTarde(Input);
      }
      
      public Indicators.ContadorTarde ContadorTarde(ISeries<double> input )
      {
      return indicator.ContadorTarde(input);
      }
      }
      }
      
      namespace NinjaTrader.NinjaScript.Strategies
      {
      public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
      {
      public Indicators.ContadorTarde ContadorTarde()
      {
      return indicator.ContadorTarde(Input);
      }
      
      public Indicators.ContadorTarde ContadorTarde(ISeries<double> input )
      {
      return indicator.ContadorTarde(input);
      }
      }
      }
      
      #endregion



      IMAGE - SAME CONDITIONS FOR X AND Y ENTRIES

      Click image for larger version

Name:	image.png
Views:	335
Size:	62.6 KB
ID:	1274709


      IMAGE - NEW CONDITIONS FOR Y ENTRY - IT DISAPPEARS FROM THE CHART....

      Click image for larger version

Name:	image.png
Views:	283
Size:	87.0 KB
ID:	1274710

      Comment


        #4
        Hello tradingnasdaqprueba,

        This would imply the condition did not evaluate as true.

        One line above the condition, print the time of the bar and all values in the condition with labels for each value and comparison operator to see which condition is not evaluating as true.
        https://ninjatrader.com/support/foru...121#post791121

        Save the output to a text file and include this with your next post and we can assist with analyzing the output.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello Chelsea,

          I did this and I get this Error in the Output panel: Error on calling 'OnBarUpdate' method on bar 0: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

          Click image for larger version

Name:	image.png
Views:	406
Size:	16.5 KB
ID:	1274781


          Code:
          ​​
          [HASHTAG="t3322"]region[/HASHTAG] 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 ContadorTarde : Indicator
          {
          private SMA SMA1;
          private EMA EMA1;
          private EMA EMA2;
          private int counter1;
          private int counter2;
          
          protected override void OnStateChange()
          {
          if (State == State.SetDefaults)
          {
          Description = @"Enter the description for your new custom Indicator here.";
          Name = "ContadorTarde";
          Calculate = Calculate.OnBarClose;
          IsOverlay = false;
          DisplayInDataBox = true;
          DrawOnPricePanel = true;
          DrawHorizontalGridLines = true;
          DrawVerticalGridLines = true;
          PaintPriceMarkers = true;
          ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
          //Disable this property if your indicator requires custom values that cumulate with each new market data event.
          //See Help Guide for additional information.
          IsSuspendedWhileInactive = true;
          }
          else if (State == State.Configure)
          {
          }
          else if (State == State.DataLoaded)
          {
          SMA1 = SMA(Close, 50);
          EMA1 = EMA(Close, 10);
          EMA2 = EMA(Close, 20);
          }
          }
          
          protected override void OnBarUpdate()
          {
          if (Bars.IsFirstBarOfSession)
          {
          counter1 = 0;
          }
          if ((Close[0] > SMA1[0])
          && (CrossAbove(EMA1, EMA2, 1))
          && (EMA2[0] < SMA1[0]))
          
          {​
          counter1++;
          TextFixed MyDrawText = Draw.TextFixed(this, "tag1", " Y = " + counter1, TextPosition.TopLeft);
          MyDrawText.Alignment = TextAlignment.Left;
          }
          
          if (Bars.IsFirstBarOfSession)
          {
          counter2 = 0;
          }
          if ((Close[0] < SMA1[0])
          && (CrossBelow(EMA1, EMA2, 1))
          && (EMA2[0] > SMA1[0]))
          
          {​
          counter2++;
          TextFixed MyDrawText = Draw.TextFixed(this, "tag2", " Y = " + counter2, TextPosition.TopLeft);
          MyDrawText.Alignment = TextAlignment.Left;
          }
          
          }
          }
          }
          
          [HASHTAG="t3322"]region[/HASHTAG] NinjaScript generated code. Neither change nor remove.
          
          namespace NinjaTrader.NinjaScript.Indicators
          {
          public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
          {
          private ContadorTarde[] cacheContadorTarde;
          public ContadorTarde ContadorTarde()
          {
          return ContadorTarde(Input);
          }
          
          public ContadorTarde ContadorTarde(ISeries<double> input)
          {
          if (cacheContadorTarde != null)
          for (int idx = 0; idx < cacheContadorTarde.Length; idx++)
          if (cacheContadorTarde[idx] != null && cacheContadorTarde[idx].EqualsInput(input))
          return cacheContadorTarde[idx];
          return CacheIndicator<ContadorTarde>(new ContadorTarde(), input, ref cacheContadorTarde);
          }
          }
          }
          
          namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
          {
          public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
          {
          public Indicators.ContadorTarde ContadorTarde()
          {
          return indicator.ContadorTarde(Input);
          }
          
          public Indicators.ContadorTarde ContadorTarde(ISeries<double> input )
          {
          return indicator.ContadorTarde(input);
          }
          }
          }
          
          namespace NinjaTrader.NinjaScript.Strategies
          {
          public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
          {
          public Indicators.ContadorTarde ContadorTarde()
          {
          return indicator.ContadorTarde(Input);
          }
          
          public Indicators.ContadorTarde ContadorTarde(ISeries<double> input )
          {
          return indicator.ContadorTarde(input);
          }
          }
          }
          
          #endregion
          ​

          Comment


            #6
            Hello tradingnasdaqprueba,

            I am not sure where you put the print in the code attached or why you would get that error based on the given code. I would suggest to revert the changes you made.

            For the previous problem where applying 2 indicators would have an issue that would be due to using Draw.TextFixed in the same location. Only 1 fixed text object can exist in the corner. One of your codes would need to specify a different corner if you want to use Draw.TextFixed.





            Comment


              #7
              Hello Jesse,

              I change the TextPosition. to have 3 different positions for each indicator but nothing happens...

              I think that the problem could be the
              if (Bars.IsFirstBarOfSession)
              what is causing the problem...

              I saw these posts:

              https://forum.ninjatrader.com/forum/ninjatrader-8/strategy-development/1122114-error-on-calling-onbarupdate-method-on-bar-0

              Hi, I'm having an error saying that i'm accessing a bar that is out of range. I don't get it since I only use current index 0. &quot;Indicator 'VWAR': Error on calling 'OnBarUpdate' method on bar 0: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series with a value of 5 when



              Could be something related to this 2 posts?

              Thanks!

              Comment


                #8
                Hello tradingnasdaqprueba,

                The condition with IsFirstBarOfSession would mean that condition only becomes true on the first bar of the session. If your other conditions were not true at that time then nothing will be drawn. If you mean for the text to be updated frequently you need to remove the IsFirstBarOfSession condition.

                Comment


                  #9
                  Hello Jesse,

                  How would be the code without te IsFirstBarOfSession condition? How can I make it to count from the Beginning of the sesion to the actual time untill the sesion change, wenn the sesion changes, reset to 0.

                  Can I just make one indicator for these 3 indicators? Could you please make an example for this?

                  Thanks!

                  Comment


                    #10
                    Hello tradingnasdaqprueba,

                    The logic to reset the counter variable would need to go inside a condition for IsFirstBarOfSession to reset it at that time. The rest of you logic would go outside that condition so its executed for each OnBarUpdate event.

                    From the last example you provided it looks like you have the counter variable being reset for the first bar of session like you wanted and you are drawing text based on conditions. The text will only be drawn when your conditions are true, if you wanted to draw text always including 0 counter values you would need to move the draw text statements outside of your conditions and only increment the counter inside the conditions.

                    Comment


                      #11
                      Hi Jesse,

                      Do you mean this? (See Code) Sorry if something is wrong, I am learning programming by myself and sometimes its a bit tricky...


                      If you could help me a bit with the programming or being more specific in what should I do, I would appreciate it!


                      Code:
                      [HASHTAG="t3322"]region[/HASHTAG] 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 ContadorSector : Indicator
                      {
                      
                      private int counter1;
                      private int counter2;
                      
                      protected override void OnStateChange()
                      {
                      if (State == State.SetDefaults)
                      {
                      Description = @"Enter the description for your new custom Indicator here.";
                      Name = "ContadorSector";
                      Calculate = Calculate.OnBarClose;
                      IsOverlay = false;
                      DisplayInDataBox = true;
                      DrawOnPricePanel = true;
                      DrawHorizontalGridLines = true;
                      DrawVerticalGridLines = true;
                      PaintPriceMarkers = true;
                      ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                      //Disable this property if your indicator requires custom values that cumulate with each new market data event.
                      //See Help Guide for additional information.
                      IsSuspendedWhileInactive = true;
                      }
                      else if (State == State.Configure)
                      {
                      }
                      else if (State == State.DataLoaded)
                      {
                      
                      }
                      }
                      
                      protected override void OnBarUpdate()
                      {
                      if (Bars.IsFirstBarOfSession)
                      {
                      counter1 = 0;
                      }
                      if ((Close[0] > SMA(Close, 50)[0])
                      && (CrossAbove(EMA(Close, 10), EMA(Close, 20), 1))
                      && (EMA(Close, 20)[0] < SMA(Close, 50)[0])
                      && (Low[0] < SMA(Close, 50)[0]))
                      {​
                      
                      counter1++;
                      TextFixed MyDrawText = Draw.TextFixed(this, "tag1", "X ALCISTA = " + counter1, TextPosition.TopLeft);
                      MyDrawText.Alignment = TextAlignment.Left;
                      }
                      
                      if (Bars.IsFirstBarOfSession)
                      {
                      counter2 = 0;
                      }
                      if ((Close[0] < SMA(Close, 50)[0])
                      && (CrossBelow(EMA(Close, 10), EMA(Close, 20), 2))
                      && (EMA(Close, 20)[0] > SMA(Close, 50)[0])
                      && (High[0] > SMA(Close, 50)[0]))
                      {​
                      
                      counter2++;
                      TextFixed MyDrawText = Draw.TextFixed(this, "tag2", " X BAJISTA = " + counter2, TextPosition.TopLeft);
                      MyDrawText.Alignment = TextAlignment.Left;
                      }
                      }
                      }
                      }
                      
                      [HASHTAG="t3322"]region[/HASHTAG] NinjaScript generated code. Neither change nor remove.
                      
                      namespace NinjaTrader.NinjaScript.Indicators
                      {
                      public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
                      {
                      private ContadorSector[] cacheContadorSector;
                      public ContadorSector ContadorSector()
                      {
                      return ContadorSector(Input);
                      }
                      
                      public ContadorSector ContadorSector(ISeries<double> input)
                      {
                      if (cacheContadorSector != null)
                      for (int idx = 0; idx < cacheContadorSector.Length; idx++)
                      if (cacheContadorSector[idx] != null && cacheContadorSector[idx].EqualsInput(input))
                      return cacheContadorSector[idx];
                      return CacheIndicator<ContadorSector>(new ContadorSector(), input, ref cacheContadorSector);
                      }
                      }
                      }
                      
                      namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
                      {
                      public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
                      {
                      public Indicators.ContadorSector ContadorSector()
                      {
                      return indicator.ContadorSector(Input);
                      }
                      
                      public Indicators.ContadorSector ContadorSector(ISeries<double> input )
                      {
                      return indicator.ContadorSector(input);
                      }
                      }
                      }
                      
                      namespace NinjaTrader.NinjaScript.Strategies
                      {
                      public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
                      {
                      public Indicators.ContadorSector ContadorSector()
                      {
                      return indicator.ContadorSector(Input);
                      }
                      
                      public Indicators.ContadorSector ContadorSector(ISeries<double> input )
                      {
                      return indicator.ContadorSector(input);
                      }
                      }
                      }
                      
                      #endregion


                      Thanks!

                      Comment


                        #12
                        Hello tradingnasdaqprueba,

                        In what you provided it seems that you are resetting the variables and incrementing them when the condition is true. Have you tried this code and if so what was the result?

                        From what I can see you should see text drawn once the conditions become true, before that there will be nothing drawn on the chart. Once the conditions become true it will draw the current counter in the top left corner. As mentioned if you try to draw 2 objects in the same corner one of the objects is not going to be displayed because it will be covered by the other object. You would need to change the second object to use a different corner to see that object.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        581 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        338 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        103 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        554 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        552 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X