ex.
| 09.54.02 close price is 18761 | |
| 18761 already in list automatically add to value and number of time repeated +1 | |
| values | number of time repeated |
| 18760 | 13 |
| 18765 | 11 |
| 18762 | 33 |
| 18761 | 33 |
| 18769 | 35 |
| 18771 | 45 |
| 18763 | 1 |
| 09.54.03 close price is 18760 | |
| 18760 already in list automatically add to value and number of time repeated +1 | |
| values | number of time repeated |
| 18760 | 13 |
| 18765 | 12 |
| 18762 | 33 |
| 18761 | 33 |
| 18769 | 35 |
| 18771 | 45 |
| 18763 | 1 |
| 09.54.04 close price is 18778 | |
| 18778 no already in list automatically add to value and number of time repeated 1 | |
| values | number of time repeated |
| 18760 | 13 |
| 18765 | 12 |
| 18762 | 33 |
| 18761 | 33 |
| 18769 | 35 |
| 18771 | 45 |
| 18763 | 1 |
| 18778 | 1 |
using System.Collections.Generic;
using System.Windows.Media;
using NinjaTrader.Gui.Chart;
using NinjaTrader.NinjaScript;
using NinjaTrader.NinjaScript.DrawingTools;
using GuiTools = NinjaTrader.Gui.Tools;
namespace NinjaTrader.NinjaScript.Indicators
{
public class PriceLevelCounter : Indicator
{
private Dictionary<double, int> tickCounts;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = "Price Level Counter";
Name = "PriceLevelCounter";
IsOverlay = false;
DisplayInDataBox = true;
Calculate = Calculate.OnPriceChange;
}
else if (State == State.DataLoaded)
{
tickCounts = new Dictionary<double, int>();
}
}
protected override void OnBarUpdate()
{
if (tickCounts.ContainsKey(Close[0]))
{
tickCounts[Close[0]]++;
}
else
{
tickCounts.Add(Close[0], 1);
}
}
protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
{
int count = 0;
foreach (var kvp in tickCounts)
{
double priceLevel = kvp.Key;
count++;
string text = string.Format("{0}: {1}", priceLevel, kvp.Value);
Draw.TextFixed(this, "Count" , text, TextPosition.BottomRight, Brushes.White, new GuiTools.SimpleFont("Arial", 150), Brushes.Transparent, Brushes.Transparent, 0);
}
}
}
}
---------------------------------------------------------------------------------------------------------------
but it output shows only one price repeated count. i want each price repeated count
i want like this output
| 18760 | 13 |
| 18765 | 11 |
| 18762 | 33 |
| 18761 | 33 |
| 18769 | 35 |
| 18771 | 45 |
| 18763 | 1 |

Comment