Experimental: a liltle experience with multiple systems, ma, linear regression, correlation and range analysis.
study(title="exp", shorttitle="exp", overlay=true) length = input(12) perc = input(12.5) src = input(close) _atr = cum(tr)/(n+1) //_atr = atr(length) //p_median = nz(median[1], close) //median = tr < _atr ? (p_median + close)/2 : close > open ? p_median + _atr : p_median - _atr //plot(median, color=black) _ema = ema(src, length) _lr = linreg(src, length, 0) _nlr = _ema - (_lr-_ema) upper = percentile_nearest_rank(close, length, 100-perc) lower = percentile_linear_interpolation(close, length, perc) plot(upper, style=cross, color=maroon) plot(lower, style=cross, color=green) plot(_ema, color=black) plot(_lr, color=olive, linewidth=2) plot(_nlr, color=orange, linewidth=2) cor = correlation(close,_ema, 4) barcolor(cor > 0 and close > _ema ? close > open ? lime : green : cor > 0 and close < _ema ? close > open ? red : maroon : close > open ? silver : gray) top = (high - max(close, open)) > tr*0.5 and tr > _atr bot = (min(close, open)-low) > tr*0.5 and tr > _atr plotshape(top, style=shape.square, color=maroon, location=location.abovebar) plotshape(bot, style=shape.square, color=green, location=location.belowbar)