RSI - S&P Sector ETFs
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © All_Verklempt

//@version=5

indicator("RSI S&P Sectors", "", format=format.price, precision=2, timeframe="", timeframe_gaps=true)

//
// Inputs

rsiLengthInput = input.int(14, minval=1, title="RSI Length")
rsiSourceInput = input.source(close, title="RSI Source")

//
// Symbol Calls

symbolrsi01 = request.security("BATS:XLK", timeframe.period, ta.rsi(rsiSourceInput, rsiLengthInput) ,lookahead=barmerge.lookahead_on)
symbolrsi02 = request.security("BATS:XLV", timeframe.period, ta.rsi(rsiSourceInput, rsiLengthInput) ,lookahead=barmerge.lookahead_on)
symbolrsi03 = request.security("BATS:XLF", timeframe.period, ta.rsi(rsiSourceInput, rsiLengthInput) ,lookahead=barmerge.lookahead_on)
symbolrsi04 = request.security("BATS:XLY", timeframe.period, ta.rsi(rsiSourceInput, rsiLengthInput) ,lookahead=barmerge.lookahead_on)
symbolrsi05 = request.security("BATS:XLC", timeframe.period, ta.rsi(rsiSourceInput, rsiLengthInput) ,lookahead=barmerge.lookahead_on)
symbolrsi06 = request.security("BATS:XLI", timeframe.period, ta.rsi(rsiSourceInput, rsiLengthInput) ,lookahead=barmerge.lookahead_on)
symbolrsi07 = request.security("BATS:XLP", timeframe.period, ta.rsi(rsiSourceInput, rsiLengthInput) ,lookahead=barmerge.lookahead_on)
symbolrsi08 = request.security("BATS:XLE", timeframe.period, ta.rsi(rsiSourceInput, rsiLengthInput) ,lookahead=barmerge.lookahead_on)
symbolrsi09 = request.security("BATS:XLU", timeframe.period, ta.rsi(rsiSourceInput, rsiLengthInput) ,lookahead=barmerge.lookahead_on)
symbolrsi10 = request.security("BATS:XLB", timeframe.period, ta.rsi(rsiSourceInput, rsiLengthInput) ,lookahead=barmerge.lookahead_on)
symbolrsi11 = request.security("BATS:XLRE", timeframe.period, ta.rsi(rsiSourceInput, rsiLengthInput) ,lookahead=barmerge.lookahead_on)


//
// Plot Information

plot(symbolrsi01, title="XLK", color=#801922)
plot(symbolrsi02, title="XLV", color=#f57c00)
plot(symbolrsi03, title="XLF", color=#fbc02d)
plot(symbolrsi04, title="XLY", color=#388e3c)
plot(symbolrsi05, title="XLC", color=#056656)
plot(symbolrsi06, title="XLI", color=#0097a7)
plot(symbolrsi07, title="XLP", color=#1848cc)
plot(symbolrsi08, title="XLE", color=#512da8)
plot(symbolrsi09, title="XLU", color=#7b1fa2)
plot(symbolrsi10, title="XLB", color=#c2185b)
plot(symbolrsi11, title="XLRE", color=#f06292)

rsiUpperBand = hline(70, "RSI Upper Band", color=#e3dac9)
hline(50, "RSI Middle Band", color=color.new(#e3dac9, 50))
rsiLowerBand = hline(30, "RSI Lower Band", color=#e3dac9)