간단한 이동평균 크로스오버 전략

저자:차오장, 날짜: 2023-09-21 10:47:24
태그:

전반적인 설명

이 전략은 3개의 간단한 이동 평균의 황금 십자와 죽은 십자 기반의 거래를 한다. 빠른 SMA가 중간 SMA를 넘어서고 중간 SMA가 느린 SMA를 넘어서면 긴 거리로 이동한다. 역차가 발생하면 짧은 거리로 이동한다.

전략 논리

  1. 서로 다른 기간을 가진 3개의 SMA를 설정합니다. 빠른, 중간, 느린
  2. 빠른 SMA가 중간 SMA와 중간 느린 SMA를 넘을 때 길게 이동합니다.
  3. 빠른 SMA가 중간 SMA 아래와 중간 느린 SMA 아래를 넘을 때 짧게 이동합니다.
  4. 잘못된 유출을 방지하기 위해 입력 지연을 설정할 수 있습니다
  5. 리버스 크로스오버 신호가 발사되면 출구

특히, 다른 기간의 3 개의 SMA 사이의 교차점을 활용하여 거래합니다. 빠른 SMA는 단기 트렌드를 나타냅니다. 중간 SMA는 중기 트렌드를 나타냅니다. 느린 SMA는 장기 트렌드를 나타냅니다. 세 개의 SMA가 순차적으로 상향으로 교차할 때, 그것은 길게 갈 상승 추세를 신호합니다. 하향 교차가 발생하면, 그것은 짧게 갈 하락 추세를 신호합니다. 엔트리 지연은 단기 가짜 브레이크오트를 피하기 위해 설정 될 수 있습니다.

이점 분석

  1. 3개의 SMA를 사용하면 방향 정확도가 향상됩니다.
  2. 늦은 출입은 가짜 탈출과 함정에 빠지는 것을 피합니다.
  3. 단순하고 직관적인 논리, 이해하기 쉬운
  4. 다양한 사이클에 대한 유연한 SMA 매개 변수 조정
  5. 트렌드를 따라가는 것은 역트렌드 위험을 피합니다.

위험 분석

  1. 장기 주기의 장기 보유 위험 손실 확장
  2. SMA 크로스오버는 약간의 지연이 있고, 최고의 입구점을 놓칠 수 있습니다.
  3. SMA 매개 변수 최적화가 필요, 그렇지 않으면 신호가 정확하지 않을 수 있습니다.
  4. 장기 보유는 하루 하루 위험을 가져옵니다.

리스크는 포지션 사이즈, SMA 최적화, 스톱 로스 전략 등을 통해 관리 할 수 있습니다.

최적화 방향

  1. 최적의 매개 변수를 찾기 위해 다른 SMA 기간을 테스트합니다.
  2. 신호를 필터링하기 위해 입력 지연을 평가
  3. 실제 가격 동작에 적응할 수 있는 스톱 로스를 도입
  4. 다른 제품에서 연구 매개 변수 선호
  5. 유지를 최적화하기 위해 재입입수 추가 및 피라미드 규칙 테스트

요약

이 전략은 트렌드 방향을 결정하기 위해 3 개의 SMA 크로스오버에 기반한 포지션을 보유하고 있습니다. 장점은 간단한 명확한 신호 및 구성 가능성입니다; 단점은 지연 신호 및 매개 변수 의존성입니다. 매개 변수 최적화, 스톱 로스 등을 통해 성능을 향상시키고 위험을 제어 할 수 있습니다. 이는 거래자가 SMA 및 크로스오버 전략을 사용하여 마스터하는 데 도움이됩니다.


/*backtest
start: 2023-08-21 00:00:00
end: 2023-09-20 00:00:00
period: 3h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// © DaynTrading

//@version=4
// strategy(
//      title="Simple Moving Average Cross",
//      overlay=true,
//      initial_capital=5000,
//      default_qty_type=strategy.percent_of_equity,
//      default_qty_value=2,
//      commission_type=strategy.commission.percent,
//      commission_value=0.075,
//      pyramiding=0
//      )

sma_top_input = input(title="SMA Top", type=input.integer, defval=20)
sma_mid_input = input(title="SMA Mid", type=input.integer, defval=50)
sma_low_input = input(title="SMA Low", type=input.integer, defval=200)

bars_long = input(title="Long: After trigger, how many bars to wait?", type=input.integer, defval=5)
bars_short = input(title="Short: After trigger, how many bars to wait?", type=input.integer, defval=5)

sma_top = sma(close, sma_top_input)
sma_mid = sma(close, sma_mid_input)
sma_low = sma(close, sma_low_input)

long = sma_top > sma_mid and sma_mid > sma_low
short = sma_top < sma_mid and sma_mid < sma_low

long_condition = long and long[bars_long] and not long[bars_long + 1]
short_condition = short and short[bars_short] and not short[bars_short + 1]

close_long = sma_top < sma_mid and sma_mid < sma_low and not long[bars_long + 1]
close_short = sma_top > sma_mid and sma_mid > sma_low and not short[bars_short + 1]

plot(sma_top, title="SMA Top", color=#95f252, linewidth=2)
plot(sma_mid, title="SMA Mid", color=#FF1493, linewidth=2)
plot(sma_low, title="SMA Low", color=#6a0dad, linewidth=2)

strategy.entry("LongPosition", strategy.long, when = long_condition)
strategy.entry("ShortPosition", strategy.short, when = short_condition)
    
strategy.close("LongPosition", when = close_short)
strategy.close("ShortPosition", when = close_long)

더 많은