
이 전략은 평활화된 캔들스틱(하이킨-아시)과 지수 이동 평균(EMA)의 교차를 기반으로 하는 다중 기간 추세 추종 시스템입니다. 하이킨-아시 캔들스틱의 평활화 특성과 다양한 기간에 걸친 이동평균의 추세 추적 능력을 결합하고, MACD 지표를 필터로 사용하면 시장 추세를 정확하게 포착할 수 있습니다. 이 전략은 시간대 계층적 설계를 채택하고 60분, 180분, 15분의 세 가지 시간대에 대해 신호 계산과 검증을 수행합니다.
전략의 핵심 논리는 다음과 같은 핵심 부분으로 구성됩니다.
이 전략은 여러 기간의 하이킨-아시와 EMA 시스템을 MACD 필터와 결합하여 완전한 추세 추종 거래 시스템을 구축합니다. 전략 설계는 신호의 신뢰성과 시스템의 안정성을 충분히 고려하며, 매개변수 최적화와 위험 관리 메커니즘 개선을 통해 다양한 시장 환경에 적응할 수 있습니다. 이 전략의 핵심적인 장점은 신호의 원활함과 다중 검증 메커니즘에 있지만, 동시에 변동성 있는 시장의 위험과 매개변수 최적화 문제에도 주의해야 합니다.
/*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", "")