WinXP SP3
CalculateOnBarClose = True
I am trying to shade the background color of the price chart based on a fast moving average being above (green) or below (red) a slower moving average using "DrawRegion". What happens is that it shades the current bar correctly when the bar closes but then "clears" the shading of the prior bar if it has the same tag. It appears that the only bar "shaded" is the last bar of the "region".
I guess I do not understand how a DrawRegion actually works. What happens to the prior region if the same tag is used several times in a row?? I have tried using 1 or 0 in the start/end bars ago but end up with no shading or the same issue.
In the attachment you can see the blank space between the last "red" shade and the last "green" shade. When the green shading first appeared it was next to the red but as each new bar appeared it cleared out the prior "green" shade and printed a new green shade.
This is the code section with the problem.
RegHigh.Set(High[0] + 100); //Sets the top of price chart
RegLow.Set(Low[0] - 100); //Sets the bottom of price chart
if (dsFast[0] > dsSlow[0]) //The moving averages 20 & 100
{
DrawRegion("Green", 1, 0, RegHigh, RegLow, Color.Empty, Color.Green, 5);
}
elseif (dsFast[0] < dsSlow[0])
{
DrawRegion("Red", 1, 0, RegHigh, RegLow, Color.Empty, Color.Red, 5);
}
else
{
DrawRegion("Yellow", 1, 0, RegHigh, RegLow, Color.Empty, Color.Yellow, 5);
}
Comment