----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
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