Freddie Mander
Freddie Mander

Reputation: 1

How to change the candle color of a candles which satisfy my candle criteria/definition in Pine Script?

Here is my current code:

strategy("Big Candle", overlay = true, shorttitle="Candle Boom", initial_capital = 100000)

//Bullish Body
bhu1 = (close-open) > 0.00102 
bullColor = #095616
bearColor = #ac0011

plotshape(bhu1 , style = shape.arrowup , location = location.belowbar , text = "Bull")

plotcandle(bhu1, color=bullColor)

I'm trying to change the color of all the candles which meet the bhu1 definition shown above (candles with big bodies basically) I've tried many variations trying to get this to work: e.g. plotcandle(bhu1 ? color=bullColor) etc and many more but I can't get it to work.

Error: Cannot call plotcandle with arguments (series__bool, color); available overloads: plotcandle(series, series, series, series, string, series__color, color, literal__bool, string) => void; plotcandle(fun_arg__<arg_open_type>, fun_arg__<arg_high_type>, fun_arg__<arg_low_type>, fun_arg__<arg_close_type>, string, fun_arg__<arg_color_type>, color, literal__bool, string) => void Script 'Candle alert' has been saved

What do I need to do?

Upvotes: 0

Views: 225

Answers (1)

beeholder
beeholder

Reputation: 1699

plotcandle() doesn't modify the existing chart candles, it creates a new, separate candle set, so it won't help you with this. To specify the color of the main chart candles' bodies, you can use barcolor():

//@version=4
strategy("Big Candle", overlay = true, shorttitle="Candle Boom", initial_capital = 100000)
//Bullish Body
bhu1 = (close-open) > 0.00102 
bullColor = #095616
bearColor = #ac0011
barcolor(bhu1 ? bullColor : na)

Upvotes: 1

Related Questions