Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- indicator(title="INVEST BTC RSI (from @tradinglord)", shorttitle="INVEST BTC RSI", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
- // worked out from "The rational monkey who outperforms most investors"
- // and "Sometimes it's better to be rational monkey than a greedy baboon" - Tradinglord 2022
- rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")
- rsiSourceInput = input.source(close, "Source", group="RSI Settings")
- rsi_high = input(80)
- rsi_low = input(35)
- rsi_middle = input(50)
- up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
- down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
- rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
- c_white = color.new(color.white, 50)
- c_green = color.new(#32CD32, 0)
- c_red = color.new(#FF0000, 0)
- rsi_color = rsi < rsi_low ? c_green : rsi > rsi_high ? c_red : ta.crossover(rsi, rsi_middle) or ta.crossunder(rsi, rsi_middle) ? color.orange : c_white
- plot(rsi, "RSI", color=rsi_color, linewidth=3)
- rsiUpperBand = hline(rsi_high, "RSI Upper Band", color=#787B86)
- hline(rsi_middle, "RSI Middle Band", color=color.new(#787B86, 50))
- rsiLowerBand = hline(rsi_low, "RSI Lower Band", color=#787B86)
Advertisement
Add Comment
Please, Sign In to add comment