本页源码来自 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("Standardized MACD Heikin-Ashi Transformed", "{Ʌ} - 𝗦𝘁. 𝗠𝗔𝗖𝗗 𝗛-𝗔", false)
f_macd(src, fast, slow) =>
(ta.ema(src, fast) - ta.ema(src, slow)) / (ta.ema(high - low, slow)) * 100
src = input.source(close, "Source", group = "MACD Settings")
fast = input.int(12, "Fast Length", group = "MACD Settings")
slow = input.int(26, "Slow Length", group = "MACD Settings")
signal = input.int(9, "Signal Length", group = "MACD Settings")
modtype = input.string("Hybrid", "Display Mode", ["Hybrid", "MACD", "Histogram"], group = "UI Options")
revshow = input.bool(true, "", inline = "0", group = "UI Options")
revt = input.int(100, "Reversion Threshold", options = [100, 150], inline = "0", group = "UI Options")
colbar = input.string("None", "Bar Coloring", ["None", "MidLine", "Candles", "Signal Cross", "Extremities", "Reversions"], group = "UI Options")
hol = input.bool(true, "Hollow Candles", group = "UI Options")
macd = f_macd(src, fast, slow)
sig = ta.ema(macd, signal)
hist = macd - sig
o_macd = macd[1]
h_macd = math.max(macd, macd[1])
l_macd = math.min(macd, macd[1])
c_macd = macd
haClose = (o_macd + h_macd + l_macd + c_macd) / 4
haOpen = float(na)
haOpen := na(haOpen[1]) ? (o_macd + c_macd) / 2 : (nz(haOpen[1]) + nz(haClose[1])) / 2
haHigh = math.max(h_macd, math.max(haOpen, haClose))
haLow = math.min(l_macd, math.min(haOpen, haClose))
colup = #00bcd4
coldn = #fc1f1f
colsig = chart.fg_color
h_col = hist > 0 ? (hist > hist[1] ? #8ac3f5a1 : #74a5cfa1) : (hist > hist[1] ? #ffa7b6a1 : #d88b98a1)
haColor = switch
haClose > haOpen => colup
haClose < haOpen => coldn
hline(0, "Mid Line", #ffffff80, hline.style_solid)
max = hline(modtype != "Histogram" ? 200 : 100, display = display.none)
hh = hline(modtype != "Histogram" ? 150 : 75, display = display.none)
lh = hline(modtype != "Histogram" ? 100 : 50, display = display.none)
fill(lh, hh, color = #fc1f1f1c)
fill(hh, max, color = #fc1f1f38)
min = hline(modtype != "Histogram" ? -200 : -100, display = display.none)
ll = hline(modtype != "Histogram" ? -150 : -75, display = display.none)
hl = hline(modtype != "Histogram" ? -100 : -50, display = display.none)
fill(ll, hl, #00bbd41a)
fill(ll, min, #00bbd436)
plot(modtype != "MACD" ? hist : na, "𝗛", h_col, 1, plot.style_columns)
plotcandle(modtype != "Histogram" ? haOpen : na, haHigh, haLow, haClose, "𝗠𝗔𝗖𝗗", hol ? haClose > haOpen ? na : haColor : haColor, haColor, bordercolor = haColor)
plot(modtype != "Histogram" ? sig : na, "𝗦𝗶𝗴𝗻𝗮𝗹", colsig)
plotshape(modtype != "Histogram" ? revshow ? haHigh > revt and haClose < haOpen and not (haClose[1] < haOpen[1]) ? haHigh + 40 : na : na : na, "OB", shape.triangledown, location.absolute, coldn, size = size.tiny)
plotshape(modtype != "Histogram" ? revshow ? haLow < -revt and haClose > haOpen and not (haClose[1] > haOpen[1]) ? haLow - 40 : na : na : na, "OS", shape.triangleup, location.absolute, colup, size = size.tiny)
color col = switch colbar
"None" => na
"MidLine" => macd > 0 ? colup : coldn
"Extremities" => macd > revt ? coldn : macd < -revt ? colup : #b3b3b3c2
"Reversions" => macd > revt and macd < macd[1] and not (macd[1] < macd[2]) ? coldn : macd < -revt and macd > macd[1] and not (macd[1] > macd[2]) ? colup : #b3b3b3c2
"Candles" => haClose > haOpen ? colup : coldn
"Signal Cross" => sig > haClose ? coldn : colup
barcolor(col)