Search code examples
pine-scriptpine-script-v5

Using Plotcandle with condition


how can i use a boolean inside Plotcandle?

plotcandle(open_c, open_c, close_c, close_c, title='Candles', color=open_c < close_c ? color.new(#003c7f,50) : color.new(#991722,50), wickcolor=na, bordercolor=open_c < close_c ? color.new(#003c7f,50) : color.new(#991722,50))

What im trying to do is using a boolean input and then plot when checkbox is True:

candle_bool = input.bool(defval=true, title='Candles')

As i use to do with the classic plot() function for plotting conditionally:

plot(candle_bool ? open_c : na [.....])

But how can i do a similar job with plotcandle()?


Solution

  • Your title sasys plotshape() but your question has plotcandle().

    You can use the display argument in both cases.

    plotcandle(open, high, low, close, "Bar", display=candle_bool ? display.all : display.none)