Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © kevindcarr
- //@version=4
- study(title="Relative Strength Index with Range Shift", shorttitle="RSI", overlay=false)
- var table conditionTable = table.new(position=position.top_right, columns=1, rows=1)
- range = input(title="Range Bias", type=input.string, options=["Bullish", "Strong Bullish", "Bearish", "Strong Bearish", "No Bias"], defval="Bullish")
- lookbackPeriod = input(title="Lookback Period", type=input.integer, defval=14)
- source = input(title="Source", type=input.source, defval=close)
- rangeShift(range) =>
- if (range == "Bullish")
- [40, 60, 80]
- else if (range == "Strong Bullish")
- [60, 70, 80]
- else if (range == "Bearish")
- [30, 45, 60]
- else if (range == "Strong Bearish")
- [30, 40, 50]
- else
- [30, 50, 70]
- condition(rsi, range) =>
- [lo, mid, hi] = rangeShift(range)
- if (rsi < lo)
- [ color.green, "Very Oversold" ]
- else if (rsi < mid)
- [ color.yellow, "Oversold" ]
- else if (rsi < hi)
- [ color.orange, "Overbought" ]
- else
- [ color.red, "Very Overbought" ]
- rsi = rsi(source, lookbackPeriod)
- [col, txt] = condition(rsi, range)
- table.cell(conditionTable, 0, 0, text=txt, bgcolor=col)
- plot(series=rsi, title="Relative Strength Index", color=col)
Advertisement
Add Comment
Please, Sign In to add comment