Create a background color only between two values.
This coloring will have priority over the background color of the platform or the indicator. Then each color defined in the client code will have priority over the previously defined colors. The alpha parameter is optional.
Syntax:
1 |
ColorBetween(value1,value2,r,g,b,a) |
Example:
1 2 3 4 5 6 7 8 9 10 11 |
ma1 = average[7] ma2 = average[20] //bullish if ma1>ma2 then colorbetween(ma1,ma2,0,255,0,50) //using RGB and Alpha else //bearish colorbetween(ma1,ma2,"red",50) //using pre-registered color name and Alpha endif return |
If this doesn’t work as intended you can try to use this variation:
ma1 = average[7]
ma2 = average[20]
r=255
g=0
b=0
if ma1>ma2 then
r = 0
g= 255
endif
colorbetween(ma1,ma2,r,g,b,50)
return ma1,ma2