LazyBear

Keltner Channel with auto highlighting of Bear/Bull reversals

*** New version @ ****

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
Mã nguồn mở

Với tinh thần TradingView, tác giả của tập lệnh này đã xuất bản nó dưới dạng mã nguồn mở, vì vậy các nhà giao dịch có thể hiểu và xác minh nó. Chúc mừng tác giả! Bạn có thể sử dụng mã này miễn phí, nhưng việc sử dụng lại mã này trong một ấn phẩm chịu sự điều chỉnh của Nội quy nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?
// @author LazyBear
// @credits Formula taken from http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:keltner_channels
//
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 reversals?", 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_reversal = high > upperVal 
bear_point = bearish_reversal ? (high+offset) : na
bear_color = bearish_reversal ? red : na

bullish_reversal = low < lowerVal
bull_point = bullish_reversal ? (low-offset) : na
bull_color = bullish_reversal ? green : na

bar_color = bearish_reversal ? bear_color : (bullish_reversal ? 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)