
이중 EMA 골드포크 데드포크 트렌드 추적 전략은 가격 트렌드 방향을 판단하기 위해 이중 EMA 지표를 사용하는 양적 거래 전략이다. 이 전략은 두 개의 다른 매개 변수의 EMA 지표를 계산하여 골드포크, 데드포크 신호를 결합하여 가격 트렌드를 결정한다. 더 짧은 EMA 위에 더 긴 EMA를 통과하면 구매 신호가 발생하고 더 짧은 EMA 아래에 더 긴 EMA를 통과하면 판매 신호가 발생한다.
이 전략의 핵심 지표는 두 개의 EMA로 구성되어 있으며, 긴 주기의 EMA1과 짧은 주기의 EMA2를 포함한다. EMA1의 변수는 21이고, EMA2의 변수는 10이다. 전략은 4시간 선을 기준주기로 두 개의 EMA를 계산한다.
더 짧은 기간 EMA2에서 더 긴 기간 EMA1을 통과하면 구매 신호가 발생한다. 이것은 가격의 단기 경향이 강해지고 상승 추세로 들어간다는 것을 나타냅니다. 더 짧은 기간 EMA2 아래에서 더 긴 기간 EMA1을 통과하면 판매 신호가 발생한다. 이것은 가격의 단기 상승 추세가 중단되어 하향 추세로 들어간다는 것을 나타냅니다.
오류 신호를 필터링하기 위해, 전략은 두 개의 골드 포크 시드포크 지표를 설정한다. 두 개의 지표가 동시에 신호를 발산할 때만, 해당 구매 및 판매 작업을 촉발한다. 이것은 가격 변동으로 인한 잘못된 거래를 효과적으로 줄일 수 있다.
이러한 위험은 다음과 같은 방법으로 조절할 수 있습니다.
이 전략에는 더 많은 최적화 가능성이 있습니다:
모델 포트폴리지를 늘립니다. 다양한 매개 변수 지표의 포트폴리지를 구축하여 전략의 안정성을 높일 수 있습니다.
손해 제도를 늘리십시오. 합리적인 손해 제도를 설정하여 개별 손해를 효과적으로 제어하십시오.
동적 매개 변수 최적화. 다양한 시장 환경에 따라 자동으로 EMA의 매개 변수를 최적화 할 수 있습니다.
기계 학습 기술과 결합
이중 EMA 금 포크 사다리 트렌드 추적 전략은 간단한 실용적인 트렌드 거래 전략이다. 이중 EMA 지표를 사용하여 가격의 단기 트렌드를 판단하여 방향성 행태의 기회를 잡는다. 동시에 두 개의 금 포크 사다리 필터 지표와 결합하여 오류 거래를 줄일 수 있다. 이 전략은 구조가 간단하고 구현하기 쉽고, 수량 거래 응용 프로그램에 적합하다. 지속적인 최적화 및 개선으로 전략 우위를 더욱 확장하고 안정적인 수익성을 향상시킬 수 있다.
/*backtest
start: 2023-02-22 00:00:00
end: 2024-02-28 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
/// Component Code Startt
testStartYear = input(2017, "Backtest Start Year")
testStartMonth = input(01, "Backtest Start Month")
testStartDay = input(1, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)
testStopYear = input(2020, "Backtest Stop Year")
testStopMonth = input(1, "Backtest Stop Month")
testStopDay = input(1, "Backtest Stop Day")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)
// A switch to control background coloring of the test period
testPeriodBackground = input(title="Color Background?", type=bool, defval=false)
testPeriodBackgroundColor = testPeriodBackground and (time >= testPeriodStart) and (time <= testPeriodStop) ? #00FF00 : na
bgcolor(testPeriodBackgroundColor, transp=97)
testPeriod() => true
// Component Code Stop
strategy(title="Ema cross strat", overlay=true)
margin = input(true, title="Margin?")
Margin = margin ? margin : false
resCustom = input(title="EMA Timeframe", defval="240" )
source = close,
len2 = input(21, minval=1, title="EMA1")
len3 = input(10, minval=1, title="EMA2")
ema2 = request.security(syminfo.tickerid,resCustom,ema(source,len2), lookahead=barmerge.lookahead_off)
ema3 = request.security(syminfo.tickerid,resCustom,ema(source,len3), lookahead=barmerge.lookahead_off)
mylong = crossover(ema3, ema2)
myshort = crossunder(ema3,ema2)
last_long = na
last_short = na
last_long := mylong ? time : nz(last_long[1])
last_short := myshort ? time : nz(last_short[1])
in_long = last_long > last_short ? 2 : 0
in_short = last_short > last_long ? 2 : 0
mylong2 = crossover(ema3, ema2)
myshort2 = crossunder(ema3, ema2)
last_long2 = na
last_short2 = na
last_long2 := mylong2 ? time : nz(last_long2[1])
last_short2 := myshort2 ? time : nz(last_short2[1])
in_long2 = last_long2 > last_short2 ? 0 : 0
in_short2 = last_short2 > last_long2 ? 0 : 0
condlongx = in_long + in_long2
condlong = crossover(condlongx, 1.9)
condlongclose = crossunder(condlongx, 1.9)
condshortx = in_short + in_short2
condshort = crossover(condshortx, 1.9)
condshortclose = crossover(condshortx, 1.9)
if crossover(condlongx, 1.9) and testPeriod() and strategy.position_size <= 0
strategy.entry("Long", strategy.long, comment="Long")
if crossover(condshortx, 1.9) and testPeriod() and strategy.position_size > 0
strategy.close("Long",when = not Margin)
if crossover(condshortx, 1.9) and testPeriod() and strategy.position_size >= 0
strategy.entry("Short", strategy.short, comment="Short", when = Margin)