Madrid

Madrid Donchian Channel

This study is based on the Donchian Channel. The idea is to show where the price is located referred to its recent highest and lowest values.
Donchian channel only displays one channel with two bands. This variation displays four bands. When the price is in the uppermost band it is bullish, when the price is in the lowest band it is bearish.
When the price is on either of these two extreme bands it is in a trending market. When it is bouncing around the midchannel line it is a trading market.
The channel lines change color according to the direction of the price.

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?
// Hector R. Madrid : 6/JUN/2014 : 15:35 : 2.0 : Donchian Channel
//
study("Madrid Donchian Channel", shorttitle="MDonCh", overlay=true)
src = close

length = input(13, "Length")

highestBar=highest(high, length)
lowestBar=lowest(low, length)
midBar=(highestBar+lowestBar)/2

// Output
channelColor = abs(highestBar-src) < abs(lowestBar-src) ? green : red
midChannel=plot(midBar, color=channelColor, style=line, linewidth=1)

upperChannel=plot(highestBar, color=channelColor, style=line, linewidth=1 )
lowerChannel=plot(lowestBar, color=channelColor, style=line, linewidth=1 )

upperMidChannel=plot(midBar+(highestBar-midBar)*0.5, style=line, linewidth=1, color=channelColor)
lowerMidChannel=plot(midBar-(midBar-lowestBar)*0.5, style=line, linewidth=1, color=channelColor)

fill(midChannel,upperChannel, color=green, transp=80)
fill(lowerChannel, midChannel, color=red, transp=80)

fill(upperMidChannel, upperChannel, color=green, transp=80)
fill(lowerChannel, lowerMidChannel, color=red, transp=80)