本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © QuantiLuxe
//@version=5
indicator("On Balance Volume Heikin-Ashi", "{Ʌ} - 𝘖𝘉𝘝 𝘏-𝘈", true, scale = scale.none)
f_obv(src) =>
dir = math.sign(close - open)
ta.cum(dir == 1 ? volume * src : dir == -1 ? -volume * src : 0)
ma1 = input.bool(true, "EMA |", inline = "1")
len1 = input.int(20, "Length", inline = "1")
ma2 = input.bool(true, "EMA |", inline = "2")
len2 = input.int(50, "Length", inline = "2")
norm = input.bool(false, "Normalize |", inline = "3")
len3 = input.int(21, "Period", inline = "3")
obv = norm ? f_obv(ohlc4) - ta.ema(f_obv(ohlc4), len3) : f_obv(ohlc4)
o_obv = obv[1]
h_obv = math.max(obv, obv[1])
l_obv = math.min(obv, obv[1])
c_obv = obv
haClose = (o_obv + h_obv + l_obv + c_obv) / 4
haOpen = float(na)
haOpen := na(haOpen[1]) ? (o_obv + c_obv) / 2 : (nz(haOpen[1]) + nz(haClose[1])) / 2
haHigh = math.max(h_obv, math.max(haOpen, haClose))
haLow = math.min(l_obv, math.min(haOpen, haClose))
colup = #fff2cc
coldn = #6fa8dc
colema1 = #FFD6E8
colema2 = #9a9adf
haColor = switch
haClose > haOpen => colup
haClose < haOpen => coldn
plotcandle(haOpen, haHigh, haLow, haClose,
title = " 𝘖𝘉𝘝", color = haColor, wickcolor = haColor, bordercolor = haColor)
plot(ma1 ? ta.ema(haClose, len1) : na, " 𝘌𝘔𝘈 1", colema1)
plot(ma2 ? ta.ema(haClose, len2) : na, " 𝘌𝘔𝘈 2", colema2)
hline(norm ? 0 : na, "Zero Line", #ffffff80, hline.style_solid)