빠르고 느린 EMA 골든 크로스 브레이크아웃 전략


생성 날짜: 2023-12-01 18:02:24 마지막으로 수정됨: 2023-12-01 18:02:24
복사: 0 클릭수: 751
avatar of ChaoZhang ChaoZhang
1
집중하다
1619
수행원

빠르고 느린 EMA 골든 크로스 브레이크아웃 전략

개요

느린 EMA 골드 크로스 브레이크 전략은 시장 동향을 추적하는 간단한 효과적인 전략이다. 그것은 서로 다른 주기의 EMA 평균선을 이용하여 크로스 브레이크를 하고 구매 및 판매 신호를 생성한다. 기본 아이디어는: 짧은 주기의 EMA에서 긴 주기의 EMA를 통과할 때 구매 신호를 생성한다. 짧은 주기의 EMA 아래에서 긴 주기의 EMA를 통과할 때 판매 신호를 생성한다.

전략 원칙

이 전략은 주로 5주기, 8주기 및 13주기 EMA 평균선을 비교하여 거래 신호를 생성한다.

  1. 5주기 EMA, 8주기 EMA 및 13주기 EMA를 계산한다.
  2. 5주기 EMA에 8주기 및 13주기 EMA를 끼면 구매 신호가 발생한다.
  3. 5주기 EMA 아래에서 8주기 및 13주기 EMA를 통과할 때, 판매 신호를 생성한다.
  4. 동시 ADX 지표와 결합하여 트렌드 강도를 판단하고, 트렌드가 충분히 강할 때만 신호를 냅니다.

이렇게 함으로써 중장선 트렌드를 추적하는 효과를 얻을 수 있다. 짧은 주기 평균선 위에 긴 주기 평균선을 통과하면 단기 트렌드가 다면 구매할 수 있다. 짧은 주기 평균선 아래에 긴 주기 평균선을 통과하면 단기 트렌드가 공백으로 전환하면 판매해야 한다.

우위 분석

이 전략은 다음과 같은 장점을 가지고 있습니다.

  1. 작업이 간단하고 실행이 쉽다.
  2. EMA의 평평한 효과를 최대한 활용하여 트렌드를 효과적으로 추적한다.
  3. 다중 그룹 EMA 포트폴리오는 교차를 실행하여 잘못된 신호를 피한다.
  4. ADX 지표와 결합하여 신호를 더욱 신뢰할 수 있게 한다.
  5. 하지만, 이 경우, 이 숫자는 매우 낮습니다.

위험 분석

이 전략에는 몇 가지 위험도 있습니다.

  1. 동향이 급격히 역전될 때, 스톱로스는 더 커질 수 있다. 스톱로스 범위를 적절히 완화할 수 있다.
  2. 거래 빈도가 높기 때문에 거래 비용을 증가시킬 수 있다. 거래 빈도를 낮추기 위해 EMA 매개 변수를 적절히 조정할 수 있다.

최적화 방향

이 전략은 다음과 같은 방향으로 최적화될 수 있습니다.

  1. EMA 변수를 최적화하여 최적의 변수 조합을 찾습니다.
  2. KDJ, BOLL 등과 같은 다른 지표 필터를 추가하여 신호 품질을 향상시킵니다.
  3. 포지션 관리를 조정하고, 위험 관리를 최적화한다.
  4. 기계 학습을 통해 더 나은 출전 및 출전 규칙을 찾아보세요.

요약하다

요약하자면, EMA 골드 크로스 브레이크 전략은 전체적으로 순조롭게 작동하며, 신호는 신뢰성이 높고, 회전이 높지 않으며, 중장선 추세를 추적하는 데 적합하다. 매개 변수 최적화 및 규칙 개선을 통해 더 나은 전략 효과를 얻을 수 있다.

전략 소스 코드
/*backtest
start: 2023-11-23 00:00:00
end: 2023-11-30 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
// 
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © gregoirejohnb
// @It is modified by ttsaadet.
// Moving average crossover systems measure drift in the market. They are great strategies for time-limited people.
// So, why don't more people use them?
// 

//
strategy(title="EMA Crossover Strategy by TTS", shorttitle="EMA-5-8-13 COS by TTS", overlay=true, pyramiding=0, default_qty_type=strategy.percent_of_equity, default_qty_value=100, currency=currency.TRY,commission_type=strategy.commission.percent,commission_value=0.04, process_orders_on_close = true, initial_capital = 100000)

// === GENERAL INPUTS ===
//strategy start date
start_year = input(defval=2020, title="Backtest Start Year")

// === LOGIC ===
short_period = input(type=input.integer,defval=5,minval=1,title="Length")
mid_period = input(type=input.integer,defval=8,minval=1,title="Length")
long_period = input(type=input.integer,defval=13,minval=1,title="Length")
rsi_period = input(type=input.integer,defval=14,minval=1,title="Length")
longOnly = input(type=input.bool,defval=false,title="Long Only")
shortEma = ema(close,short_period)
midEma = ema(close,mid_period)
longEma = ema(close,long_period)

rsi = rsi(close, rsi_period)

[diplus, diminus, adx] = dmi(short_period, short_period)
plot(shortEma,linewidth=2,color=color.red,title="Fast")
plot(midEma,linewidth=2,color=color.orange,title="Fast")
plot(longEma,linewidth=2,color=color.blue,title="Slow")

longEntry = crossover(shortEma,midEma) and crossover(shortEma,longEma) //or ((shortEma > longEma) and crossover(shortEma,midEma)))and (adx > 25)
shortEntry =((shortEma < midEma) and crossunder(shortEma,longEma)) or ((shortEma < longEma) and crossunder(shortEma,midEma))

plotshape(longEntry ? close : na,style=shape.triangleup,color=color.green,location=location.belowbar,size=size.small,title="Long Triangle")
plotshape(shortEntry and not longOnly ? close : na,style=shape.triangledown,color=color.red,location=location.abovebar,size=size.small,title="Short Triangle")
plotshape(shortEntry and longOnly ? close : na,style=shape.xcross,color=color.black,location=location.abovebar,size=size.small,title="Exit Sign")

// === STRATEGY - LONG POSITION EXECUTION ===
enterLong() =>
    longEntry and 
       time > timestamp(start_year, 1, 1, 01, 01)
exitLong() =>
    crossunder(shortEma,longEma) or crossunder(close, longEma)

strategy.entry(id="Long", long=strategy.long, when=enterLong())
strategy.close(id="Long", when=exitLong())


// === STRATEGY - SHORT POSITION EXECUTION ===

enterShort() =>
    not longOnly and shortEntry and 
       time > timestamp(start_year, 1, 1, 01, 01)
exitShort() =>
    crossover(shortEma,longEma)

strategy.entry(id="Short", long=strategy.short, when=enterShort())
strategy.close(id="Short", when=exitShort())