- // This source code is subject to the terms of the MIT License at https://opensource.org/licenses/MIT
- // /u/HurlTeaInTheSea v1.0
- //
- // Credits:
- // - Inspired by /u/lilsgymdan
- // - RRS calculation by /u/WorkPiece on 12.28.21
- // - Concept by u/HSeldon2020
- //@version=5
- indicator(shorttitle='RRS/S', title='Real Relative Sector Strength Arrows', overlay=true)
- var CURRENT_COLOR = #d1d4dc
- var BASELINE_COLOR = #b2b5be
- colorCurrent = input.color(CURRENT_COLOR, title='Current')
- baseline = input.symbol('SPY', title='Baseline', inline='baseline')
- colorBaseline = input.color(BASELINE_COLOR, title='', inline='baseline')
- src = input(close, title='Source')
- periodPC= input.int(12, minval=1, title='Price Chg. Period')
- periodATR = input.int(12, minval=1, title='ATR Period')
- // ===== Sector Symbol Definitions =====
- // Note:
- // - As of 2022-08-29
- // - A symbol may belong in multiple sectors
- // Communication Services
- var sectorName1 = 'Comms'
- var sector1 = 'XLC'
- var sectorSymbols1 = 'ATVI, CHTR, CMCSA, DIS, DISH, EA, META, FOX, FOXA, GOOG, GOOGL, IPG, LUMN, LYV, MTCH, NFLX, NWS, NWSA, OMC, PARA, T, TMUS, TTWO, TWTR, VZ, WBD'
- var color1 = #ffc000
- // Consumer Discretionary
- var sectorName2 = 'CDisc'
- var sector2 = 'XLY'
- var sectorSymbols2 = 'AAP, AMZN, APTV, AZO, BBWI, BBY, BKNG, BWA, CCL, CMG, CZR, DG, DHI, DLTR, DPZ, DRI, EBAY, ETSY, EXPE, F, GM, GPC, GRMN, HAS, HD, HLT, KMX, LEN, LKQ, LOW, LVS, MAR, MCD, MGM, MHK, NCLH, NKE, NVR, NWL, ORLY, PENN, PHM, POOL, PVH, RCL, RL, ROST, SBUX, TGT, TJX, TPR, TSCO, TSLA, UAA, ULTA, VFC, WHR, WYNN, YUM'
- var color2 = #ff0000
- // Consumer Staples
- var sectorName3 = 'CStap'
- var sector3 = 'XLP'
- var sectorSymbols3 = 'ADM, BF.B, CAG, CHD, CL, CLX, COST, CPB, EL, GIS, HRL, HSY, K, KDP, KHC, KMB, KO, KR, LW, MDLZ, MKC, MNST, MO, PEP, PG, PM, SJM, STZ, SYY, TAP, TSN, WBA, WMT'
- var color3 = #0000ff
- // Energy
- var sectorName4 = 'Energy'
- var sector4 = 'XLE'
- var sectorSymbols4 = 'APA, BKR, COP, CTRA, CVX, DVN, EOG, FANG, HAL, HES, KMI, MPC, MRO, OKE, OXY, PSX, PXD, SLB, VLO, WMB, XOM'
- var color4 = #ffff00
- // Financials
- var sectorName5 = 'Fin'
- var sector5 = 'XLF'
- var sectorSymbols5 = 'AFL, AIG, AIZ, AJG, ALL, AMP, AON, AXP, BAC, BEN, BK, BLK, BRK.B, BRO, C, CB, CBOE, CFG, CINF, CMA, CME, COF, DFS, FDS, FITB, FRC, GL, GS, HBAN, HIG, ICE, IVZ, JPM, KEY, L, LNC, MCO, MET, MKTX, MMC, MS, MSCI, MTB, NDAQ, NTRS, PFG, PGR, PNC, PRU, RE, RF, RJF, SBNY, SCHW, SIVB, SPGI, STT, SYF, TFC, TROW, TRV, USB, WFC, WRB, WTW, ZION'
- var color5 = #009940
- // Health Care
- var sectorName6 = 'Health'
- var sector6 = 'XLV'
- var sectorSymbols6 = 'A, ABBV, ABC, ABMD, ABT, ALGN, AMGN, BAX, BDX, BIIB, BIO, BMY, BSX, CAH, CI, CNC, COO, CRL, CTLT, CVS, DGX, DHR, DVA, DXCM, ELV, EW, GILD, HCA, HOLX, HSIC, HUM, IDXX, ILMN, INCY, IQV, ISRG, JNJ, LH, LLY, MCK, MDT, MOH, MRK, MRNA, MTD, OGN, PFE, PKI, REGN, RMD, STE, SYK, TECH, TFX, TMO, UHS, UNH, VRTX, VTRS, WAT, WST, XRAY, ZBH, ZTS'
- var color6 = #f8bbd0
- // Industrials
- var sectorName7 = 'Indus'
- var sector7 = 'XLI'
- var sectorSymbols7 = 'AAL, ALK, ALLE, AME, AOS, BA, CARR, CAT, CHRW, CMI, CPRT, CSX, CTAS, DAL, DE, DOV, EFX, EMR, ETN, EXPD, FAST, FBHS, FDX, FTV, GD, GE, GNRC, GWW, HII, HON, HWM, IEX, IR, ITW, J, JBHT, JCI, LDOS, LHX, LMT, LUV, MAS, MMM, NDSN, NLSN, NOC, NSC, ODFL, OTIS, PCAR, PH, PNR, PWR, RHI, ROK, ROL, ROP, RSG, RTX, SNA, SWK, TDG, TDY, TT, TXT, UAL, UNP, UPS, URI, VRSK, WAB, WM, XYL'
- var color7 = #ff8000
- // Materials
- var sectorName8 = 'Mats'
- var sector8 = 'XLB'
- var sectorSymbols8 = 'ALB, AMCR, APD, AVY, BALL, CE, CF, CTVA, DD, DOW, ECL, EMN, FCX, FMC, IFF, IP, LIN, LYB, MLM, MOS, NEM, NUE, PKG, PPG, SEE, SHW, VMC, WRK'
- var color8 = #801922
- // Real Estate
- var sectorName9 = 'Real'
- var sector9 = 'XLRE'
- var sectorSymbols9 = 'AMT, ARE, AVB, BXP, CBRE, CCI, CPT, DLR, DRE, EQIX, EQR, ESS, EXR, FRT, HST, IRM, KIM, MAA, O, PEAK, PLD, PSA, REG, SBAC, SPG, UDR, VICI, VNO, VTR, WELL, WY'
- var color9 = #8000ff
- // Technology
- var sectorName10 = 'Tech'
- var sector10 = 'XLK'
- var sectorSymbols10 = 'AAPL, ACN, ADBE, ADI, ADP, ADSK, AKAM, AMAT, AMD, ANET, ANSS, APH, AVGO, BR, CDAY, CDNS, CDW, CRM, CSCO, CTSH, CTXS, DXC, ENPH, EPAM, FFIV, FIS, FISV, FLT, FTNT, GLW, GPN, HPE, HPQ, IBM, INTC, INTU, IT, JKHY, JNPR, KEYS, KLAC, LRCX, MA, MCHP, MPWR, MSFT, MSI, MU, NLOK, NOW, NTAP, NVDA, NXPI, ON, ORCL, PAYC, PAYX, PTC, PYPL, QCOM, QRVO, SEDG, SNPS, STX, SWKS, TEL, TER, TRMB, TXN, TYL, V, VRSN, WDC, ZBRA'
- var color10 = #0080ff
- // Utilities
- var sectorName11 = 'Utils'
- var sector11 = 'XLU'
- var sectorSymbols11 = 'AEE, AEP, AES, ATO, AWK, CEG, CMS, CNP, D, DTE, DUK, ED, EIX, ES, ETR, EVRG, EXC, FE, LNT, NEE, NI, NRG, PEG, PNW, PPL, SO, SRE, WEC, XEL'
- var color11 = #00ffff
- // Semiconductors
- var sectorName12 = 'Semis'
- var sector12 = 'SMH'
- var sectorSymbols12 = 'ADI, AMAT, AMD, ASML, AVGO, CDNS, INTC, KLAC, LRCX, MCHP, MPWR, MRVL, MU, NVDA, NXPI, OLED, ON, QCOM, QRVO, SNPS, STM, SWKS, TER, TSM, TXN'
- var color12 = #00ff00
- // Add New
- var sectorName13 = ''
- var sector13 = ''
- var sectorSymbols13 = ''
- var color13 = #2962FF
- // Add New
- var sectorName14 = ''
- var sector14 = ''
- var sectorSymbols14 = ''
- var color14 = #2962FF
- // Add New
- var sectorName15 = ''
- var sector15 = ''
- var sectorSymbols15 = ''
- var color15 = #2962FF
- // Add New
- var sectorName16 = ''
- var sector16 = ''
- var sectorSymbols16 = ''
- var color16 = #2962FF
- // Add New
- var sectorName17 = ''
- var sector17 = ''
- var sectorSymbols17 = ''
- var color17 = #2962FF
- // Add New
- var sectorName18 = ''
- var sector18 = ''
- var sectorSymbols18 = ''
- var color18 = #2962FF
- // Add New
- var sectorName19 = ''
- var sector19 = ''
- var sectorSymbols19 = ''
- var color19 = #2962FF
- // Add New
- var sectorName20 = ''
- var sector20 = ''
- var sectorSymbols20 = ''
- var color20 = #2962FF
- // ===== Sector Inputs =====
- var SECTOR_GROUP_NAME = 'Sectors (Check Each to Always Show)'
- var SECTOR_SHOW_NAME = ''
- showAll = input.bool(false, title='Show All', group=SECTOR_GROUP_NAME)
- c1 = input.color(color1, title='1', group=SECTOR_GROUP_NAME, inline='S1A')
- n1 = input.string(sectorName1, title='', group=SECTOR_GROUP_NAME, inline='S1A')
- s1 = input.symbol(sector1 , title='', group=SECTOR_GROUP_NAME, inline='S1B')
- symbols1 = input.string(sectorSymbols1, title='', group=SECTOR_GROUP_NAME, inline='S1B')
- show1 = input.bool(false, title=SECTOR_SHOW_NAME, group=SECTOR_GROUP_NAME, inline='S1B')
- c2 = input.color(color2, title='2', group=SECTOR_GROUP_NAME, inline='S2A')
- n2 = input.string(sectorName2, title='', group=SECTOR_GROUP_NAME, inline='S2A')
- s2 = input.symbol(sector2 , title='', group=SECTOR_GROUP_NAME, inline='S2B')
- symbols2 = input.string(sectorSymbols2, title='', group=SECTOR_GROUP_NAME, inline='S2B')
- show2 = input.bool(false, title=SECTOR_SHOW_NAME, group=SECTOR_GROUP_NAME, inline='S2B')
- c3 = input.color(color3, title='3', group=SECTOR_GROUP_NAME, inline='S3A')
- n3 = input.string(sectorName3, title='', group=SECTOR_GROUP_NAME, inline='S3A')
- s3 = input.symbol(sector3 , title='', group=SECTOR_GROUP_NAME, inline='S3B')
- symbols3 = input.string(sectorSymbols3, title='', group=SECTOR_GROUP_NAME, inline='S3B')
- show3 = input.bool(false, title=SECTOR_SHOW_NAME, group=SECTOR_GROUP_NAME, inline='S3B')
- c4 = input.color(color4, title='4', group=SECTOR_GROUP_NAME, inline='S4A')
- n4 = input.string(sectorName4, title='', group=SECTOR_GROUP_NAME, inline='S4A')
- s4 = input.symbol(sector4 , title='', group=SECTOR_GROUP_NAME, inline='S4B')
- symbols4 = input.string(sectorSymbols4, title='', group=SECTOR_GROUP_NAME, inline='S4B')
- show4 = input.bool(false, title=SECTOR_SHOW_NAME, group=SECTOR_GROUP_NAME, inline='S4B')
- c5 = input.color(color5, title='5', group=SECTOR_GROUP_NAME, inline='S5A')
- n5 = input.string(sectorName5, title='', group=SECTOR_GROUP_NAME, inline='S5A')
- s5 = input.symbol(sector5 , title='', group=SECTOR_GROUP_NAME, inline='S5B')
- symbols5 = input.string(sectorSymbols5, title='', group=SECTOR_GROUP_NAME, inline='S5B')
- show5 = input.bool(false, title=SECTOR_SHOW_NAME, group=SECTOR_GROUP_NAME, inline='S5B')
- c6 = input.color(color6, title='6', group=SECTOR_GROUP_NAME, inline='S6A')
- n6 = input.string(sectorName6, title='', group=SECTOR_GROUP_NAME, inline='S6A')
- s6 = input.symbol(sector6 , title='', group=SECTOR_GROUP_NAME, inline='S6B')
- symbols6 = input.string(sectorSymbols6, title='', group=SECTOR_GROUP_NAME, inline='S6B')
- show6 = input.bool(false, title=SECTOR_SHOW_NAME, group=SECTOR_GROUP_NAME, inline='S6B')
- c7 = input.color(color7, title='7', group=SECTOR_GROUP_NAME, inline='S7A')
- n7 = input.string(sectorName7, title='', group=SECTOR_GROUP_NAME, inline='S7A')
- s7 = input.symbol(sector7 , title='', group=SECTOR_GROUP_NAME, inline='S7B')
- symbols7 = input.string(sectorSymbols7, title='', group=SECTOR_GROUP_NAME, inline='S7B')
- show7 = input.bool(false, title=SECTOR_SHOW_NAME, group=SECTOR_GROUP_NAME, inline='S7B')
- c8 = input.color(color8, title='8', group=SECTOR_GROUP_NAME, inline='S8A')
- n8 = input.string(sectorName8, title='', group=SECTOR_GROUP_NAME, inline='S8A')
- s8 = input.symbol(sector8 , title='', group=SECTOR_GROUP_NAME, inline='S8B')
- symbols8 = input.string(sectorSymbols8, title='', group=SECTOR_GROUP_NAME, inline='S8B')
- show8 = input.bool(false, title=SECTOR_SHOW_NAME, group=SECTOR_GROUP_NAME, inline='S8B')
- c9 = input.color(color9, title='9', group=SECTOR_GROUP_NAME, inline='S9A')
- n9 = input.string(sectorName9, title='', group=SECTOR_GROUP_NAME, inline='S9A')
- s9 = input.symbol(sector9 , title='', group=SECTOR_GROUP_NAME, inline='S9B')
- symbols9 = input.string(sectorSymbols9, title='', group=SECTOR_GROUP_NAME, inline='S9B')
- show9 = input.bool(false, title=SECTOR_SHOW_NAME, group=SECTOR_GROUP_NAME, inline='S9B')
- c10 = input.color(color10, title='10', group=SECTOR_GROUP_NAME, inline='S10A')
- n10 = input.string(sectorName10, title='', group=SECTOR_GROUP_NAME, inline='S10A')
- s10 = input.symbol(sector10, title='', group=SECTOR_GROUP_NAME, inline='S10B')
- symbols10 = input.string(sectorSymbols10, title='', group=SECTOR_GROUP_NAME, inline='S10B')
- show10 = input.bool(false, title=SECTOR_SHOW_NAME, group=SECTOR_GROUP_NAME, inline='S10B')
- c11 = input.color(color11, title='11', group=SECTOR_GROUP_NAME, inline='S11A')
- n11 = input.string(sectorName11, title='', group=SECTOR_GROUP_NAME, inline='S11A')
- s11 = input.symbol(sector11, title='', group=SECTOR_GROUP_NAME, inline='S11B')
- symbols11 = input.string(sectorSymbols11, title='', group=SECTOR_GROUP_NAME, inline='S11B')
- show11 = input.bool(false, title=SECTOR_SHOW_NAME, group=SECTOR_GROUP_NAME, inline='S11B')
- c12 = input.color(color12, title='12', group=SECTOR_GROUP_NAME, inline='S12A')
- n12 = input.string(sectorName12, title='', group=SECTOR_GROUP_NAME, inline='S12A')
- s12 = input.symbol(sector12, title='', group=SECTOR_GROUP_NAME, inline='S12B')
- symbols12 = input.string(sectorSymbols12, title='', group=SECTOR_GROUP_NAME, inline='S12B')
- show12 = input.bool(false, title=SECTOR_SHOW_NAME, group=SECTOR_GROUP_NAME, inline='S12B')
- c13 = input.color(color13, title='13', group=SECTOR_GROUP_NAME, inline='S13A')
- n13 = input.string(sectorName13, title='', group=SECTOR_GROUP_NAME, inline='S13A')
- s13 = input.symbol(sector13, title='', group=SECTOR_GROUP_NAME, inline='S13B')
- symbols13 = input.string(sectorSymbols13, title='', group=SECTOR_GROUP_NAME, inline='S13B')
- show13 = input.bool(false, title=SECTOR_SHOW_NAME, group=SECTOR_GROUP_NAME, inline='S13B')
- c14 = input.color(color14, title='14', group=SECTOR_GROUP_NAME, inline='S14A')
- n14 = input.string(sectorName14, title='', group=SECTOR_GROUP_NAME, inline='S14A')
- s14 = input.symbol(sector14, title='', group=SECTOR_GROUP_NAME, inline='S14B')
- symbols14 = input.string(sectorSymbols14, title='', group=SECTOR_GROUP_NAME, inline='S14B')
- show14 = input.bool(false, title=SECTOR_SHOW_NAME, group=SECTOR_GROUP_NAME, inline='S14B')
- c15 = input.color(color15, title='15', group=SECTOR_GROUP_NAME, inline='S15A')
- n15 = input.string(sectorName15, title='', group=SECTOR_GROUP_NAME, inline='S15A')
- s15 = input.symbol(sector15, title='', group=SECTOR_GROUP_NAME, inline='S15B')
- symbols15 = input.string(sectorSymbols15, title='', group=SECTOR_GROUP_NAME, inline='S15B')
- show15 = input.bool(false, title=SECTOR_SHOW_NAME, group=SECTOR_GROUP_NAME, inline='S15B')
- c16 = input.color(color16, title='16', group=SECTOR_GROUP_NAME, inline='S16A')
- n16 = input.string(sectorName16, title='', group=SECTOR_GROUP_NAME, inline='S16A')
- s16 = input.symbol(sector16, title='', group=SECTOR_GROUP_NAME, inline='S16B')
- symbols16 = input.string(sectorSymbols16, title='', group=SECTOR_GROUP_NAME, inline='S16B')
- show16 = input.bool(false, title=SECTOR_SHOW_NAME, group=SECTOR_GROUP_NAME, inline='S16B')
- c17 = input.color(color17, title='17', group=SECTOR_GROUP_NAME, inline='S17A')
- n17 = input.string(sectorName17, title='', group=SECTOR_GROUP_NAME, inline='S17A')
- s17 = input.symbol(sector17, title='', group=SECTOR_GROUP_NAME, inline='S17B')
- symbols17 = input.string(sectorSymbols17, title='', group=SECTOR_GROUP_NAME, inline='S17B')
- show17 = input.bool(false, title=SECTOR_SHOW_NAME, group=SECTOR_GROUP_NAME, inline='S17B')
- c18 = input.color(color18, title='18', group=SECTOR_GROUP_NAME, inline='S18A')
- n18 = input.string(sectorName18, title='', group=SECTOR_GROUP_NAME, inline='S18A')
- s18 = input.symbol(sector18, title='', group=SECTOR_GROUP_NAME, inline='S18B')
- symbols18 = input.string(sectorSymbols18, title='', group=SECTOR_GROUP_NAME, inline='S18B')
- show18 = input.bool(false, title=SECTOR_SHOW_NAME, group=SECTOR_GROUP_NAME, inline='S18B')
- c19 = input.color(color19, title='19', group=SECTOR_GROUP_NAME, inline='S19A')
- n19 = input.string(sectorName19, title='', group=SECTOR_GROUP_NAME, inline='S19A')
- s19 = input.symbol(sector19, title='', group=SECTOR_GROUP_NAME, inline='S19B')
- symbols19 = input.string(sectorSymbols19, title='', group=SECTOR_GROUP_NAME, inline='S19B')
- show19 = input.bool(false, title=SECTOR_SHOW_NAME, group=SECTOR_GROUP_NAME, inline='S19B')
- c20 = input.color(color20, title='20', group=SECTOR_GROUP_NAME, inline='S20A')
- n20 = input.string(sectorName20, title='', group=SECTOR_GROUP_NAME, inline='S20A')
- s20 = input.symbol(sector20, title='', group=SECTOR_GROUP_NAME, inline='S20B')
- symbols20 = input.string(sectorSymbols20, title='', group=SECTOR_GROUP_NAME, inline='S20B')
- show20 = input.bool(false, title=SECTOR_SHOW_NAME, group=SECTOR_GROUP_NAME, inline='S20B')
- // ===== Utility Functions =====
- isSymbolInSector(string sectorSymbols) =>
- // replace all commas, pluses and minuses with whitespace then split by whitespace
- symbols = str.split(str.replace_all(str.replace_all(str.replace_all(sectorSymbols, ',', ' '), '+', ' '), '-', ' '), ' ')
- array.indexof(symbols, syminfo.ticker) >= 0
- // ===== RRS =====
- // NOTE:
- // - RRS is the powerIndex of the current symbol minus the powerIndex of the baseline/sector
- // - A higher (lower) powerIndex to the baseline/sector means relative strength (weakness)
- // - Because we're plotting the symbol, baseline and sector together, we show each powerIndex instead of RRS
- calcPowerIndex(series float src, series float atr) =>
- symbolRollingMove = src - src[periodPC]
- symbolPowerIndex = symbolRollingMove / atr[1]
- // current + baseline
- powerIndex = calcPowerIndex(close, ta.atr(periodATR))
- [src0, atr0] = request.security(symbol=baseline, timeframe="", expression=[src, ta.atr(periodATR)])
- powerIndex0 = calcPowerIndex(src0, atr0)
- // sectors
- var plot1 = str.length(s1) > 0 and (showAll or show1 or isSymbolInSector(symbols1))
- [src1, atr1 ] = request.security(symbol=s1, timeframe="", expression=[src, ta.atr(periodATR)])
- powerIndex1 = calcPowerIndex(plot1 ? src1 : na, plot1 ? atr1 : na)
- var plot2 = str.length(s2) > 0 and (showAll or show2 or isSymbolInSector(symbols2))
- [src2, atr2 ] = request.security(symbol=s2, timeframe="", expression=[src, ta.atr(periodATR)])
- powerIndex2 = calcPowerIndex(plot2 ? src2 : na, plot2 ? atr2 : na)
- var plot3 = str.length(s3) > 0 and (showAll or show3 or isSymbolInSector(symbols3))
- [src3, atr3 ] = request.security(symbol=s3, timeframe="", expression=[src, ta.atr(periodATR)])
- powerIndex3 = calcPowerIndex(plot3 ? src3 : na, plot3 ? atr3 : na)
- var plot4 = str.length(s4) > 0 and (showAll or show4 or isSymbolInSector(symbols4))
- [src4, atr4 ] = request.security(symbol=s4, timeframe="", expression=[src, ta.atr(periodATR)])
- powerIndex4 = calcPowerIndex(plot4 ? src4 : na, plot4 ? atr4 : na)
- var plot5 = str.length(s5) > 0 and (showAll or show5 or isSymbolInSector(symbols5))
- [src5, atr5 ] = request.security(symbol=s5, timeframe="", expression=[src, ta.atr(periodATR)])
- powerIndex5 = calcPowerIndex(plot5 ? src5 : na, plot5 ? atr5 : na)
- var plot6 = str.length(s6) > 0 and (showAll or show6 or isSymbolInSector(symbols6))
- [src6, atr6 ] = request.security(symbol=s6, timeframe="", expression=[src, ta.atr(periodATR)])
- powerIndex6 = calcPowerIndex(plot6 ? src6 : na, plot6 ? atr6 : na)
- var plot7 = str.length(s7) > 0 and (showAll or show7 or isSymbolInSector(symbols7))
- [src7, atr7 ] = request.security(symbol=s7, timeframe="", expression=[src, ta.atr(periodATR)])
- powerIndex7 = calcPowerIndex(plot7 ? src7 : na, plot7 ? atr7 : na)
- var plot8 = str.length(s8) > 0 and (showAll or show8 or isSymbolInSector(symbols8))
- [src8, atr8 ] = request.security(symbol=s8, timeframe="", expression=[src, ta.atr(periodATR)])
- powerIndex8 = calcPowerIndex(plot8 ? src8 : na, plot8 ? atr8 : na)
- var plot9 = str.length(s9) > 0 and (showAll or show9 or isSymbolInSector(symbols9))
- [src9, atr9 ] = request.security(symbol=s9, timeframe="", expression=[src, ta.atr(periodATR)])
- powerIndex9 = calcPowerIndex(plot9 ? src9 : na, plot9 ? atr9 : na)
- var plot10 = str.length(s10) > 0 and (showAll or show10 or isSymbolInSector(symbols10))
- [src10, atr10] = request.security(symbol=s10, timeframe="", expression=[src, ta.atr(periodATR)])
- powerIndex10 = calcPowerIndex(plot10 ? src10 : na, plot10 ? atr10 : na)
- var plot11 = str.length(s11) > 0 and (showAll or show11 or isSymbolInSector(symbols11))
- [src11, atr11] = request.security(symbol=s11, timeframe="", expression=[src, ta.atr(periodATR)])
- powerIndex11 = calcPowerIndex(plot11 ? src11 : na, plot11 ? atr11 : na)
- var plot12 = str.length(s12) > 0 and (showAll or show12 or isSymbolInSector(symbols12))
- [src12, atr12] = request.security(symbol=s12, timeframe="", expression=[src, ta.atr(periodATR)])
- powerIndex12 = calcPowerIndex(plot12 ? src12 : na, plot12 ? atr12 : na)
- var plot13 = str.length(s13) > 0 and (showAll or show13 or isSymbolInSector(symbols13))
- [src13, atr13] = request.security(symbol=s13, timeframe="", expression=[src, ta.atr(periodATR)])
- powerIndex13 = calcPowerIndex(plot13 ? src13 : na, plot13 ? atr13 : na)
- var plot14 = str.length(s14) > 0 and (showAll or show14 or isSymbolInSector(symbols14))
- [src14, atr14] = request.security(symbol=s14, timeframe="", expression=[src, ta.atr(periodATR)])
- powerIndex14 = calcPowerIndex(plot14 ? src14 : na, plot14 ? atr14 : na)
- var plot15 = str.length(s15) > 0 and (showAll or show15 or isSymbolInSector(symbols15))
- [src15, atr15] = request.security(symbol=s15, timeframe="", expression=[src, ta.atr(periodATR)])
- powerIndex15 = calcPowerIndex(plot15 ? src15 : na, plot15 ? atr15 : na)
- var plot16 = str.length(s16) > 0 and (showAll or show16 or isSymbolInSector(symbols16))
- [src16, atr16] = request.security(symbol=s16, timeframe="", expression=[src, ta.atr(periodATR)])
- powerIndex16 = calcPowerIndex(plot16 ? src16 : na, plot16 ? atr16 : na)
- var plot17 = str.length(s17) > 0 and (showAll or show17 or isSymbolInSector(symbols17))
- [src17, atr17] = request.security(symbol=s17, timeframe="", expression=[src, ta.atr(periodATR)])
- powerIndex17 = calcPowerIndex(plot17 ? src17 : na, plot17 ? atr17 : na)
- var plot18 = str.length(s18) > 0 and (showAll or show18 or isSymbolInSector(symbols18))
- [src18, atr18] = request.security(symbol=s18, timeframe="", expression=[src, ta.atr(periodATR)])
- powerIndex18 = calcPowerIndex(plot18 ? src18 : na, plot18 ? atr18 : na)
- var plot19 = str.length(s19) > 0 and (showAll or show19 or isSymbolInSector(symbols19))
- [src19, atr19] = request.security(symbol=s19, timeframe="", expression=[src, ta.atr(periodATR)])
- powerIndex19 = calcPowerIndex(plot19 ? src19 : na, plot19 ? atr19 : na)
- var plot20 = str.length(s20) > 0 and (showAll or show20 or isSymbolInSector(symbols20))
- [src20, atr20] = request.security(symbol=s20, timeframe="", expression=[src, ta.atr(periodATR)])
- powerIndex20 = calcPowerIndex(plot20 ? src20 : na, plot20 ? atr20 : na)
- // ===== Visuals =====
- // current + baseline
- // color.new() to disable style color customization because changing colors there won't affect sector tags
- //plot(powerIndex, title='Current', color=color.new(colorCurrent, 1), linewidth=2)
- //plot(powerIndex0, title='Baseline', color=colorBaseline)
- //hline(0, title="Center", color=color.gray, linestyle=hline.style_dotted)
- // sectors
- //plot(powerIndex1, title='S1', color=c1)
- //plot(powerIndex2, title='S2', color=c2)
- //plot(powerIndex3, title='S3', color=c3)
- //plot(powerIndex4, title='S4', color=c4)
- //plot(powerIndex5, title='S5', color=c5)
- //plot(powerIndex6, title='S6', color=c6)
- //plot(powerIndex7, title='S7', color=c7)
- //plot(powerIndex8, title='S8', color=c8)
- //plot(powerIndex9, title='S9', color=c9)
- //plot(powerIndex10, title='S10', color=c10)
- //plot(powerIndex11, title='S11', color=c11)
- //plot(powerIndex12, title='S12', color=c12)
- //plot(powerIndex13, title='S13', color=c13)
- //plot(powerIndex14, title='S14', color=c14)
- //plot(powerIndex15, title='S15', color=c15)
- //plot(powerIndex16, title='S16', color=c16)
- //plot(powerIndex17, title='S17', color=c17)
- //plot(powerIndex18, title='S18', color=c18)
- //plot(powerIndex19, title='S19', color=c19)
- //plot(powerIndex20, title='S20', color=c20)
- // ===== Visuals (Sector Tags) =====
- // sectors
- var string[] activeSectors = array.new_string()
- var color[] activeColors = array.new_color()
- if barstate.isfirst
- if plot1
- array.push(activeSectors, str.length(n1) > 0 ? n1 : syminfo.ticker(s1))
- array.push(activeColors, c1)
- if plot2
- array.push(activeSectors, str.length(n2) > 0 ? n2 : syminfo.ticker(s2))
- array.push(activeColors, c2)
- if plot3
- array.push(activeSectors, str.length(n3) > 0 ? n3 : syminfo.ticker(s3))
- array.push(activeColors, c3)
- if plot4
- array.push(activeSectors, str.length(n4) > 0 ? n4 : syminfo.ticker(s4))
- array.push(activeColors, c4)
- if plot5
- array.push(activeSectors, str.length(n5) > 0 ? n5 : syminfo.ticker(s5))
- array.push(activeColors, c5)
- if plot6
- array.push(activeSectors, str.length(n6) > 0 ? n6 : syminfo.ticker(s6))
- array.push(activeColors, c6)
- if plot7
- array.push(activeSectors, str.length(n7) > 0 ? n7 : syminfo.ticker(s7))
- array.push(activeColors, c7)
- if plot8
- array.push(activeSectors, str.length(n8) > 0 ? n8 : syminfo.ticker(s8))
- array.push(activeColors, c8)
- if plot9
- array.push(activeSectors, str.length(n9) > 0 ? n9 : syminfo.ticker(s9))
- array.push(activeColors, c9)
- if plot10
- array.push(activeSectors, str.length(n10) > 0 ? n10 : syminfo.ticker(s10))
- array.push(activeColors, c10)
- if plot11
- array.push(activeSectors, str.length(n11) > 0 ? n11 : syminfo.ticker(s11))
- array.push(activeColors, c11)
- if plot12
- array.push(activeSectors, str.length(n12) > 0 ? n12 : syminfo.ticker(s12))
- array.push(activeColors, c12)
- if plot13
- array.push(activeSectors, str.length(n13) > 0 ? n13 : syminfo.ticker(s13))
- array.push(activeColors, c13)
- if plot14
- array.push(activeSectors, str.length(n14) > 0 ? n14 : syminfo.ticker(s14))
- array.push(activeColors, c14)
- if plot15
- array.push(activeSectors, str.length(n15) > 0 ? n15 : syminfo.ticker(s15))
- array.push(activeColors, c15)
- if plot16
- array.push(activeSectors, str.length(n16) > 0 ? n16 : syminfo.ticker(s16))
- array.push(activeColors, c16)
- if plot17
- array.push(activeSectors, str.length(n17) > 0 ? n17 : syminfo.ticker(s17))
- array.push(activeColors, c17)
- if plot18
- array.push(activeSectors, str.length(n18) > 0 ? n18 : syminfo.ticker(s18))
- array.push(activeColors, c18)
- if plot19
- array.push(activeSectors, str.length(n19) > 0 ? n19 : syminfo.ticker(s19))
- array.push(activeColors, c19)
- if plot20
- array.push(activeSectors, str.length(n20) > 0 ? n20 : syminfo.ticker(s20))
- array.push(activeColors, c20)
- var sectorTag = table.new(position=position.bottom_right, columns=array.size(activeSectors), rows=1, border_width=0)
- if barstate.isfirst
- int i = 0
- while i < array.size(activeSectors)
- table.cell(sectorTag, column=i, row=0, text=array.get(activeSectors, i), text_color=array.get(activeColors, i))
- i := i+1
- //BarColor Plot:
- long1 = powerIndex > powerIndex0 and powerIndex1 > powerIndex0 and powerIndex > powerIndex1 and isSymbolInSector(symbols1)
- short1 = powerIndex < powerIndex0 and powerIndex1 < powerIndex0 and powerIndex < powerIndex1 and isSymbolInSector(symbols1)
- long2 = powerIndex > powerIndex0 and powerIndex2 > powerIndex0 and powerIndex > powerIndex2 and isSymbolInSector(symbols2)
- short2 = powerIndex < powerIndex0 and powerIndex2 < powerIndex0 and powerIndex < powerIndex2 and isSymbolInSector(symbols2)
- long3 = powerIndex > powerIndex0 and powerIndex3 > powerIndex0 and powerIndex > powerIndex3 and isSymbolInSector(symbols3)
- short3 = powerIndex < powerIndex0 and powerIndex3 < powerIndex0 and powerIndex < powerIndex3 and isSymbolInSector(symbols3)
- long4 = powerIndex > powerIndex0 and powerIndex4 > powerIndex0 and powerIndex > powerIndex4 and isSymbolInSector(symbols4)
- short4 = powerIndex < powerIndex0 and powerIndex4 < powerIndex0 and powerIndex < powerIndex4 and isSymbolInSector(symbols4)
- long5 = powerIndex > powerIndex0 and powerIndex5 > powerIndex0 and powerIndex > powerIndex5 and isSymbolInSector(symbols5)
- short5 = powerIndex < powerIndex0 and powerIndex5 < powerIndex0 and powerIndex < powerIndex5 and isSymbolInSector(symbols5)
- long6 = powerIndex > powerIndex0 and powerIndex6 > powerIndex0 and powerIndex > powerIndex6 and isSymbolInSector(symbols6)
- short6 = powerIndex < powerIndex0 and powerIndex6 < powerIndex0 and powerIndex < powerIndex6 and isSymbolInSector(symbols6)
- long7 = powerIndex > powerIndex0 and powerIndex7 > powerIndex0 and powerIndex > powerIndex7 and isSymbolInSector(symbols7)
- short7 = powerIndex < powerIndex0 and powerIndex7 < powerIndex0 and powerIndex < powerIndex7 and isSymbolInSector(symbols7)
- long8 = powerIndex > powerIndex0 and powerIndex8 > powerIndex0 and powerIndex > powerIndex8 and isSymbolInSector(symbols8)
- short8 = powerIndex < powerIndex0 and powerIndex8 < powerIndex0 and powerIndex < powerIndex8 and isSymbolInSector(symbols8)
- long9 = powerIndex > powerIndex0 and powerIndex9 > powerIndex0 and powerIndex > powerIndex9 and isSymbolInSector(symbols9)
- short9 = powerIndex < powerIndex0 and powerIndex9 < powerIndex0 and powerIndex < powerIndex9 and isSymbolInSector(symbols9)
- long10 = powerIndex > powerIndex0 and powerIndex10 > powerIndex0 and powerIndex > powerIndex10 and isSymbolInSector(symbols10)
- short10 = powerIndex < powerIndex0 and powerIndex10 < powerIndex0 and powerIndex < powerIndex10 and isSymbolInSector(symbols10)
- long11 = powerIndex > powerIndex0 and powerIndex11 > powerIndex0 and powerIndex > powerIndex11 and isSymbolInSector(symbols11)
- short11 = powerIndex < powerIndex0 and powerIndex11 < powerIndex0 and powerIndex < powerIndex11 and isSymbolInSector(symbols11)
- long12 = powerIndex > powerIndex0 and powerIndex12 > powerIndex0 and powerIndex > powerIndex12 and isSymbolInSector(symbols12)
- short12 = powerIndex < powerIndex0 and powerIndex2 < powerIndex0 and powerIndex < powerIndex2 and isSymbolInSector(symbols2)
- //barcolor(long1 or long2 or long3 or long4 or long5 or long6 or long7 or long8 or long9 or long10 or long11 or long12 ? color.yellow : short1 or short2 or short3 or short4 or short5 or short6 or short7 or short8 or short9 or short10 or short11 or short12 ? color.purple: na)
- vwap = ta.vwap
- vwapup = close > ta.vwap
- vwapdown = close < ta.vwap
- plotshape((long1 or long2 or long3 or long4 or long5 or long6 or long7 or long8 or long9 or long10 or long11 or long12) and vwapup, "Long", shape.arrowup, location.belowbar, color.green)
- plotshape((short1 or short2 or short3 or short4 or short5 or short6 or short7 or short8 or short9 or short10 or short11 or short12) and vwapdown, "Short", shape.arrowdown, location.abovebar, color.red)
- //plotshape("Long", shape.arrowup, location.belowbar, color.green)
- //plotshape("Short", shape.arrowdown, location.abovebar, color.red)
[text] Real Relative Sector Strength Arrows
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: