이중 EMA 전략 분석 기반


생성 날짜: 2024-02-28 18:07:59 마지막으로 수정됨: 2024-02-28 18:07:59
복사: 1 클릭수: 550
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

이중 EMA 전략 분석 기반

개요

이중 EMA 전략은 트렌드 추적 전략으로, 다른 주기의 EMA를 계산하여 가격의 트렌드 방향을 식별하여 포지션 또는 평소 포지션을 결정한다. 이 전략은 간단하고 실용적이며, 트렌드성이 강한 시장에 적용된다.

전략 원칙

이 전략은 주로 두 개의 EMA 지표, 하나는 짧은 주기 9일 EMA, 다른 하나는 더 긴 주기 21일 EMA에 기초한다. 그들의 교차는 창고 및 창고 신호이다.

단기 EMA 상에서 장기 EMA를 통과할 때, 가격이 상승 추세에 진입한 것으로 간주되며, 이 전략은 이 때 더 많은 주문을 하고, 가격 상승을 추적한다. 단기 EMA 아래에서 장기 EMA를 통과할 때, 가격이 하향 추세에 진입한 것으로 간주되며, 이 전략은 이 때 공명 주문을 하고, 가격 하락을 추적한다.

이 EMA 지표는 가격 데이터의 잡음을 효과적으로 필터링하여 가격 트렌드의 주요 방향을 식별할 수 있습니다. 따라서 이 전략은 더 긴 가격 트렌드 사이클을 잡을 수 있기를 기대하여 쌍 EMA 지표를 포지션 및 포지션의 기초로 사용합니다.

전략적 이점

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

  1. 전략은 간단하고 명확하며 이해하기 쉽고 실행이 가능합니다.
  2. 가격 동향을 효과적으로 식별하고, 동향을 추적하기 위해 적시에 입장을 세울 수 있다.
  3. EMA 지표를 사용하여 소음을 필터링하여 단기 가격 변동의 방해를 피하십시오.
  4. EMA 파라미터를 구성하여 정책의 민감도를 조정할 수 있다.

전략적 위험

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

  1. 동향이 반전될 경우, EMA 지표의 지연 특성은 손실을 증가시킬 수 있다.
  2. EMA 파라미터를 잘못 설정하면 잘못된 신호율이 높아진다.
  3. 이 전략은 강한 추세 시장에 적합하며, 정리할 때 손해가 발생할 수 있습니다.

전략 최적화

이 전략은 다음과 같은 측면에서 최적화될 수 있습니다.

  1. 다른 지표와 결합하여 트렌드 반전을 판단하여 손실을 줄인다. 예를 들어 MACD, KDJ 등이다.
  2. 스톱 로직을 추가하면 좋은 스톱 전략은 전략의 최대 회수량을 크게 줄일 수 있다.
  3. 다양한 품종의 가격 특성에 더 잘 맞도록 EMA 매개 변수를 최적화하십시오.
  4. 기계 학습 알고리즘과 결합하여 EMA 매개 변수의 자동 최적화를 구현한다.

요약하다

이중 EMA 전략은 전체적으로 매우 실용적인 트렌드 추적 전략이다. 그것은 작동하기 쉽고 이해하기 쉽고 강한 트렌드 시장에서 우수한 성능을 발휘한다. 이 전략에는 또한 여러 차원에서 전략의 안정성을 향상시킬 수있는 몇 가지 위험이 있습니다.

전략 소스 코드
/*backtest
start: 2023-02-21 00:00:00
end: 2024-02-27 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
// This can only draw so many lines. Use bar replay to go back further
strategy("Strategy Lines", shorttitle="Strategy Lines", overlay=true, max_lines_count=500)

//###########################################################################################################################################
// Replace your strategy here
//###########################################################################################################################################

shortEMA = ta.ema(close, input(9, title="Short EMA Length"))
longEMA = ta.ema(close, input(21, title="Long EMA Length"))

// Entry conditions for long and short positions
longCondition = ta.crossover(shortEMA, longEMA)
shortCondition = ta.crossunder(shortEMA, longEMA)

//###########################################################################################################################################
// Strategy Lines
//###########################################################################################################################################

var timeLow = bar_index
var line li = na
var openLPrice = 0.0000
var openSPrice = 0.0000

LongWColor = input.color(color.rgb(0,255,0,0),"Long Win Color", group="Strategy Lines")
LongLColor = input.color(color.rgb(0,0,255,0),"Long Loss Color", group="Strategy Lines")
ShortWColor = input.color(color.rgb(255,255,0,0),"Short Win Color", group="Strategy Lines")
ShortLColor = input.color(color.rgb(255,0,0,0),"Short Loss Color", group="Strategy Lines")
WinFontColor = input.color(color.rgb(0,0,0,0),"Win Font Color", group="Strategy Lines")
LossFontColor = input.color(color.rgb(255,255,255,0),"Loss Font Color", group="Strategy Lines")
LinesShowLabel = input(false,"Show Labels?",group = "Strategy Lines")

// // Start new line when we go long
// if strategy.position_size >0
//     line.delete(li)
//     li := line.new(timeLow, close[bar_index-timeLow], bar_index, close, width=2, color=close>openLPrice?LongWColor:LongLColor)

// // Start new line when we go short
// if strategy.position_size <0
//     line.delete(li)
//     li := line.new(timeLow, close[bar_index-timeLow], bar_index, close, width=2, color=close<openSPrice?ShortWColor:ShortLColor)

// //Delete Lines if we don't have a position open
// if strategy.position_size ==0
//     li := line.new(timeLow, close[bar_index-timeLow], bar_index, close, width=2, color=color.rgb(0,0,0,100))
//     line.delete(li)

if LinesShowLabel
    // Short Label
    if strategy.position_size>=0 and strategy.position_size[1] <0
        label.new(
             timeLow, na, 
             text=str.tostring((openSPrice-close[1])/(syminfo.mintick*10)), 
             color=close[1]<openSPrice?ShortWColor:ShortLColor, 
             textcolor=close[1]<openSPrice?WinFontColor:LossFontColor,
             size=size.small, 
             style=label.style_label_down, yloc=yloc.abovebar)
    // Long Label
    if strategy.position_size<=0 and strategy.position_size[1] >0
        label.new(
             timeLow, na,
             text=str.tostring((close[1]-openLPrice)/(syminfo.mintick*10)), 
             color=close[1]>openLPrice?LongWColor:LongLColor, 
             textcolor=close[1]>openLPrice?WinFontColor:LossFontColor,
             size=size.small, 
             style=label.style_label_down, yloc=yloc.abovebar)

// Open long position and draw line
if (longCondition)
    //strategy.entry("Long", strategy.long)
    // timeLow := bar_index
    // li := line.new(timeLow, close[bar_index-timeLow], bar_index, close, width=2, color=close>openLPrice?LongWColor:LongLColor)
    openLPrice := close

// Open short position and draw line
if (shortCondition)
    //strategy.entry("Short", strategy.short)
    // timeLow := bar_index
    // li := line.new(timeLow, close[bar_index-timeLow], bar_index, close, width=2, color=close<openSPrice?ShortWColor:ShortLColor)
    openSPrice := close

//###########################################################################################################################################
// Strategy Execution (Replace this as well)
//###########################################################################################################################################

if (longCondition)
    strategy.entry("Long", strategy.long)

if (shortCondition)
    strategy.entry("Short", strategy.short)