I don't even know what to title this problem as I have zero idea what is going on. So extremely frustrating these built-in functions are - there is more behind the scenes stuff going on here and I have no idea what. For whatever reason, it is reloading the bars several times and recalculating the indicator OR it is resetting Bars.CurrentBar property.
Code: Select all
private ISeries<Boolean> m_popCondition;
private CountIf m_popCount;
protected override void Create()
{
m_popCount = new CountIf(this);
plot1 = AddPlot(new PlotAttributes("", EPlotShapes.Line, Color.Red));
}
protected override void StartCalc()
{
m_popCondition =
new Lambda<Boolean>(
delegate(int _idx)
{ return ((Bars.Open[_idx] >= Bars.Low[1 + _idx]) && (Bars.Open[_idx] <= Bars.High[1 + _idx])); });
m_popCount.test = m_popCondition;
m_popCount.length = new Lambda<Int32>(delegate { return Bars.CurrentBar; });
}
protected override void CalcBar()
{
Output.WriteLine("{0}", Bars.CurrentBar);
plot1.Set(m_popCount[0]);
}
Code: Select all
1
1
2
3
4
5
6
7
1
2
3
4
5
6
7
8
9
10
11
12
13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
...
Tediously tired and confused,
MK