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("");
    }
    }
    }
    }


    Last edited by alagu; 06-20-2023, 10:19 AM.

    #2
    Hello, thanks for writing in. When you get a script that compiles, but does not show up in the Indicator/Strategy list, always first check the Log tab of the Control Center for any errors. This line is causing the initialization error:
    AddChartIndicator(new Plot(new Pen(Brushes.Transparent, 0), "Tick Count"));

    Did you mean to use AddPlot?

    Comment


      #3
      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("");
      }
      }
      }
      }


      ​​

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      51 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      31 views
      0 likes
      Last Post PaulMohn  
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      165 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      100 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      160 views
      2 likes
      Last Post CaptainJack  
      Working...
      X