163 lines
8.6 KiB
Markdown
163 lines
8.6 KiB
Markdown
|
|||
|
|
> Name
|
||
|
|
|
||
|
|
多重时间周期平滑烛线移动平均趋势跟踪交易系统-Multi-Timeframe-Heikin-Ashi-Moving-Average-Trend-Following-Trading-System
|
||
|
|
|
||
|
|
> Author
|
||
|
|
|
||
|
|
ChaoZhang
|
||
|
|
|
||
|
|
> Strategy Description
|
||
|
|
|
||
|
|

|
||
|
|
|
||
|
|
[trans]
|
||
|
|
#### 概述
|
||
|
|
该策略是一个基于平滑烛线(Heikin-Ashi)与指数移动平均线(EMA)交叉的多重时间周期趋势跟踪系统。通过在不同时间周期上结合Heikin-Ashi烛线的平滑特性和移动平均线的趋势跟踪能力,同时配合MACD指标作为过滤器,实现对市场趋势的准确捕捉。策略采用了时间周期分层设计,分别在60分钟、180分钟和15分钟三个时间周期上进行信号计算和验证。
|
||
|
|
|
||
|
|
#### 策略原理
|
||
|
|
策略的核心逻辑包括以下几个关键部分:
|
||
|
|
1. Heikin-Ashi烛线计算:通过特殊的开高低收价格计算方法,平滑原始价格数据,减少市场噪音。
|
||
|
|
2. 多重时间周期EMA系统:在180分钟周期计算Heikin-Ashi EMA,与60分钟周期的慢速EMA形成交叉信号系统。
|
||
|
|
3. MACD过滤器:在15分钟周期上计算MACD指标,用于验证交易信号的有效性。
|
||
|
|
4. 信号生成规则:当快速Heikin-Ashi EMA向上穿越慢速EMA,且MACD指标确认(如果启用)时,产生做多信号;反之产生做空信号。
|
||
|
|
|
||
|
|
#### 策略优势
|
||
|
|
1. 信号平滑性强:Heikin-Ashi烛线的平滑特性可以有效降低假信号。
|
||
|
|
2. 多重时间周期验证:不同时间周期的配合使用提高了信号的可靠性。
|
||
|
|
3. 趋势跟踪效果好:通过EMA交叉系统可以有效捕捉中长期趋势。
|
||
|
|
4. 灵活的过滤机制:可选的MACD过滤器提供了额外的信号确认。
|
||
|
|
5. 参数可调性强:多个关键参数可以根据不同市场特征进行优化。
|
||
|
|
|
||
|
|
#### 策略风险
|
||
|
|
1. 震荡市场风险:在横盘震荡市场可能产生频繁的假突破信号。
|
||
|
|
2. 滞后性风险:多重时间周期验证可能导致入场时机略有延迟。
|
||
|
|
3. 参数敏感性:不同参数组合可能导致策略表现差异较大。
|
||
|
|
4. 市场环境依赖:策略在强趋势市场表现更好,而在其他市场环境下可能效果欠佳。
|
||
|
|
|
||
|
|
#### 策略优化方向
|
||
|
|
1. 增加波动率过滤:引入ATR或Bollinger带等指标进行市场波动性判断。
|
||
|
|
2. 优化时间周期选择:可以根据具体交易品种特征调整时间周期组合。
|
||
|
|
3. 完善止损机制:增加追踪止损或基于波动率的动态止损。
|
||
|
|
4. 增加仓位管理:根据信号强度和市场波动性动态调整仓位大小。
|
||
|
|
5. 加入市场环境判断:增加趋势强度指标来区分不同市场环境。
|
||
|
|
|
||
|
|
#### 总结
|
||
|
|
该策略通过多重时间周期的Heikin-Ashi和EMA系统,结合MACD过滤器,构建了一个完整的趋势跟踪交易系统。策略设计充分考虑了信号的可靠性和系统的稳定性,通过参数优化和风险控制机制的完善,能够适应不同的市场环境。策略的核心优势在于信号的平滑性和多重验证机制,但同时也需要注意震荡市场风险和参数优化问题。 ||
|
||
|
|
|
||
|
|
#### Overview
|
||
|
|
This strategy is a multi-timeframe trend following system based on Heikin-Ashi candlesticks and Exponential Moving Average (EMA) crossovers. It combines the smoothing properties of Heikin-Ashi candlesticks with the trend-following capabilities of moving averages across different timeframes, using MACD as an additional filter to accurately capture market trends. The strategy employs a hierarchical timeframe design, calculating and validating signals across 60-minute, 180-minute, and 15-minute timeframes.
|
||
|
|
|
||
|
|
#### Strategy Principles
|
||
|
|
The core logic includes several key components:
|
||
|
|
1. Heikin-Ashi calculation: Smooths original price data through special OHLC calculations to reduce market noise.
|
||
|
|
2. Multi-timeframe EMA system: Calculates Heikin-Ashi EMA on 180-minute timeframe, forming crossover signals with slow EMA on 60-minute timeframe.
|
||
|
|
3. MACD filter: Calculates MACD indicator on 15-minute timeframe to validate trading signals.
|
||
|
|
4. Signal generation rules: Generates buy signals when fast Heikin-Ashi EMA crosses above slow EMA with MACD confirmation (if enabled); reverse for sell signals.
|
||
|
|
|
||
|
|
#### Strategy Advantages
|
||
|
|
1. Strong signal smoothing: Heikin-Ashi candlesticks effectively reduce false signals.
|
||
|
|
2. Multi-timeframe validation: Using different timeframes increases signal reliability.
|
||
|
|
3. Effective trend following: EMA crossover system effectively captures medium to long-term trends.
|
||
|
|
4. Flexible filtering mechanism: Optional MACD filter provides additional signal confirmation.
|
||
|
|
5. Strong parameter adaptability: Multiple key parameters can be optimized for different market characteristics.
|
||
|
|
|
||
|
|
#### Strategy Risks
|
||
|
|
1. Choppy market risk: May generate frequent false breakout signals in sideways markets.
|
||
|
|
2. Lag risk: Multi-timeframe validation may lead to slightly delayed entries.
|
||
|
|
3. Parameter sensitivity: Different parameter combinations may result in significant performance variations.
|
||
|
|
4. Market environment dependency: Strategy performs better in strong trend markets, may underperform in other conditions.
|
||
|
|
|
||
|
|
#### Optimization Directions
|
||
|
|
1. Add volatility filtering: Introduce ATR or Bollinger Bands for market volatility assessment.
|
||
|
|
2. Optimize timeframe selection: Adjust timeframe combinations based on specific instrument characteristics.
|
||
|
|
3. Improve stop-loss mechanism: Add trailing stops or volatility-based dynamic stop-losses.
|
||
|
|
4. Enhance position sizing: Dynamically adjust position sizes based on signal strength and market volatility.
|
||
|
|
5. Include market environment analysis: Add trend strength indicators to differentiate market conditions.
|
||
|
|
|
||
|
|
#### Summary
|
||
|
|
This strategy constructs a complete trend following trading system using multi-timeframe Heikin-Ashi and EMA systems combined with MACD filtering. The design thoroughly considers signal reliability and system stability, capable of adapting to different market environments through parameter optimization and risk control mechanisms. The strategy's core strengths lie in signal smoothing and multi-validation mechanisms, while attention must be paid to choppy market risks and parameter optimization issues.[/trans]
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
> Source (PineScript)
|
||
|
|
|
||
|
|
``` pinescript
|
||
|
|
/*backtest
|
||
|
|
start: 2019-12-23 08:00:00
|
||
|
|
end: 2025-01-04 08:00:00
|
||
|
|
period: 1d
|
||
|
|
basePeriod: 1d
|
||
|
|
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
|
||
|
|
*/
|
||
|
|
|
||
|
|
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
|
||
|
|
// © tradingbauhaus
|
||
|
|
|
||
|
|
//@version=5
|
||
|
|
strategy("Heikin Ashi Candle Time Frame @tradingbauhaus", shorttitle="Heikin Ashi Candle Time Frame @tradingbauhaus", overlay=true)
|
||
|
|
|
||
|
|
// Inputs
|
||
|
|
res = input.timeframe(title="Heikin Ashi Candle Time Frame", defval="60")
|
||
|
|
hshift = input.int(1, title="Heikin Ashi Candle Time Frame Shift")
|
||
|
|
res1 = input.timeframe(title="Heikin Ashi EMA Time Frame", defval="180")
|
||
|
|
mhshift = input.int(0, title="Heikin Ashi EMA Time Frame Shift")
|
||
|
|
fama = input.int(1, title="Heikin Ashi EMA Period")
|
||
|
|
test = input.int(1, title="Heikin Ashi EMA Shift")
|
||
|
|
sloma = input.int(30, title="Slow EMA Period")
|
||
|
|
slomas = input.int(1, title="Slow EMA Shift")
|
||
|
|
macdf = input.bool(false, title="With MACD filter")
|
||
|
|
res2 = input.timeframe(title="MACD Time Frame", defval="15")
|
||
|
|
macds = input.int(1, title="MACD Shift")
|
||
|
|
|
||
|
|
// Heikin Ashi calculation
|
||
|
|
var float ha_open = na
|
||
|
|
ha_close = (open + high + low + close) / 4
|
||
|
|
ha_open := na(ha_open[1]) ? (open + close) / 2 : (ha_open[1] + ha_close[1]) / 2
|
||
|
|
ha_high = math.max(high, math.max(ha_open, ha_close))
|
||
|
|
ha_low = math.min(low, math.min(ha_open, ha_close))
|
||
|
|
|
||
|
|
// Adjusted Heikin Ashi Close for different timeframes
|
||
|
|
mha_close = request.security(syminfo.tickerid, res1, ha_close[mhshift])
|
||
|
|
|
||
|
|
// MACD calculation
|
||
|
|
[macdLine, signalLine, _] = ta.macd(close, 12, 26, 9)
|
||
|
|
macdl = request.security(syminfo.tickerid, res2, macdLine[macds])
|
||
|
|
macdsl = request.security(syminfo.tickerid, res2, signalLine[macds])
|
||
|
|
|
||
|
|
// Moving Averages
|
||
|
|
fma = ta.ema(mha_close[test], fama)
|
||
|
|
sma = ta.ema(ha_close[slomas], sloma)
|
||
|
|
plot(fma, title="Heikin Ashi EMA", color=color.green, linewidth=2)
|
||
|
|
plot(sma, title="Slow EMA", color=color.red, linewidth=2)
|
||
|
|
|
||
|
|
// Strategy Logic
|
||
|
|
golong = ta.crossover(fma, sma) and (macdl > macdsl or not macdf)
|
||
|
|
goshort = ta.crossunder(fma, sma) and (macdl < macdsl or not macdf)
|
||
|
|
|
||
|
|
// Plot Shapes for Buy/Sell Signals
|
||
|
|
plotshape(golong, color=color.green, text="Buy", style=shape.triangleup, location=location.belowbar)
|
||
|
|
plotshape(goshort, color=color.red, text="SELL", style=shape.triangledown, location=location.abovebar)
|
||
|
|
|
||
|
|
// Strategy Orders
|
||
|
|
strategy.entry("Long", strategy.long, when=golong)
|
||
|
|
strategy.close("Long", when=goshort)
|
||
|
|
strategy.entry("Short", strategy.short, when=goshort)
|
||
|
|
strategy.close("Short", when=golong)
|
||
|
|
|
||
|
|
// Alerts
|
||
|
|
alertcondition(golong, "Heikin Ashi BUY", "")
|
||
|
|
alertcondition(goshort, "Heikin Ashi SELL", "")
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
```
|
||
|
|
|
||
|
|
> Detail
|
||
|
|
|
||
|
|
https://www.fmz.com/strategy/477596
|
||
|
|
|
||
|
|
> Last Modified
|
||
|
|
|
||
|
|
2025-01-06 16:20:56
|