KoKo69
Pine Script Scholar
Pine Script Scholar
Posts: 2
Joined: March 8th, 2023
Contact: TradingView Profile

Visual order of drawing a box

Hi there ,

When using aBox = box.new( ... etc
Is there a way to make the box draw behind the candles instead of on top of them ?

thanks ,
. Rob .

Steve Burman
Moderator
Moderator
Posts: 109
Joined: January 13th, 2023

Re: Visual order of drawing a box

Hi Rob,

Unfortunately, the box function does not have a transparency attribute to enable the candle to show through. You could use the bgcolor function to highlight the candle you want which you can specify a transparency for, however, it will be a vertical line with no control over height or placement.

eg. bgcolor(barstate.isrealtime ? color.new(color.blue,80) : na)

KoKo69
Pine Script Scholar
Pine Script Scholar
Posts: 2
Joined: March 8th, 2023
Contact: TradingView Profile

Re: Visual order of drawing a box

Hi Steve ,

Actually , the box function does have a transparency attribute as I am using it atm to fade the box color. But this is not really what i am trying to do. After further research , I think it is the z index I need to change in order to plot the box behind the candles rather then on top. However , z does not seem to be available in pinescript.Thank you anyway Steve .... R .

Steve Burman
Moderator
Moderator
Posts: 109
Joined: January 13th, 2023

Re: Visual order of drawing a box

Hi Rob,

I just looked up all the box attributes and again couldn't find transparency in the language reference. Just out of interest, how are you using it or do I just have blinkers on lol?

Return to “Pine Script Q&A”