Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

my chart indicator section not showing my indecator name

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

    my chart indicator section not showing my indecator name

    my script compile without error .but in my chart indicator section not showing my indecator name. pls tell me how solve this

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    i would plan to design this indicator for each and every tick by tick LTP how many times repeated and it will be counted.

    ex.
    LTP | LTP repeated count
    1879 | 34
    1881 | 38
    1885 | 60
    ​------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    using System.Collections.Generic;
    using System.Windows.Media;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.NinjaScript.Indicators;

    namespace NinjaTrader.NinjaScript.Strategies
    {
    public class TickRepetitionCounter : Strategy
    {
    private Dictionary<double, int> tickCounts;
    private double lastTickValue;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = "Tick Repetition Counter";
    Name = "TickRepetitionCounter";
    Calculate = Calculate.OnEachTick;
    IsFillLimitOnTouch = false;
    BarsRequiredToTrade = 1;
    tickCounts = new Dictionary<double, int>();
    }
    }

    protected override void OnBarUpdate()
    {
    double currentTickValue = Close[0];

    if (tickCounts.ContainsKey(currentTickValue))
    {
    tickCounts[currentTickValue]++;
    }
    else
    {
    tickCounts.Add(currentTickValue, 1);
    }

    lastTickValue = currentTickValue;

    PrintTickCounts();
    }

    private void PrintTickCounts()
    {
    ClearOutputWindow();

    foreach (KeyValuePair<double, int> tickCount in tickCounts)
    {
    Print("Value: " + tickCount.Key + "\tNumber of Times Repeated: " + tickCount.Value);
    }
    }

    private void ClearOutputWindow()
    {
    for (int i = 0; i < 100; i++)
    {
    Print("");
    }
    }
    }
    }​

    #2
    Hello alagu,

    Is there an error appearing on the Log tab of the Control Center?

    Have you erased the label in the Indicators window?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3


      hi chelsea , modified same changes in my script .so that problem was solve now appare indicator in my chart . but i facing new issue on indicator not showing real time value repeated count it show's same random number . i am attact screenshot for you ref . pls tell how to solve this

      -------------------------------------------------------------------

      using System;
      using System.Collections.Generic;
      using System.Windows.Media;
      using NinjaTrader.NinjaScript;
      using NinjaTrader.NinjaScript.DrawingTools;
      using NinjaTrader.NinjaScript.Indicators;

      namespace NinjaTrader.NinjaScript.Indicators
      {
      public class TickRepetitionCounter : Indicator
      {
      private Dictionary<double, int> tickCounts;
      private double lastTickValue;
      private DateTime lastTradingDate;

      protected override void OnStateChange()
      {
      if (State == State.SetDefaults)
      {
      Description = "Tick Repetition Counter";
      Name = "TickRepetitionCounter";
      Calculate = Calculate.OnEachTick;
      IsOverlay = true;
      tickCounts = new Dictionary<double, int>();
      }
      }

      protected override void OnBarUpdate()
      {
      DateTime currentTradingDate = Time[0].Date;

      if (currentTradingDate != lastTradingDate)
      {
      tickCounts.Clear();
      lastTradingDate = currentTradingDate;
      }

      double currentTickValue = Close[0];

      int currentTickCount = tickCounts.ContainsKey(currentTickValue) ? tickCounts[currentTickValue] : 0;
      tickCounts[currentTickValue] = currentTickCount + 1;

      lastTickValue = currentTickValue;

      PrintTickCounts();
      }

      private void PrintTickCounts()
      {
      RemoveDrawObjects();

      int yOffset = 0;

      foreach (KeyValuePair<double, int> tickCount in tickCounts)
      {
      string label = "Value: " + tickCount.Key + "\tNumber of Times Repeated: " + tickCount.Value;

      Draw.Text(this, label, yOffset.ToString(), 0, tickCount.Key, Brushes.White);
      yOffset -= 15;
      }
      }
      }
      }
      Last edited by alagu; 06-21-2023, 07:32 AM.

      Comment


        #4
        Hello alagu,

        It appears you are assigning currentTickCount to the Close[0] which is the market price.
        Then you add one to this and save the value to the key of the market price.

        Is this what you are trying to achieve? You want a dictionary of market price keys that have a value of the market price plus 1?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          already modified this code many time. but still this code provided what evary i want that thinks .i you don't mind pls check and reprogram this code

          i want real time each and evary value how many time repeated .for your ref pls view attached fig

          Click image for larger version

Name:	Screenshot 2023-06-21 205826.png
Views:	202
Size:	30.0 KB
ID:	1256903

          ---------------------------------------------------------------------------------------------------------------------------------------------------------------

          using System;
          using System.Collections.Generic;
          using System.Windows.Media;
          using NinjaTrader.NinjaScript;
          using NinjaTrader.NinjaScript.DrawingTools;
          using NinjaTrader.NinjaScript.Indicators;

          namespace NinjaTrader.NinjaScript.Indicators
          {
          public class TickRepetitionCounter : Indicator
          {
          private Dictionary<double, int> tickCounts;
          private double lastTickValue;
          private DateTime lastTradingDate;

          protected override void OnStateChange()
          {
          if (State == State.SetDefaults)
          {
          Description = "Tick Repetition Counter";
          Name = "TickRepetitionCounter";
          Calculate = Calculate.OnEachTick;
          IsOverlay = true;
          tickCounts = new Dictionary<double, int>();
          }
          }

          protected override void OnBarUpdate()
          {
          DateTime currentTradingDate = Time[0].Date;

          if (currentTradingDate != lastTradingDate)
          {
          tickCounts.Clear();
          lastTradingDate = currentTradingDate;
          }

          double currentTickValue = Close[0];

          int currentTickCount = tickCounts.ContainsKey(currentTickValue) ? tickCounts[currentTickValue] : 0;
          tickCounts[currentTickValue] = currentTickCount + 1;

          lastTickValue = currentTickValue;

          PrintTickCounts();
          }

          private void PrintTickCounts()
          {
          RemoveDrawObjects();

          int yOffset = 0;

          foreach (KeyValuePair<double, int> tickCount in tickCounts)
          {
          string label = "Value: " + tickCount.Key + "\tNumber of Times Repeated: " + tickCount.Value;

          Draw.Text(this, label, yOffset.ToString(), 0, tickCount.Key, Brushes.White);
          yOffset -= 15;
          }
          }
          }
          }​​​

          Comment


            #6
            Hello alagu,

            I would not be able to reprogram the script for you, and instead can only offer guidance for you to modify the script yourself.

            You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.


            Where you have mentioned:
            i want real time each and evary value how many time repeated
            Are you wanting to increment an integer each time a bar closes with a specific price?

            Code:
            if (tickCounts.ContainsKey(Close[0]))
            {
            tickCounts[Close[0]]++;
            }
            else
            {
            tickCounts.Add(Close[0], 1);
            }
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              using System.Collections.Generic;
              using System.Windows.Media;
              using NinjaTrader.NinjaScript;
              using NinjaTrader.NinjaScript.DrawingTools;
              using NinjaTrader.NinjaScript.Indicators;

              namespace NinjaTrader.NinjaScript.Indicators
              {
              public class TickRepetitionCounter : Indicator
              {
              private Dictionary<double, int> tickCounts;
              private double lastTickValue;

              protected override void OnStateChange()
              {
              if (State == State.SetDefaults)
              {
              Description = "Tick Repetition Counter";
              Name = "TickRepetitionCounter";
              Calculate = Calculate.OnEachTick;
              IsOverlay = true;
              tickCounts = new Dictionary<double, int>();
              }
              }

              protected override void OnBarUpdate()
              {
              if (CurrentBar == 0)
              return;

              if (tickCounts.ContainsKey(Close[0]))
              {
              tickCounts[Close[0]]++;
              }
              else
              {
              tickCounts.Add(Close[0], 1);
              }

              lastTickValue = Close[0];

              PrintTickCounts();
              }

              private void PrintTickCounts()
              {
              RemoveDrawObjects();

              int yOffset = 0;

              foreach (KeyValuePair<double, int> tickCount in tickCounts)
              {
              string label = "Value: " + tickCount.Key + "\tNumber of Times Repeated: " + tickCount.Value;

              Draw.Text(this, label, yOffset.ToString(), 0, tickCount.Key, Brushes.White);
              yOffset -= 15;
              }
              }
              }
              }
              ​-----------------------------------------------------------------------------------------------------------------
              HI chelsea

              modified done . but still not show real value counts .indicator shows random value below attached fig.

              Click image for larger version

Name:	Screenshot (21).png
Views:	172
Size:	179.6 KB
ID:	1256908

              Comment


                #8
                Hello alagu,

                It appears you are using the tickCount.Key as the text. To confirm you are only wanting the price key to appear in the drawn text and not the Value?

                The label you are using for the tagName of the drawing object. Is this appearing correctly in the DrawingObjects window for tag?
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                600 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                347 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
                558 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                558 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X