Hi, I'm new to Pine Script and learning to write some simple codes. I've made a HMA script that changes color based on direction. Here's the code:
study(title=HMA
, overlay=true)
src = input(close, title=Source
)
len = input(20, title=HMA Length
)
hma1 = hma(src, len)
hmacolor = change(hma1)>=0 ? color.green : color.red
plot(hma1, color=hmacolor, title=HMA
)
I'm able to change the series of bar color using the following code:
barcolor(change(hma1)>=0 ? color.green : color.red)
but what i'd like instead, is to be able to change just a single bar's color(as a signal) when the direction/color of HMA changes.
Any help will be greatly appreciated.
Thanks