本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// © Bjorgum
//@version=4
study("Heiken Ashi Candle Overlay", "HA Overlay", true)
// Optional Mathmatical Calcualtion to avoid the security function
//hkClose = (open + high + low + close) / 4
//hkOpen = float(na)
//hkOpen := na(haOpen[1]) ? (open + close) / 2 : (nz(haOpen[1]) + nz(haClose[1])) / 2
//hkHigh = max(high, max(haOpen, haClose))
//hkLow = min(low, min(haOpen, haClose))
[hkOpen, hkHigh, hkLow, hkClose] = security(heikinashi(syminfo.tickerid), timeframe.period, [open, high, low, close])
candletype = input ("Hollow", "Candle Type", options=["Hollow", "Bars", "Candles"], group="Heiken Ashi Candle Overlay", tooltip="Candle Type to be dispalyed. User will have to 'Mute' the main series bar using the 👁 symbol next to ticker id.")
BodyBull = input (#26a69a, "", input.color, inline="a", group="Candle Body")
BodyBear = input (#ef5350, "", input.color, inline="a", group="Candle Body")
BorderBull = input (#26a69a, "", input.color, inline="b", group="Candle Borders")
BorderBear = input (#ef5350, "", input.color, inline="b", group="Candle Borders")
WickBull = input (#26a69a, "", input.color, inline="c", group="Candle Wick")
WickBear = input (#ef5350, "", input.color, inline="c", group="Candle Wick")
hollow = candletype == "Hollow"
bars = candletype == "Bars"
candle = candletype == "Candles"
plotcandle(
hkOpen, hkHigh, hkLow, hkClose,
"Hollow Candles",
hollow ? hkClose < hkOpen ? BodyBear : na : candle ? hkClose < hkOpen ? BodyBear : BodyBull : na,
hollow or candle ? hkClose < hkOpen ? WickBear : WickBull : na,
bordercolor = hollow or candle ? hkClose < hkOpen ? BorderBear : BorderBull : na)
plotbar(
hkOpen, hkHigh, hkLow, hkClose,
"Bars",
bars ? hkClose < hkOpen ? BodyBear : BodyBull : na)