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/
- // © HeWhoMustNotBeNamed
- // __ __ __ __ __ __ __ __ __ __ __ _______ __ __ __
- // / | / | / | _ / |/ | / \ / | / | / \ / | / | / \ / \ / | / |
- // $$ | $$ | ______ $$ | / \ $$ |$$ |____ ______ $$ \ /$$ | __ __ _______ _$$ |_ $$ \ $$ | ______ _$$ |_ $$$$$$$ | ______ $$ \ $$ | ______ _____ ____ ______ ____$$ |
- // $$ |__$$ | / \ $$ |/$ \$$ |$$ \ / \ $$$ \ /$$$ |/ | / | / |/ $$ | $$$ \$$ | / \ / $$ | $$ |__$$ | / \ $$$ \$$ | / \ / \/ \ / \ / $$ |
- // $$ $$ |/$$$$$$ |$$ /$$$ $$ |$$$$$$$ |/$$$$$$ |$$$$ /$$$$ |$$ | $$ |/$$$$$$$/ $$$$$$/ $$$$ $$ |/$$$$$$ |$$$$$$/ $$ $$< /$$$$$$ |$$$$ $$ | $$$$$$ |$$$$$$ $$$$ |/$$$$$$ |/$$$$$$$ |
- // $$$$$$$$ |$$ $$ |$$ $$/$$ $$ |$$ | $$ |$$ | $$ |$$ $$ $$/$$ |$$ | $$ |$$ \ $$ | __ $$ $$ $$ |$$ | $$ | $$ | __ $$$$$$$ |$$ $$ |$$ $$ $$ | / $$ |$$ | $$ | $$ |$$ $$ |$$ | $$ |
- // $$ | $$ |$$$$$$$$/ $$$$/ $$$$ |$$ | $$ |$$ \__$$ |$$ |$$$/ $$ |$$ \__$$ | $$$$$$ | $$ |/ |$$ |$$$$ |$$ \__$$ | $$ |/ |$$ |__$$ |$$$$$$$$/ $$ |$$$$ |/$$$$$$$ |$$ | $$ | $$ |$$$$$$$$/ $$ \__$$ |
- // $$ | $$ |$$ |$$$/ $$$ |$$ | $$ |$$ $$/ $$ | $/ $$ |$$ $$/ / $$/ $$ $$/ $$ | $$$ |$$ $$/ $$ $$/ $$ $$/ $$ |$$ | $$$ |$$ $$ |$$ | $$ | $$ |$$ |$$ $$ |
- // $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$/ $$$$$$/ $$/ $$/ $$$$$$/ $$$$$$$/ $$$$/ $$/ $$/ $$$$$$/ $$$$/ $$$$$$$/ $$$$$$$/ $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$$$$$$/ $$$$$$$/
- //
- //
- //
- //@version=4
- study("RSI - Dynamic Overbought/Oversold Range", shorttitle="RSI-DR")
- resolution = input("", type=input.resolution, title="Resolution", group="RSI")
- source = input(close, title="Source", group="RSI")
- length = input(14, title="Length", group="RSI")
- repaint = input(true, title="Repaint", group="RSI")
- method = input("swma", title="Detection Method", group = "Overbought/Oversold Range", options=["highlow", "sma", "ema", "rma", "hma", "wma", "vwma", "swma"])
- rangeLength = input(50, step=10, title="Length", group="Overbought/Oversold Range")
- f_security(_sym, _res, _src, _rep) => security(_sym, _res, _src[not _rep and barstate.isrealtime ? 1 : 0])[_rep or barstate.isrealtime ? 0 : 1]
- f_get_ma(source, method, rangeLength)=>
- method == "sma" ? sma(source,rangeLength) :
- method == "ema" ? ema(source,rangeLength) :
- method == "rma" ? rma(source,rangeLength) :
- method == "hma" ? hma(source,rangeLength) :
- method == "wma" ? wma(source,rangeLength) :
- method == "vwma" ? vwma(source,rangeLength) :
- method == "swma" ? swma(source) :
- method == "high"? highest(source, rangeLength) :
- method == "low" ? lowest(source, rangeLength) : na
- f_rsi_high(source, length, method, rangeLength)=> f_get_ma(highest(rsi(source, length), rangeLength), method == "highlow" ? "low" : method, length)
- f_rsi_low(source, length, method, rangeLength)=> f_get_ma(lowest(rsi(source, length), rangeLength), method == "highlow" ? "high" : method, length)
- rsi = f_security(syminfo.tickerid, resolution, rsi(source, length), repaint)
- rsiHigh = f_security(syminfo.tickerid, resolution, f_rsi_high(source, length, method, rangeLength), repaint)
- rsiLow = f_security(syminfo.tickerid, resolution, f_rsi_low(source, length, method, rangeLength), repaint)
- highSma = sma(highest(rsi, rangeLength), length)
- lowSma = sma(lowest(rsi, rangeLength), length)
- plot(rsi, title="RSI", color=color.blue)
- plot(rsiHigh, title="Overbought", color=color.red)
- plot(rsiLow, title="Oversold", color=color.green)
Advertisement
Add Comment
Please, Sign In to add comment