Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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?
    Chris L.NinjaTrader Customer Service

    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 pibrew, Today, 06:10 PM
      0 responses
      4 views
      0 likes
      Last Post pibrew
      by pibrew
       
      Started by pibrew, 04-28-2024, 06:37 AM
      2 responses
      17 views
      0 likes
      Last Post pibrew
      by pibrew
       
      Started by Philippe56140, 04-27-2024, 02:35 PM
      7 responses
      56 views
      0 likes
      Last Post kevinenergy  
      Started by arunkumar3, 08-25-2023, 12:40 PM
      3 responses
      169 views
      0 likes
      Last Post Trader2024!  
      Started by DJ888, 04-26-2024, 10:57 PM
      2 responses
      19 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Working...
      X