Here is my code:
__________________________________________________ ___
double Two_Bar_High = Math.Max(High[1], High[0]); // Calculate 2-bar hi
double Two_Bar_Low = Math.Min(Low[1], Low[0]); // Calculate 2-bar lo
Two_Bar_Range.Set(Two_Bar_High - Two_Bar_Low); // 2-bar range
double Smallest_Range = MIN(Two_Bar_Range, 20)[0];
if (Two_Bar_Range[0] == Smallest_Range)
{
BarColorSeries[0] = Color.Black;
BarColorSeries[1] = Color.Black;
DrawDot("0"+CurrentBar, true, 0, High[0] + Offset, Color.Black);
DrawDot("1"+CurrentBar, true, 1, High[1] + Offset, Color.Black);
}
else if (Two_Bar_Range[1] == Smallest_Range)
{
BarColorSeries[1] = Color.Black;
BarColorSeries[2] = Color.Black;
DrawDot("1a"+CurrentBar, true, 1, High[1] + Offset, Color.Black);
DrawDot("2"+CurrentBar, true, 2, High[2] + Offset, Color.Black);
}
else if (Two_Bar_Range[2] == Smallest_Range)
{
BarColorSeries[2] = Color.Black;
BarColorSeries[3] = Color.Black;
DrawDot("2a"+CurrentBar, true, 2, High[2] + Offset, Color.Black);
DrawDot("3"+CurrentBar, true, 3, High[3] + Offset, Color.Black);
}
..... and so on up to [20].
__________________________________________________ ___
This code almost works, but not quite. It sometimes plots signals on 3 bars in a row when the condition is satisfied on back-to-back bars. It also fails to plot any signals at all for over 20 bars on some occasions. I need it to be able to "repaint" bars and signals correctly.
Any suggestions?
Comment