Hi kuli,
The FinanceChart volume bars have different colors for up, down and flat days. May be you can use the FinanceChart.py source code (see the addVolIndicator method) as a reference on how this is achieved.
Basically, you would need to separate your data into two or more data series, with each data series representing bars of one color. The separation method depends on what you mean by "falling" and "raising" bars. After separating the data, you may the data to the chart as different data sets, using different colors.
In brief, the code would be like:
#separate the bar data into two data series for falling and raising bars
fallingBars = [NoValue] * len(myData)
raisingBars = [NoValue] * len(myData)
for i in range(0, len(myData)) :
if is_Falling_Bar(i) :
fallingBars[i] = myData[i]
else :
raisingBar[i] = myData[i]
#add the two data series using different colors
barLayer = c.addIndicator(height).addBarLayer2(Overlay)
barLayer.setBorderColor(Transparent)
barLayer.addDataSet(fallingBars, fallingBarColor)
barLayer.addDataSet(raisingBars, raisingBarColor)
#display the legend icon color based on the last bar
barLayer.getDataSet(fallingBars[-1] != NoValue).setDataName("My Indicator")
Hope this can help.
Regards
Peter Kwan |