How to paint the active candle?

Yo Adrian

New member
Hey everyone, first post but I've been reading the board for a long time. Finally getting around to participating :)

How can I paint the active candle gray and revert to the original color as soon as it closes?

So far this is my line of thinking:

Code:
def Active = (_no Close price yet_);

AssignPriceColor
(if Active then Color.GRAY
else Color.CURRENT);

Can anyone here fill in the blanks?
 

Pensar

Well-known member
VIP
@Yo Adrian It seems to work fine on my end. I colored the candle blue to make it more visible, as gray is hard to see. Are there any other chart studies loaded that color the price? If so, one will usually override the other.

XmrZyIU.png
 

Iconoclastic

New member
VIP
@Yo Adrian Check if this works.
Code:
def current_bar = !isnan(close) and isnan(close[-1]);
assignpricecolor(if current_bar then color.gray else color.current);
Thank you, Pensar...

I'd like to paint the 3rd past candle. Not every 3rd candle, but the 3rd past, so it shifts/ changes throughout the chart as time advances.
Is that a quick hack for you?

I've bene fartin' around with the code above and I can't get it to work.
 

halcyonguy

Well-known member
VIP
Thank you, Pensar...

I'd like to paint the 3rd past candle. Not every 3rd candle, but the 3rd past, so it shifts/ changes throughout the chart as time advances.
Is that a quick hack for you?

I've bene fartin' around with the code above and I can't get it to work.

to find a bar 3 bars before the last bar, use an offset of 3 , to look at future bars.

Code:
input barsback = 3;
def xbar = !isnan(close[-barsback] ) and isnan(close[-(barsback + 1) ] ); 
assignpricecolor(if xbar then color.gray else color.current);
 

Similar threads

Top