
이 전략은 평형형 Heikin-Ashi 도표와 간단한 이동 평균 ((SMA) 의 교차에 기반한 트렌드 추적 시스템이다. 전략은 EMA 평형 처리를 받은 Heikin-Ashi 도표와 44주기 SMA의 교차를 통해 트렌드의 변화를 식별하여 시장의 주요 트렌드적 기회를 포착한다. 전략은 동적인 포지션 관리 메커니즘을 설계하고 있으며, 가격이 장기 평균선과 근접한 거리가 지나면 자동으로 평소되어 전체 시장의 변동 위험을 회피한다.
전략의 핵심 논리에는 세 가지 핵심 요소가 포함되어 있습니다. 첫째, 전통적인 K선을 Heikin-Ashi 도표로 변환하여 4가지 가격의 수학적 평균을 계산하여 시장의 잡음을 필터링합니다. 둘째, 6주기 EMA를 사용하여 Heikin-Ashi를 부드럽게 처리하여 신호의 신뢰성을 더욱 향상시킵니다.
이 전략은 Heikin-Ashi 도표와 SMA 평선 시스템을 결합하여 안정적인 트렌드 추적 거래 시스템을 구축한다. 전략의 신호 생성 메커니즘은 완벽하고, 위험 통제는 합리적이며, 특히 트렌드 특징이 뚜렷한 시장에서 적용하기에 적합하다. 제안된 최적화 방향을 통해 전략의 실전 효과를 더욱 향상시킬 수 있다.
/*backtest
start: 2024-10-01 00:00:00
end: 2024-10-31 23:59:59
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Smoothed Heikin Ashi with SMA Strategy", overlay=true)
// Input parameters for SMAs
s1 = input.int(11, title="Short SMA Period")
s2 = input.int(44, title="Long SMA Period")
noPositionThreshold = input.float(0.001, title="No Position Threshold", step=0.0001)
// Calculate the original Heikin-Ashi values
haClose = (open + high + low + close) / 4
var float haOpen = na
haOpen := na(haOpen[1]) ? (open + close) / 2 : (haOpen[1] + haClose[1]) / 2
haHigh = math.max(high, math.max(haOpen, haClose))
haLow = math.min(low, math.min(haOpen, haClose))
// Smoothing using exponential moving averages
smoothLength = input.int(6, title="Smoothing Length")
smoothedHaClose = ta.ema(haClose, smoothLength)
smoothedHaOpen = ta.ema(haOpen, smoothLength)
smoothedHaHigh = ta.ema(haHigh, smoothLength)
smoothedHaLow = ta.ema(haLow, smoothLength)
// Calculate SMAs
smaShort = ta.sma(close, s1)
smaLong = ta.sma(close, s2)
// Plotting the smoothed Heikin-Ashi values
plotcandle(smoothedHaOpen, smoothedHaHigh, smoothedHaLow, smoothedHaClose, color=(smoothedHaClose >= smoothedHaOpen ? color.green : color.red), title="Smoothed Heikin Ashi")
plot(smaShort, color=color.blue, title="SMA Short")
plot(smaLong, color=color.red, title="SMA Long")
// Generate buy/sell signals based on SHA crossing 44 SMA
longCondition = ta.crossover(smoothedHaClose, smaLong)
shortCondition = ta.crossunder(smoothedHaClose, smaLong)
noPositionCondition = math.abs(smoothedHaClose - smaLong) < noPositionThreshold
// Strategy logic
if (longCondition)
strategy.entry("Long", strategy.long)
if (shortCondition)
strategy.entry("Short", strategy.short)
if (noPositionCondition and strategy.position_size != 0)
strategy.close_all("No Position")
// Plot buy/sell signals
plotshape(series=longCondition, location=location.belowbar, color=color.green, style=shape.labelup, text="BUY", size=size.small)
plotshape(series=shortCondition, location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL", size=size.small)
plotshape(series=noPositionCondition and strategy.position_size != 0, location=location.belowbar, color=color.yellow, style=shape.labeldown, text="EXIT", size=size.small)