Madrid

Madrid Slide

1292
This study shows the linear regression in a way to easily spot trends, S/R levels, reversals, choppiness, trading ranges, patterns, flags.

This script requires very few and easy to understand parameters, the length of analysis and the width of the slide. The default values are good for most scenarios.

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?
// Madrid : 28/lrcy/2015 23:00 : Slide : 1.0
// This study shows the linear regression in an easy visual way
// to spot S/R points, reversals, choppiness, range trading, patterns
//

study("Madrid Slide", shorttitle="MSlide", overlay=true)
src = hl2
len=input(13)
w = input(defval=4, title="width", minval=1, maxval=7, step=1)
lrc = linreg(src, len, 0)

lrcColor=change(lrc) >= 0 ? lime:red

plot(lrc, color=lrcColor, linewidth=3)

plot(w>=7?lrc:na, offset=7, color=lrcColor)
plot(w>=6?lrc:na, offset=6, color=lrcColor)
plot(w>=5?lrc:na, offset=5, color=lrcColor)
plot(w>=4?lrc:na, offset=4, color=lrcColor)
plot(w>=3?lrc:na, offset=3, color=lrcColor)
plot(w>=2?lrc:na, offset=2, color=lrcColor)
plot(w>=1?lrc:na, offset=1, color=lrcColor)

plot(w>=7?lrc:na, offset=-7, color=lrcColor)
plot(w>=6?lrc:na, offset=-6, color=lrcColor)
plot(w>=5?lrc:na, offset=-5, color=lrcColor)
plot(w>=4?lrc:na, offset=-4, color=lrcColor)
plot(w>=3?lrc:na, offset=-3, color=lrcColor)
plot(w>=2?lrc:na, offset=-2, color=lrcColor)
plot(w>=1?lrc:na, offset=-1, color=lrcColor)