
이 전략은 경험 모드 분해 (Empirical Mode Decomposition, EMD) 방법에 기초하여, 가격 서열을 분해하여, 서로 다른 파장의 특성을 추출하고, 평균값과 결합하여 거래 신호를 생성한다. 이 전략은 주로 중장선 지위를 보유하는 데 적합하다.
이 전략은 경험 모형 분해 방법을 사용하여 가격 서열에 특징을 추출하고 추출 된 특징을 기반으로 거래 신호를 생성하여 안정적인 중장선 거래 전략을 구현합니다. 이 전략의 장점은 가격의 주기적 특성을 효과적으로 식별하고 큰 변동에서 거래 지시를 발령하는 데 있습니다. 그러나 위험이 있지만 더 복잡한 시장 환경에 적응하기 위해 추가 최적화가 필요합니다.
/*backtest
start: 2022-12-15 00:00:00
end: 2023-12-21 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
////////////////////////////////////////////////////////////
// Copyright by HPotter v1.0 12/04/2017
// The related article is copyrighted material from Stocks & Commodities Mar 2010
// You can use in the xPrice any series: Open, High, Low, Close, HL2, HLC3, OHLC4 and ect...
//
// You can change long to short in the Input Settings
// Please, use it only for learning or paper trading. Do not for real trading.
////////////////////////////////////////////////////////////
strategy(title="Empirical Mode Decomposition")
Length = input(20, minval=1)
Delta = input(0.5)
Fraction = input(0.1)
reverse = input(false, title="Trade reverse")
xPrice = hl2
beta = cos(3.1415 * (360 / Length) / 180)
gamma = 1 / cos(3.1415 * (720 * Delta / Length) / 180)
alpha = gamma - sqrt(gamma * gamma - 1)
xBandpassFilter = 0.5 * (1 - alpha) * (xPrice - xPrice[2]) + beta * (1 + alpha) * nz(xBandpassFilter[1]) - alpha * nz(xBandpassFilter[2])
xMean = sma(xBandpassFilter, 2 * Length)
xPeak = iff (xBandpassFilter[1] > xBandpassFilter and xBandpassFilter[1] > xBandpassFilter[2], xBandpassFilter[1], nz(xPeak[1]))
xValley = iff (xBandpassFilter[1] < xBandpassFilter and xBandpassFilter[1] < xBandpassFilter[2], xBandpassFilter[1], nz(xValley[1]))
xAvrPeak = sma(xPeak, 50)
xAvrValley = sma(xValley, 50)
nAvrPeak = Fraction * xAvrPeak
nAvrValley = Fraction * xAvrValley
pos = iff(xMean > nAvrPeak and xMean > nAvrValley, 1,
iff(xMean < nAvrPeak and xMean < nAvrValley, -1, nz(pos[1], 0)))
possig = iff(reverse and pos == 1, -1,
iff(reverse and pos == -1, 1, pos))
if (possig == 1)
strategy.entry("Long", strategy.long)
if (possig == -1)
strategy.entry("Short", strategy.short)
barcolor(possig == -1 ? red: possig == 1 ? green : blue )
plot(xMean, color=red, title="Mean")
plot(nAvrPeak, color=blue, title="Peak")
plot(nAvrValley, color=blue, title="Valley")