本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=3
strategy("Kozlod - Heikin-Ashi Bar Color Change Strategy", overlay = true)
//
// author: Kozlod
// date: 2018-09-03
// https://www.tradingview.com/u/Kozlod/
//
// Calculation HA Values
haopen = 0.0
haclose = ((open + high + low + close)/4)
haopen := na(haopen[1]) ? (open + close)/2 : (haopen[1] + haclose[1]) / 2
hahigh = max(high, max(haopen, haclose))
halow = min(low, min(haopen, haclose))
// HA colors
hacolor = haclose > haopen ? green : red
// Signals
turnGreen = haclose > haopen and haclose[1] <= haopen[1]
turnRed = haclose <= haopen and haclose[1] > haopen[1]
// Plotting
bgcolor(hacolor)
plotshape(turnGreen, style = shape.arrowup, location = location.belowbar, color = green)
plotshape(turnRed, style = shape.arrowdown, location = location.abovebar, color = red)
// Alerts
strategy.entry("long", true, when = turnGreen)
strategy.entry("short", false, when = turnRed)