Heikin Ashi Trend Indicator

dman103 · study · 62 行 · 点赞 2,713 · TradingView 原页

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

Pine Script

//@version=4
// This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License https://creativecommons.org/licenses/by-sa/4.0/
// © dman103
// My own implantation of Heikin Ashi.
// The Heikin Ashi Trend Indicator (HAT) used to determine the price direction of an asset, as well as draw attention to when the price direction is changing.
// The HAT indicator translates the current close/open/high/low into Heikin Ashi and smooths them a bit using Tilson T3 formula. 
// Buy signal when Heikin Ashi Close is bigger than Heikin Ashi Open with Tilson T3 smoothing.
// Sell signal when Heikin Ashi Open is bigger than Heikin Ashi Close with Tilson T3 smoothing.
// 
// Set the 'percentSqueeze' percentage to display possible reversal with light Red/Green crosses. 
// 
// Green       - Up Trend
// Light Green - Possible reversal is near
// Red         - Down Trend
// Light Red   - Possible reversal is near
//
// Enjoy
//
//Follow for more indicators: https://www.tradingview.com/u/dman103/#published-scripts
study(title="Heikin Ashi Trend Indicator", shorttitle="HAT", overlay=true)
 
// === Input ===
 
percentSqueeze=input(0.2,step=0.1)
 
// === Tilson T3 ===
T3Factor=input( defval=0.3, minval=0,maxval = 100,step = 0.1,title="T3 Factor")
T3Length = input(defval=7, minval=1, title ="T3 Length")
T3FactorCalc = T3Factor *.10
gd(src, T3Length, T3FactorCalc) => ema(src, T3Length) * (1 + T3FactorCalc) - ema(ema(src, T3Length), T3Length) * T3FactorCalc 
t3(src, T3Length, T3FactorCalc) => gd(gd(gd(src, T3Length, T3FactorCalc), T3Length, T3FactorCalc), T3Length, T3FactorCalc) 
 
o = open
c = close
h = high
l = low
 
ha_t = heikinashi(syminfo.tickerid)
ha_o = security(ha_t, timeframe.period, o)
ha_c = security(ha_t, timeframe.period, c)
ha_h = security(ha_t, timeframe.period, h)
ha_l = security(ha_t, timeframe.period, l)
o2 = t3(ha_o, T3Length, T3FactorCalc) 
c2 =  t3(ha_c, T3Length, T3FactorCalc) 
h2 =  t3(ha_h, T3Length, T3FactorCalc) 
l2 =  t3(ha_l, T3Length, T3FactorCalc) 
 
percentHL=0.0
 
percentHL := ((o2 - c2) / avg(o2,c2)) * 100
 
high_squeeze= abs(percentHL)<percentSqueeze and percentHL>0
low_squeeze= abs(percentHL)<percentSqueeze and percentHL<0
 
crossPlot= 0.0
if (o2 < c2)
    crossPlot := l2
else 
    crossPlot := h2
 
plotColor =  high_squeeze ? color.maroon : low_squeeze ? color.teal :  o2 < c2 ? color.lime :  color.red 
plot(crossPlot, color = plotColor, style = plot.style_cross, linewidth = 2)

← 返回列表