Bapi

Bapi

//@version=6

indicator("RSI with 15 EMA and 9 EMA", overlay=true)

// Input settings for RSI
rsiLength = input.int(14, title="RSI Length")
rsiSource = input.source(close, title="RSI Source")
rsiOverbought = input.int(70, title="RSI Overbought")
rsiOversold = input.int(30, title="RSI Oversold")

// Calculate RSI
rsiValue = ta.rsi(rsiSource, rsiLength)

// Plot RSI in a separate pane
rsiPlot = plot(rsiValue, title="RSI", color=color.blue, linewidth=2)
hline(rsiOverbought, "Overbought", color=color.red, linestyle=hline.style_dotted)
hline(rsiOversold, "Oversold", color=color.green, linestyle=hline.style_dotted)

// Input settings for EMAs
ema15Length = input.int(15, title="15 EMA Length")
ema9Length = input.int(9, title="9 EMA Length")

// Calculate EMAs
ema15 = ta.ema(close, ema15Length)
ema9 = ta.ema(close, ema9Length)

// Plot EMAs on the price chart
plot(ema15, title="15 EMA", color=color.orange, linewidth=2)
plot(ema9, title="9 EMA", color=color.purple, linewidth=2)

// Add background color based on RSI levels
bgcolor(rsiValue > rsiOverbought ? color.new(color.red, 90) : rsiValue < rsiOversold ? color.new(color.green, 90) : na)

Read More

Share:

Latest News