Z-Score Heikin Ashi Transformed

EliCobra · study · 67 行 · 点赞 1,973 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

// 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("Z-Score Heikin Ashi Transformed", "{Ʌ} - 𝘡 𝘏-𝘈", false)
 
f_z(src, len) =>
    mean = ta.sma(src, len)
    dev = ta.stdev(src, len)
 
    (src - mean) / dev
 
 
len = input.int(21, 'Z Period')
revshow = input.bool(true, "", inline = "0")
revt = input.int(2, "Reversion Threshold", options = [1, 2, 3], inline = "0")
ma1 = input.bool(true, "EMA  |", inline = "1", group = "EMAs")
len1 = input.int(50, "Length", inline = "1", group = "EMAs")
ma2 = input.bool(true, "EMA  |", inline = "2", group = "EMAs")
len2 = input.int(150, "Length", inline = "2", group = "EMAs")
 
 
o_z = f_z(open, len)
h_z = f_z(high, len)
l_z = f_z(low, len)
c_z = f_z(close, len)
 
haClose = (o_z + h_z + l_z + c_z) / 4
haOpen = float(na)
haOpen := na(haOpen[1]) ? (o_z + c_z) / 2 : (nz(haOpen[1]) + nz(haClose[1])) / 2
haHigh = math.max(h_z, math.max(haOpen, haClose))
haLow = math.min(l_z, 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, "𝘚𝘤𝘰𝘳𝘦", haClose < haOpen ? haColor : na, haColor, bordercolor = haColor)
 
plot(ma1 ? ta.ema(haClose, len1) : na, "𝘌𝘔𝘈 1", colema1)
plot(ma2 ? ta.ema(haClose, len2) : na, "𝘌𝘔𝘈 2", colema2)
 
 
hline(0, "Mid Line", #ffffff80, hline.style_solid)
 
max = hline(4, display = display.none)
hh = hline(3, display = display.none)
lh = hline(2, display = display.none)
 
fill(lh, hh, color = #9a9adf2a)
fill(hh, max, color = #9a9adf4d)
 
min = hline(-4, display = display.none)
ll = hline(-3, display = display.none)
hl = hline(-2, display = display.none)
 
fill(ll, hl, color = #ffd6e83b)
fill(ll, min, color = #ffd6e85e)
 
 
plotshape(revshow ? haHigh > revt and haHigh < haHigh[1] and not (haHigh[1] < haHigh[2]) ? haHigh + 0.75 : na : na, "OB", shape.triangledown, location.absolute, colema1, size = size.tiny)
plotshape(revshow ? haLow < -revt and haLow > haLow[1] and not (haLow[1] > haLow[2]) ? haLow - 0.75 : na : na, "OS", shape.triangleup, location.absolute, colema2, size = size.tiny)

← 返回列表