资源加载中... loading...

Momentum Crossover Moving Average and MACD Filter Heikin-Ashi Candlestick Strategy

Author: ChaoZhang, Date: 2024-01-02 12:18:03
Tags:

img

Overview

This strategy utilizes the Heikin-Ashi candlestick technique combined with moving average crossover signals and MACD indicator for filtration to construct a trend-following strategy. The strategy can capture market trends in different timeframes, generating trading signals through moving average crossovers, and then filtering out false signals via the MACD indicator, demonstrating high profitability in backtests.

Strategy Logic

The strategy mainly leverages three major technical indicators:

  1. Heikin-Ashi Candlesticks. It modifies the closing price to construct “shadowless” candlestick bars, which can more clearly exhibit true price trends, filtering out excessive market noise.

  2. Exponential Moving Average (EMA). The fast EMA captures short-term trends while the slow EMA judges long-term trend directions. A buy signal is generated when the fast EMA crosses above the slow EMA; A sell signal is generated when the fast EMA crosses below the slow EMA.

  3. MACD Indicator. It combines fast and slow EMAs. When the MACD line is above the signal line, it is a bullish signal; when below, it’s a bearish signal.

The trading signals of this strategy come from the golden/dead cross of the fast and slow EMAs. To filter out false signals, the MACD indicator is introduced for auxiliary judgment. Only when the MACD gives out a signal that aligns with the EMA crossover will the final trading signal be triggered, which greatly reduces the probability of wrong trades.

Specifically, when the fast EMA crosses above the slow EMA (golden cross) and the MACD line goes above the signal line (bullish signal) simultaneously, a buy signal is generated; when the fast EMA crosses below the slow EMA (dead cross) and the MACD line goes below the signal line (bearish signal) at the same time, a sell signal is generated.

This combination of moving average crossover and MACD filtration can effectively identify key inflection points in the market and capture price trends accordingly.

Advantages

The strategy has the following outstanding edges:

  1. Greatly improved probability of capturing trend signals. The Heikin-Ashi technique offers clearer trend judgment, while the strength of crossover signals from the two EMAs is also powerful. The reliability is even higher after integrating the MACD filter.

  2. Relatively small drawdown risk. The MACD, serving as an auxiliary indicator, can mitigate stop-loss risks to some extent and effectively reduce unwanted liquidation losses.

  3. More tunable parameters. The periods of Heikin-Ashi candlesticks, fast/slow EMAs of the moving average system, parameters of the MACD etc. can all be adjusted based on market conditions to make the strategy more adaptive.

  4. Simple and clear implementation. Using Heikin-Ashi candles to denote prices and aided with common indicators for determination, it is easy to program, with neat and concise codes that are intuitive to understand.

  5. Higher capital usage efficiency. By trend-following, most of the time the strategy can align capital movements with the main market direction and generate returns more effectively.

Risks

The strategy also has the following potential risks:

  1. Severe whipsaws in the market may lead to heavy losses. When prices gap significantly or reverse rapidly in the short-term, stop-loss measures could fail, incurring losses way beyond expectations.

  2. Possibilities of MACD misjudgment. MACD as an auxiliary indicator can also make wrong calls, resulting in the strategy wrongly establishing or closing positions.

  3. Inflexible parameter settings. Fixed parameter combinations may not adapt to the ever-changing market, thus missing good trading opportunities.

  4. Potentially high trading frequency. Trend-following methods could induce frequent trades, increasing costs and slippage losses.

To mitigate and reduce the above risks, the following measures can be adopted:

  1. Set stop-loss points to limit losses for single trades. Also, avoid over-chasing trends and control position sizes.

  2. Adjust MACD parameters to decrease incorrect signal probabilities. More indicators can also be introduced for multi-confirmation.

  3. Build parameter optimization mechanisms. Employ machine learning etc. to auto-tune parameter combinations for higher adaptivity.

  4. Appropriately relax trigger conditions for trading signals to reduce trading frequency, or set minimum price change thresholds.

Optimization

Great potential lies in further optimization of the strategy, including:

  1. Optimize Heikin-Ashi candlestick durations. Test longer or shorter periods to find the ones that best exhibit market trends.

  2. Adjust parameters of the moving average system. Modify periods of the fast/slow EMAs to discover optimal parameter sets.

  3. Multi-parameter optimization of the MACD. Fine-tune parameters of the fast/slow EMAs and MACD signal line to locate superior configurations.

  4. Reinforce risk management modules. Devise more scientific stop-loss/take-profit rules, integrate position sizing, capital management etc.

  5. Introduce more auxiliary indicators. Add other indicators like KD, RSI for multi-factor confirmation, improving signal quality.

  6. Employ machine learning techniques. Leverage neural networks, genetic algorithms etc. to real-time optimize strategy parameters for higher adaptivity.

With iterative combinations of technical indicators, continuous parameter optimizations, stronger risk control modules etc., significant performance boosts of the strategy can be expected for more steady and efficient profitability.

Conclusion

This strategy captures market trends by combining Heikin-Ashi candles and moving average crossovers, aided by MACD filtration for detecting high-reliability turning points and trading signals. Backtested results are outstanding, with edges like high winning probability, low drawdowns, high tunability. Meanwhile, risk control also needs attention to hedge impacts from extreme market moves. With continuous improvements and optimization, the strategy demonstrates great potential as a highly effective quantitative trading strategy.


/*backtest
start: 2022-12-26 00:00:00
end: 2024-01-01 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
//Heikin Ashi Strategy  V1 by nachobuey

strategy("Heikin Ashi Strategy  V2",shorttitle="HAS V2",overlay=true)
res = input(title="Heikin Ashi Candle Time Frame",  defval="15")
hshift = input(0,title="Heikin Ashi Candle Time Frame Shift")
//res1 = input(title="Heikin Ashi EMA Time Frame", type=resolution, defval="180")
res1   = input(title="Time frame (Minutes. Not lower than chart)",defval="300")
mhshift = input(0,title="Heikin Ashi EMA Time Frame Shift")
fama = input(16,"Heikin Ashi EMA Period")
test = input(0,"Heikin Ashi EMA Shift")
sloma = input(21,"Slow EMA Period")
slomas = input(0,"Slow EMA Shift")
macdf = input(false,title="With MACD filter")
res2 = input(title="MACD Time Frame",  defval="60")
macds = input(1,title="MACD Shift")




//Heikin Ashi Open/Close Price
ha_t = heikinashi(syminfo.tickerid)
ha_open = request.security(ha_t, res, open[hshift])
ha_close = request.security(ha_t, res, close[hshift])
mha_close = request.security(ha_t, res1, close[mhshift])

//macd
[macdLine, signalLine, histLine] = macd(close, 12, 26, 9)
macdl = request.security(ha_t,res2,macdLine[macds])
macdsl= request.security(ha_t,res2,signalLine[macds])

//Moving Average
fma = ema(mha_close[test],fama)
sma = ema(ha_close[slomas],sloma)
plot(fma,title="MA",color=lime,linewidth=2,style=line)
plot(sma,title="SMA",color=red,linewidth=2,style=line)


//Strategy
golong =  crossover(fma,sma) and (macdl > macdsl or macdf == false )
goshort =   crossunder(fma,sma) and (macdl < macdsl or macdf == false )


strategy.entry("Long",strategy.long,when = golong)
strategy.entry("Short",strategy.short,when = goshort)

plotchar(golong,char="L", color=green)
plotchar(goshort,char="S", color=red)

alertcondition(golong, "HAS GO LONG", "OPEN LONG")
alertcondition(goshort, "HAS GO SHORT", "OPEN SHORT")



More