RS9.1
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Ricardo_Silva

//@version=5
strategy("RS9.1", overlay=true, margin_long=100, margin_short=100)

ema9  =  ta.ema(close,9)
//ema21 =  ta.ema(close,21)
//ema50 =  ta.ema(close,50)
//ema100 = ta.ema(close,100)
//ema200 = ta.ema(close,200)


ema9up= ema9>ema9[1]
colorup=(ema9up ? color.green:na)

ema9down=ema9<ema9[1]
colordown = (ema9down ? color.red:na)

ema9n=not ema9up and not ema9down
colorn=(ema9n ? color.yellow:na)

plot(ema9, title="EMA 9 UP",linewidth=2,color=colorup)
plot(ema9, title="EMA 9 DOWN",linewidth=2,color=colordown)
plot(ema9, title="EMA 9 N",linewidth=2,color=colorn)
//plot(ema21, title="EMA 26 N",linewidth=2,color=color.orange)
//plot(ema50, title="EMA 50 N",linewidth=2,color=color.gray)
//plot(ema100, title="EMA 100", linewidth=2, color=color.blue)
//plot(ema200, title="EMA 200", linewidth=3, color=color.black)

// text signal

textbuy= high>high[1] and close>ema9 and close[1]<ema9[1]

textsell= low<low[1] and close<ema9 and close[1]>ema9[1]

long = close > ema9
short = close < ema9

//barcolor signal

buybarsignal= close>close[1] and textbuy 
sellbarsignal = close<close[1] and textsell


barcolor(buybarsignal? #0e0ffb:na,title="BuyBar")
barcolor(sellbarsignal? color.purple:na,title="SellBar")

bgcolor(color=long ? color.new(color.green,80) : color.new(color.red,80))








