더블 이동 평균 교차 전략


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

더블 이동 평균 교차 전략

개요

이 전략은 쌍평균선 교차에 기반한 트렌드 추적 전략이다. 그것은 빠른 간단한 이동 평균 ((SMA) 과 느린 중화 이동 평균 ((VWMA) 을 결합하여 두 평균선의 교차를 이용하여 구매 및 판매 신호를 형성한다.

빠른 SMA가 느린 VWMA를 상향으로 통과하면 구매 신호가 발생하고, 빠른 SMA가 느린 VWMA를 상향으로 통과하면 판매 신호가 발생한다.

전략 원칙

이 전략의 핵심 논리는 이중 평행선 교차 시스템을 기반으로 합니다. 구체적으로, 다음과 같은 기술 지표를 동시에 사용합니다:

  1. 간단한 이동 평균 ((SMA): 최근 n일간의 종결 가격의 수학적 평균을 취하여 최근 기간의 평균 가격을 반영한다.
  2. 가중 이동 평균 ((VWMA): 최근 n일 종결 가격에 가중된 평균을 사용하여, 최근 가격에 더 큰 무게를 부여하여 가격 변화에 더 빠르게 반응할 수 있다.

이중 평균선에서의 빠른 SMA 파라미터 설정이 짧아서 가격 변화에 빠르게 반응할 수 있습니다. 느린 VWMA 파라미터이 길어서 파동 작용을 합니다. 단기 및 장기 트렌드가 같은 방향으로 진행될 때, 빠른 SMA는 느린 VWMA를 상향으로 통과하면 구매 신호를 생성합니다. 아래로 통과하면 판매 신호를 생성합니다.

이 전략은 동시에 손해 제도를 설정한다. 가격이 불리한 방향으로 움직일 때, 위험을 통제하기 위해 제 시간에 손해를 막는다.

우위 분석

  1. 빠르게 반응하고, 시장 추세 변화에 따라
  2. 회수 통제, 위험 통제
  3. 간단하고 직관적이고 이해하기 쉬운 구현
  4. 다른 시장 환경에 적응하여 파라미터를 조정하여 최적화 할 수 있습니다.

위험 분석

  1. 이중평균형 전략은 다중 시장의 잘못된 신호를 유발할 수 있습니다.
  2. 적절한 매개 변수를 선택해야 합니다. 잘못 설정하면 손실이 발생할 수 있습니다.
  3. 가끔은 Markt의 갑작스러운 사건으로 인해 머리가 아프기도 합니다.

위험 관리 방법:

  1. 트렌드 필터링을 사용하여 확인
  2. 최적화 변수 설정
  3. 단독 손실을 적절하게 통제하기 위한 손실 차단 전략

최적화 방향

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

  1. 다른 기술 지표와 함께 확인, 예를 들어 RSI, 브린 라인 등, 신호의 정확성을 향상
  2. 평균선 변수의 길이를 최적화하여 다른 주기에 따라 변수를 조정합니다.
  3. 거래량 지표와 결합하여 많은 에너지의 입출력 지점에서 거래
  4. 역 측정 결과에 따라 파라미터를 조정하고 최적의 파라미터를 선택합니다.
  5. 동적 스톱을 사용하여 시장의 변동에 따라 스톱 포인트를 조정합니다.

요약하다

이 전략은 전체적으로 매우 실용적인 트렌드 추적 전략이다. 그것은 간단한 직관적 이중 평균선 교차를 사용하여 거래 신호를 생성하고, 빠른 평균선과 느린 평균선의 조합을 통해 시장 추세의 변화를 효과적으로 포착할 수 있다.

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

//@version=4
//strategy(title="Bitlinc Entry v0.1 VWMA / SMA / MRSI SQQQ 94M", overlay=true, initial_capital=10000, currency='USD')

strategy(title="Bitlinc Entry v0.1 VWMA / SMA / MRSI SQQQ 94M", overlay=true)

// Credit goes to this developer for the "Date Range Code"
// https://www.tradingview.com/script/62hUcP6O-How-To-Set-Backtest-Date-Range/

// === GENERAL INPUTS ===
// short ma
maFastSource   = input(defval = close, title = "Simple MA Source")
maFastLength   = input(defval = 6, title = "Simple MA Length", minval = 1)
// long ma
maSlowSource   = input(defval = high, title = "VW MA Source")
maSlowLength   = input(defval = 7, title = "VW MA Period", minval = 1)


// === SERIES SETUP ===
// a couple of ma's...
maFast = sma(maFastSource, maFastLength)
maSlow = vwma(maSlowSource, maSlowLength)


// === PLOTTING ===
fast = plot(maFast, title = "Fast MA", color = color.green, linewidth = 2, style = plot.style_line, transp = 30)
slow = plot(maSlow, title = "Slow MA", color = color.red, linewidth = 2, style = plot.style_line, transp = 30)

// === INPUT BACKTEST RANGE ===
FromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
FromDay   = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
FromYear  = input(defval = 2018, title = "From Year", minval = 2017)
ToMonth   = input(defval = 1, title = "To Month", minval = 1, maxval = 12)
ToDay     = input(defval = 1, title = "To Day", minval = 1, maxval = 31)
ToYear    = input(defval = 9999, title = "To Year", minval = 2017)

// === FUNCTION EXAMPLE ===
start     = timestamp(FromYear, FromMonth, FromDay, 00, 00)  // backtest start window
finish    = timestamp(ToYear, ToMonth, ToDay, 23, 59)        // backtest finish window
window()  => time >= start and time <= finish ? true : false // create function "within window of time"

// === LOGIC ===
enterLong = crossover(maFast, maSlow)
exitLong = crossover(maSlow, maFast)
//enterLong = crossover(maSlow, maFast)
//exitLong = crossover(maFast, maSlow)

// Entry //
strategy.entry(id="Long Entry", long=true, when=window() and enterLong)
strategy.entry(id="Short Entry", long=false, when=window() and exitLong)

// === FILL ====
fill(fast, slow, color = maFast > maSlow ? color.green : color.red)

// === MRSI ===
//
//

basis = rsi(close, input(50))

ma1 = ema(basis, input(2))
ma2 = ema(basis, input(27))

oversold = input(32.6)
overbought = input(63)

//plot(ma1, title="RSI EMA1", color=blue)
//plot(ma2, title="RSI EMA2", color=yellow)

obhist = ma1 >= overbought ? ma1 : overbought
oshist = ma1 <= oversold ? ma1 : oversold

//plot(obhist, title="Overbought Highligth", style=columns, color=color.maroon, histbase=overbought)
//plot(oshist, title="Oversold Highligth", style=columns, color=color.yellow, histbase=oversold)

//i1 = hline(oversold, title="Oversold Level", color=white)
//i2 = hline(overbought, title="Overbought Level", color=white)

//fill(i1, i2, color=olive, transp=100)

// === LOGIC ===
enterLongMrsi = crossover(ma1, oversold)
exitLongMrsi = crossover(ma1, overbought)

// Entry //
strategy.entry(id="MRSI Long Entry", long=true, when=window() and enterLongMrsi)
strategy.entry(id="MRSI Short Entry", long=false, when=window() and exitLongMrsi)

//hline(50, title="50 Level", color=white)