RicardoSantos

[RS]Linear Regression Bands V2

EXPERIMENTAL:
added titles to inputs and plots for better understanding what is what(DCC)
M = middle, T = top, B = bottom, S = signal.
开源脚本

本着真正的TradingView精神,该脚本的作者将其开源发布,以便交易者可以理解和验证它。为作者喝彩!您可以免费使用它,但在出版物中重复使用此代码受网站规则的约束。 您可以收藏它以在图表上使用。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?
study(title="[RS]Linear Regression Bands V2", shorttitle="LRB", overlay=true)
decay_ratio = input(title='Decay ratio:', type=float, defval=0.125)
smooth = input(title='Smoothing:', type=integer, defval=4)

prehh1 = nz(hh1[1], high)
prell1 = nz(ll1[1], low)

hh1 = close >= prehh1 ? high : prehh1 - sma(abs(change(high, 1)*decay_ratio), smooth)
ll1 = close <= prell1 ? low : prell1 + sma(abs(change(low, 1)*decay_ratio), smooth)
midline = avg(hh1, ll1)
plot(title='M', series=midline, style=cross, color=black, linewidth=1)
ph1 = plot(title='T', series=hh1, style=line, color=black, linewidth=1)
pl1 = plot(title='B', series=ll1, style=line, color=black, linewidth=1)

margin = input(title='Signal margin:', type=float, defval=30.0) * syminfo.mintick
signalcolor = high-margin > hh1 ? maroon : low+margin < ll1 ? green : gray
signal = high-margin > hh1 ? high+margin : low+margin < ll1 ? low-margin : na
plot(title='S', series=signal, style=circles, color=signalcolor, linewidth=4)