Shading Bands With Different Colors?
Author: Ben_Zurich
Creation Date: 2/9/2015 11:57 AM
profile picture

Ben_Zurich

#1
Is it possible to shade bands (like Bollinger Bands) with a different color for each bar, according to a certain rule?

I have done this with vertical lines and brushed colors, but this is not satisfactory as the vertical lines have a width and this gives unwanted effects when shrinking or widening the bars.
profile picture

Eugene

#2
profile picture

Ben_Zurich

#3

This is probably a misunderstanding.

We would like to create a band that has a transparent fill ("brush" command) but which would change its fill color depending on an underlying signal.

So for example, the band's fill should be transparent green when a MA cross signal is positive and change to transparent red when the MA cross signal is negative. (the MA shall not be displayed, only the shading of the band).


In additiona, we want to have a second band with a much longer lookback period and wider variation.
The bigger band should also display a red / green fill depending on an underlying signal.

Ideally, the coloring of the short term band should be "above" the coloring of the longterm-band.

profile picture

Cone

#4
The only way I could see it being done from WealthScript is to write a routine that draws rectangles from bar to bar between the bands, with the desired color.

Here's an example:
CODE:
Please log in to see this code.
profile picture

Ben_Zurich

#5

Well we tried it with vertical lines, that works - sort of, but it looks very bad when the chart's time compression is scaled up or down.

The problem here is that vertical line width is static and doesn't scale.
if you choose them too thin (1 or 3) you will see white lines in between, if it is too thick, density will increase and also produce a strange look when the time is compressed.

Would those rectangles that you are referencing to scale in width ?

Where could we find code for that ?


profile picture

Cone

#6
See above.
profile picture

Ben_Zurich

#7
sorry I didn't see that in the first place. Thanks.
profile picture

Ben_Zurich

#8
This worked perfectly, thank you!
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).