enter image description hereenter image description here
I am trying to build a BUY/SELL Indicator for TradingView by EMA.
Conditions for BUY Signal: The 9 EMA LINE (Green) is above the 18 EMA LINE (Red)
Conditions for SELL Signal: The 9 EMA LINE (Green) is below the 18 EMA LINE (Red)
When the above conditions are met it should give the respective BUY or SELL signal.
But, I am not being able to fill background & plotbarcolor for the correct BUY/SELL signal that meets all the conditions.
My codes:
//@version=5 indicator(title='EMA', overlay=true)
s9ema = ta.ema(close, 9) s18ema = ta.ema(close, 18)
longCond = ta.crossover(s9ema, s18ema) shortCond = ta.crossunder(s9ema, s18ema)
plotshape(series=longCond, title='BUY', style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), textcolor=color.new(color.white, 0), text='BUY', size=size.small) plotshape(series=shortCond, title='SELL', style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), textcolor=color.new(color.white, 0), text='SELL', size=size.small)