|
Individual candlestick colors |
Posted by jcl on Apr-19-2011 22:02 |
|
I'm using a FinanceChart and am wondering what the easiest method is to highlight particular volume bars or candlesticks in a different color. For instance, I want to colorize volume bars red when the volume is above a certain threshold. Of course I could add another layer on top and draw rectangular symbols over the bars or candles, but is there a more straightforward way? |
Re: Individual candlestick colors |
Posted by Peter Kwan on Apr-20-2011 01:28 |
|
Hi jcl,
The easiest method I can think of it to add another bar layer. An example in C++ is like:
XYChart *m = c->addMainChart(240); //add the main price chart
Layer *layer = c->addVolBars(75, 0x99ff99, 0xff9999, 0x808080); //add the volume bars
//Code to add another bar layer to highlight some bars
Layer *layer2 = m->addBarLayer(DoubleArray(specialBars, noOfBars), 0xff0000);
layer2->moveFront(layer);
layer2->setUseYAxis2();
In the above, specialBars is an array of double representing the bars you want to highligh. Each of its elements should be either Chart::NoValue or the "scaled volume", depending on whether the corresponding bar needs to be highlighted. The "scaled volume" is the volume divided by 1, 1000, or 1000000, which depends on whether the maximum volume is maxVol < 1000, or 1000 <= maxVol < 1000000, or maxVol >= 1000000.
Hope this can help.
Regards
Peter Kwan |
Re: Individual candlestick colors |
Posted by jcl on Apr-21-2011 22:32 |
|
Thanks, I'll try that! |
Re: Individual candlestick colors |
Posted by SK on Apr-25-2011 05:15 |
|
How can one add multiple candle stick series ? |
Re: Individual candlestick colors |
Posted by Peter Kwan on Apr-25-2011 16:07 |
|
Hi SK,
Do you mean you would to put two candlestick series in two separate plot areas in the charts, or do you want to put them in the same plot area (so that the candlesticks may overlap)? Are you using the FinanceChart object? There is an example below which uses the FinanceChart object to put two candlestick series in two separate plot areas:
http://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&thread=1244750697#N1244762987
If you need to translate the above sample code to another programming language, or if you would like to put two candlestick series in the same plot area, please let me know.
Regards
Peter Kwan |
Re: Individual candlestick colors |
Posted by SK on Apr-26-2011 13:49 |
|
Thanks Peter. I meant 2 different candle sticks on same chart. Is it possible. Currently the way I do is to
c.setdata(...) // Data Set 1
c.addCandleStick(0x008000, 0xcc0000)
c.setdata(...) // Data Set 2
c.addCandleStick(0x008000, 0xcc0000)
Is this the only way ? The downside with this is that this overwrites the Data Set 1.
- SK |
Re: Individual candlestick colors |
Posted by Peter Kwan on Apr-26-2011 23:26 |
|
Hi SK,
You may try:
c.setData(...) // Data Set 1
c.addCandleStick(0x008000, 0xcc0000)
c.setData(...) // Data Set 2
c.addCandleStick(0x008000, 0xcc0000)
c.setData(...) // Data Set 1
The above will restore the original data set.
Another alternative is (in Python)
m = c.addMainChart(......)
c.addCandleStick(0x008000, 0xcc0000)
m.addCandleStickLayer(highData2, lowData2, openData2, closeData2, 0x008000, 0xcc0000)
Hope this can help.
Regards
Peter Kwan |
Re: Individual candlestick colors |
Posted by SK on Apr-28-2011 06:47 |
|
I like the second one. Thanks. |
|