Reputation: 19
How do I create a fill color between "the plot and a horizontal line" whenever the "plot" is above the "horizontal line"?
I can only seem to do it for plot and plot or hline and hline, but never both.
Example here I want to make the color filled between the ema 20 and the line, whenever ema is above 220.
//@version=5
indicator("My script")
ema = ta.ema(close, 20)
hline = hline(220)
fill(hline, ema, color=color.red)
Upvotes: 0
Views: 663
Reputation: 21294
That is correct. You cannot mix a plot()
and an hline()
in fill()
.
As a workaround, you can just plot your hline.
//@version=5
indicator("My script")
ema = ta.ema(close, 20)
p_ema = plot(ema)
p_hline = plot(220)
fill(p_hline, p_ema, color=color.red)
Upvotes: 1