soru

LRx2 MAx2

21
modified version now:) + ema,sma option fixed
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?
study("LRx2 MAx2",overlay=true)
Len=input(200)
LR_offset=input(0)
ema= input(defval=false,title='use ema instead of sma?')
show_2xMA = input(true)
show_2xLR = input(true)
ma1 = ema ? ema(high,Len) : sma(high,Len)
ma2 = ema ? ema(low,Len) : sma(low,Len)
plot(show_2xMA ? ma1:na,color=#6666ff, linewidth=2)
plot(show_2xMA ? ma2: na,color=#6666ff, linewidth=2)
z1=linreg(high,Len,LR_offset)
z2=linreg(low,Len,LR_offset)

col=z1>z1[1]? lime : red
col2=z2>z2[1]? lime : red
plot(show_2xLR ? z1 : na,color=col)
plot(show_2xLR? z2 : na,color=col2)