극대화 이동 평균 크로스오버 전략을 따르는 경향

저자:차오장, 날짜: 2023-10-17 13:05:29
태그:

img

전반적인 설명

이 전략은 트레이딩 신호를 생성하기 위해 서로 다른 기간의 두 이동 평균의 교차를 사용합니다. 트렌드 다음 전략에 속합니다. 이 전략은 짧은 기간 MA가 더 긴 기간 MA를 넘을 때 신호를 사용하여 트렌드 기회를 포착합니다.

전략 논리

이 전략은 9주기 단기 MA (SMA) 와 50주기 장기 MA (LMA) 를 사용합니다. SMA가 LMA를 넘을 때 구매 신호가 생성됩니다. SMA가 LMA를 넘을 때 판매 신호가 생성됩니다.

이 전략은 또한 트렌드의 강도를 측정하기 위해 RSI 지표를 포함합니다. 거래 신호는 RSI가 임계치 (디폴트 55) 를 넘었을 때만 생성됩니다. 이것은 RSI가 과잉 구매 구역에있을 때 잘못된 신호를 피합니다.

이 전략은 매번 전체 자본의 30%를 거래하며, 한 번에 하나의 포지션만 열립니다. 0.1%의 수수료가 계산됩니다.

이점 분석

  • MA 크로스오버 트렌드 신호를 사용하여 트렌드 기회를 효과적으로 포착합니다.
  • RSI를 포함하면 트렌드가 멈출 때 잘못된 신호를 피할 수 있습니다.
  • 기본 매개 변수는 최적화되어 다양한 시장에서 안정적인 수익을 창출합니다.
  • 합리적인 자본 관리는 너무 큰 포지션 사이즈를 피합니다.

위험 분석

  • 트렌드가 없는 범위에 묶인 시장에서 윙사와 잘못된 신호에 취약합니다.
  • 트렌드를 따르는 전략으로 중요한 트렌드가 없으면 수익이 없습니다.
  • 과도한 거래와 수수료가 매개 변수가 제대로 조정되지 않으면
  • 스톱 로스의 부재로 인해 전략은 이벤트 위험에 노출됩니다.

위험은 매개 변수 최적화, 다른 지표 사용, 엄격한 자본 관리 및 스톱 로스 등을 통해 줄일 수 있습니다.

더 나은 기회

  • 최적의 매개 변수를 찾기 위해 다양한 MA 조합을 테스트합니다.
  • 추세를 확인하기 위해 MACD와 같은 다른 지표를 포함합니다.
  • 트레이드당 손실을 제어하기 위해 동적 스톱 손실을 구현합니다.
  • 다른 시장에 따라 포지션 크기를 조정합니다.
  • 트렌드 강도를 측정하기 위해 볼륨 지표를 사용하십시오.

결론

이 전략은 간단한 MA 크로스오버 시스템을 사용하여 트렌딩 기회를 캡처합니다. 기본 매개 변수는 안정적인 수익으로 최적화되어 알고리즘 거래에 적합합니다. 다른 지표를 추가하고 매개 변수를 최적화하고 스톱 로스를 구현하여 추가 개선이 가능합니다. 전반적으로 크로스오버 신호를 사용하여 트렌딩 시장을위한 효과적인 트렌드 다음 전략입니다.


/*backtest
start: 2023-09-16 00:00:00
end: 2023-10-16 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © relevantLeader16058

//@version=4
strategy(shorttitle='Maximized Moving Average Crossing ',title='Maximized Moving Average Crossing (by Coinrule)', overlay=true, initial_capital=1000,  default_qty_type = strategy.percent_of_equity, default_qty_value = 30, commission_type=strategy.commission.percent, commission_value=0.1)

//Backtest dates
fromMonth = input(defval = 1,    title = "From Month",      type = input.integer, minval = 1, maxval = 12)
fromDay   = input(defval = 1,    title = "From Day",        type = input.integer, minval = 1, maxval = 31)
fromYear  = input(defval = 2020, title = "From Year",       type = input.integer, minval = 1970)
thruMonth = input(defval = 1,    title = "Thru Month",      type = input.integer, minval = 1, maxval = 12)
thruDay   = input(defval = 1,    title = "Thru Day",        type = input.integer, minval = 1, maxval = 31)
thruYear  = input(defval = 2112, title = "Thru Year",       type = input.integer, minval = 1970)

showDate  = input(defval = true, title = "Show Date Range", type = input.bool)

start     = timestamp(fromYear, fromMonth, fromDay, 00, 00)        // backtest start window
finish    = timestamp(thruYear, thruMonth, thruDay, 23, 59)        // backtest finish window
window()  => time >= start and time <= finish ? true : false       // create function "within window of time"

//MA inputs and calculations
inlong=input(50, title='MA long period')
inshort=input(9, title='MA short period')

MAlong = sma(close, inlong)
MAshort= sma(close, inshort)

// RSI inputs and calculations
lengthRSI = (14)

RSI = rsi(close, lengthRSI)
RSI_Signal = input(55, title = 'RSI Trigger', minval=1)

//Entry and Exit
bullish = crossover(MAshort, MAlong)
bearish = crossunder(MAshort, MAlong)

strategy.entry(id="long", long = true, when = bullish and RSI > RSI_Signal and window())
strategy.close(id="long", when = bearish and window())

 
plot(MAshort, color=color.purple, linewidth=2)
plot(MAlong, color=color.red, linewidth=2)

더 많은