setBarColor

lndshrk

Member
Joined
Jun 13, 2019
Posts
13
Likes
2
I'm trying to change a bar color based on certain conditions. I've found 'setBarColor' in the SDK.
setBarColor needs the index, key and color in order to be invoked.

Can someone post a code snippet showing the proper use of the "Object Key" for price bars ?
 

igor.s

Well-known member
Joined
May 22, 2019
Posts
76
Likes
20
For my studies I use setPriceBarColor(index, Color). It seems straightforward and it works well for me. Try that and see if it works for you.
 

MotiveWave_Joe

Moderator
Staff member
Joined
Mar 26, 2019
Posts
62
Likes
10
Hi,

There are quite a few of our source files that implement that method. Here is a snippet from the DeltaMA source:

if (ma > 0) series.setBarColor(index, Values.MA, getSettings().getColor(Inputs.UP_COLOR));
else series.setBarColor(index, Values.MA, getSettings().getColor(Inputs.DOWN_COLOR));
 

dsinnig

Member
Joined
Jun 14, 2019
Posts
21
Likes
8
Hi everyone,

the key is important to indicate which bar should be colored. This is especially important, if your study has multiple different bars. Have a look at the histogram study below (which is a deviation of the built-in MA Diff study). In the same histogram, it hows the MA diff (small bars) and an averaged (smoothed) value of the differences (big bars). In such a case, you need to pass on to the setBarColor method which bar (regular diff or smoothed diff) you want to color.

32

I have attached the Java code for your reference.

Cheers,
Daniel
 

Attachments

Top