This strategy generates trading signals by calculating the moving average crossover of Heiken Ashi candles, combined with MACD as a filter condition. It implements a relatively stable trading system.
Calculate the open and close prices of Heiken Ashi candles.
Calculate fast moving average (EMA) and slow moving average (SMA).
When fast MA crosses above slow MA, a buy signal is generated.
When fast MA crosses below slow MA, a sell signal is generated.
If MACD filter is enabled, buy signals are only generated when MACD histogram crosses above 0 line, and sell signals are only generated when MACD histogram crosses below 0 line.
Heiken Ashi candles effectively filter out market noise, making MA crossover signals more reliable.
Combining MAs of different periods avoids false breakouts from single MA.
MACD filter further avoids false signals and improves signal quality.
Using Heiken Ashi to calculate MA reduces drawdowns from regular candles.
The strategy has reasonable parameters and moderate trading frequency, allowing stable profits without high frequency trading.
However, some risks need to be noticed:
Repeated position adjustments may occur in ranging markets.
MACD filter may fail in some cases, resulting in false signals.
MA systems are sensitive to parameter tuning, requiring careful optimization.
Long holding positions need to monitor events that may cause significant market changes.
Manual judgement of major trends is still needed to avoid losses from counter-trend trading.
In conclusion, this is a relatively mature MA strategy that can provide steady profits with proper parameter tuning. But traders still need to watch out for risks, adjust positions accordingly, and combine trend analysis when applying it.
/*backtest start: 2023-09-24 00:00:00 end: 2023-10-24 00:00:00 period: 1h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=3 //Heiken-Ashi Strategy V3 by wziel // strategy("Heiken-Ashi Strategy V3",shorttitle="WZIV3",overlay=true,default_qty_value=10000,initial_capital=10000,currency=currency.USD) res = input(title="Heikin Ashi Candle Time Frame", defval="60") hshift = input(1,title="Heikin Ashi Candle Time Frame Shift") res1 = input(title="Heikin Ashi EMA Time Frame", defval="180") mhshift = input(0,title="Heikin Ashi EMA Time Frame Shift") fama = input(1,"Heikin Ashi EMA Period") test = input(1,"Heikin Ashi EMA Shift") sloma = input(30,"Slow EMA Period") slomas = input(1,"Slow EMA Shift") macdf = input(false,title="With MACD filter") res2 = input(title="MACD Time Frame", defval="15") macds = input(1,title="MACD Shift") //Heikin Ashi Open/Close Price ha_t = heikinashi(syminfo.tickerid) ha_open = security(ha_t, res, open[hshift]) ha_close = security(ha_t, res, close[hshift]) mha_close = security(ha_t, res1, close[mhshift]) //macd [macdLine, signalLine, histLine] = macd(close, 12, 26, 9) macdl = security(ha_t,res2,macdLine[macds]) macdsl= 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("Buy",strategy.long,when = golong) strategy.entry("Sell",strategy.short,when = goshort)