//////////////////////////////////////////////////////////////////////////
// Settings for 5min chart, BTCUSDC. For Other coin, change the paremeters
//////////////////////////////////////////////////////////////////////////
study(title="Range Filter 5min", overlay=true)
// Source
src = input(defval=close, title="Source")
// Sampling Period
// Settings for 5min chart, BTCUSDC. For Other coin, change the paremeters
per = input(defval=100, minval=1, title="Sampling Period")
// Range Multiplier
mult = input(defval=3.0, minval=0.1, title="Range Multiplier")
// Smooth Average Range
smoothrng(x, t, m) =>
wper = t * 2 - 1
avrng = ema(abs(x - x[1]), t)
smoothrng = ema(avrng, wper) * m
smoothrng
smrng = smoothrng(src, per, mult)
// Range Filter
rngfilt(x, r) =>
rngfilt = x
rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r :
x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r
rngfilt
filt = rngfilt(src, smrng)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.