LazyBear

Keltner Channel v2 - Auto highlighting of Bull/Bear trends

460
Please do not use the previous version (www.tradingview.com/v/WH1PVDTO/), I was using wrong colors for Bull/Bear there.

All options configurable.

Reversals are marked using crosses. as well as highlighted using green/red color (depending on bull/bear). Enjoy!


List of my free indicators: bit.ly/1LQaPK8
List of my indicators at Appstore: blog.tradingview.com/?p=970
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?
//
// @author LazyBear
// @credits Formula taken from http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:keltner_channels
// v02 - fixed the bull/bear colors, I accidentally switched them in the prev ver. 
// v01 - initial release
//
study(title="Keltner Channel [LazyBear]", overlay=true)
offset = 1
lengthMiddle = input(20,  title="MiddleEMA")
channelATR = input(10, title="Channel wall ATR")
channelWidth = input(2, title = "Channel Width")
showBarColor = input(true, title="Highlight Bear/Bull indicators?", type=bool)

emaVal = ema(close,lengthMiddle)
upperVal = emaVal + channelWidth * atr(channelATR)
lowerVal = emaVal - channelWidth * atr(channelATR)

middle_line = plot(emaVal, style=circles, linewidth=2)
upper_line = plot(upperVal)
lower_line = plot(lowerVal)
fill(upper_line, lower_line, color=green, transp=80)

bearish = low < lowerVal
bear_point = bearish ? (low-offset) : na
bear_color = bearish ? red : na

bullish = high > upperVal 
bull_point = bullish ? (high+offset) : na
bull_color = bullish ? green : na

bar_color = bearish ? bear_color : (bullish ? bull_color : na)

plot(bear_point, color = bear_color, style=cross, linewidth=2)
plot(bull_point, color = bull_color, style=cross, linewidth=2)

bgcolor(showBarColor ? bar_color : na)