Is there ANY ways possible to manipulate, maybe even override the way the candlestick charts are colored?
What I'm trying to do, should look like this:
What happens here, is that the candles are filled with its color when the "Open" prices are higher than "Close" prices, and black when it's the other way around.
But this isn't possible in MS Chart? I was thinking about creating another candlestick series on top of the other, and get filled boxes from that, but it wouldn't work, since MS Chart automatically uses the "PriceDown/Up" colors. ...See my answer below.
Here's the code I use and which doesn't work the way I would like to:
DataPointCollection dpcCandle = Series[Candle].Points;
DataPointCollection dpcPrice = Series[Price].Points;
int candleCount = dpcCandle.Count;
dpcCandle.AddXY(time, high);
dpcCandle[candleCount].YValues[1] = low;
dpcCandle[candleCount].YValues[2] = open;
dpcCandle[candleCount].YValues[3] = close;
if( candleCount > 1 )
{
Color col;
float oldClose = (float)dpcCandle[candleCount-1].YValues[3];
float oldOpen = (float)dpcCandle[candleCount-1].YValues[2];
dpcCandle[candleCount].BorderWidth = 1;
// Determine color
if( oldClose <= close) // Price up!
col = Color.ForestGreen;
else // Price down...
col = Color.Red;
// Determine fill
if( open < close )
{
dpcCandle[candleCount].Color = Color.Black;
dpcCandle[candleCount].BorderColor = col;
}
else
{
dpcCandle[candleCount].Color = col;
dpcCandle[candleCount].BorderColor = col;
}
if( oldOpen.Equals(close) )
{
dpcCandle[candleCount].Color = dpcCandle[candleCount-1].Color;
dpcCandle[candleCount].BorderColor = dpcCandle[candleCount-1].BorderColor;
}
}
Well, it works, but the result looks like this:
...with these settings:
Series[Candle]["PriceUpColor"] = "Black";
Series[Candle]["PriceDownColor"] = "Black";
And when I change those to these:
Series[Candle]["PriceUpColor"] = "ForestGreen";
Series[Candle]["PriceDownColor"] = "Red";
...I get this ugly mess for a result:
Thanks in advance.