Custom colors for volume bars

smf2005

New member
Joined
May 22, 2020
Posts
2
Likes
0
Hello! Does anybody know how can I set a specific color for the volume chart bar at a given position? For the price chart I did something similar using the DataSeries' "setPriceBarColor", called from the overriden "calculate" void in the study class, something like:

@Override
protected void calculate(int index, DataContext ctx) {
[...]
DataSeries series = ctx.getDataSeries();
[...]
series.setPriceBarColor(index, Color.GREEN);
}

However I do not see a corresponding "setVolumeBarColor" or anything similar I could think of, or an alternate approach... any ideas are welcome. Thanks!
volume_bar_custom_colors.png
 

smf2005

New member
Joined
May 22, 2020
Posts
2
Likes
0
In the meantime, I've found a workaround to declare a new indicator and manually re-create the volume bars in a new chart frame, something like:

public void initialize(Defaults defaults)
RuntimeDescriptor desc = new RuntimeDescriptor();
[...]
desc.declareBars(Values.CUSTOM_VOLUME, Inputs.BAR);
desc.declareIndicator(Values.CUSTOM_VOLUME, Inputs.IND);
[...[
}

protected void calculate(int index, DataContext ctx) {
[...]
DataSeries series = ctx.getDataSeries();
series.setFloat(index, Values.CUSTOM_VOLUME, series.getVolumeAsFloat(index));
[...]
}

Based on another topic from this forum (thanks, Daniel!):
 
Top