크로스 이동 평균 역전 전략

저자:차오장, 날짜: 2024-02-20 13:59:46
태그:

img

전반적인 설명

이것은 간단한 이동 평균 크로스오버를 기반으로 하는 역전 전략이다. 1일 및 5일 간단한 이동 평균을 사용합니다. 짧은 SMA가 더 긴 SMA를 넘을 때, 그것은 길게 간다. 짧은 SMA가 더 긴 SMA를 넘을 때, 그것은 짧게 간다. 이것은 전형적인 트렌드 다음 전략이다.

전략 논리

이 전략은 폐쇄 가격의 1일 SMA (sma1) 와 5일 SMA (sma5) 를 계산한다. sma1이 sma5를 넘을 때, 긴 포지션에 진입한다. sma1이 sma5를 넘을 때, 짧은 포지션에 진입한다. 긴 포지션을 열고 나면, 스톱 로스는 엔트리 가격보다 5 USD 낮고, 이윤은 150 USD 높게 설정된다. 쇼트 포지션의 경우, 스톱 로스는 엔트리보다 5 USD 높고, 이윤은 150 USD 낮게 설정된다.

이점 분석

  • 시장 트렌드를 결정하기 위해 이중 SMA를 사용하여 스톱 로스 이후 손실 거래를 피합니다.
  • SMA 매개 변수 단순하고 합리적, 좋은 백테스트 결과
  • 특정 가격 변동에 견딜 수 있는 작은 스톱 로스
  • 충분한 돈을 벌기 위한 큰 수익 목표

위험 분석

  • 이중 SMA는 윙사 (whipsaws) 에 유연하며, 흔들리는 경우 손실을 멈추는 확률이 높습니다
  • 트렌드 움직임을 파악하기 어렵고, 장기 거래의 이익은 제한적입니다.
  • 제한된 최적화 공간, 쉽게 과장
  • 다른 거래 도구에 대한 매개 변수 조정

개선 방향

  • 잘못된 신호를 피하기 위해 다른 필터를 추가합니다
  • 동적 스톱 로스 및 수익 취득
  • SMA 매개 변수를 최적화
  • 변동성 지수를 위치 크기를 제어하는 것으로 결합합니다.

결론

이 간단한 이중 SMA 전략은 빠른 전략 검증을 위해 이해하기 쉽고 구현하기 쉽습니다. 그러나 제한된 위험 관용과 수익 잠재력을 가지고 있습니다. 더 많은 시장 조건에 적응하기 위해 매개 변수와 필터에 추가 최적화가 필요합니다. 시작 양 전략으로 반복 가능한 개선을위한 기본 빌딩 블록을 포함합니다.


/*backtest
start: 2023-02-19 00:00:00
end: 2024-02-19 00:00:00
period: 2d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Valeria 181 Bot Strategy Mejorado 2.21", overlay=true, margin_long=100, margin_short=100)
 
var float lastLongOrderPrice = na
var float lastShortOrderPrice = na

longCondition = ta.crossover(ta.sma(close, 1), ta.sma(close, 5))
if (longCondition)
    strategy.entry("Long Entry", strategy.long)  // Enter long

shortCondition = ta.crossunder(ta.sma(close, 1), ta.sma(close, 5))
if (shortCondition)
    strategy.entry("Short Entry", strategy.short)  // Enter short

if (longCondition)
    lastLongOrderPrice := close

if (shortCondition)
    lastShortOrderPrice := close

// Calculate stop loss and take profit based on the last executed order's price
stopLossLong = lastLongOrderPrice - 5  // 10 USDT lower than the last long order price
takeProfitLong = lastLongOrderPrice + 151  // 100 USDT higher than the last long order price
stopLossShort = lastShortOrderPrice + 5  // 10 USDT higher than the last short order price
takeProfitShort = lastShortOrderPrice - 150  // 100 USDT lower than the last short order price

// Apply stop loss and take profit to long positions
strategy.exit("Long Exit", from_entry="Long Entry", stop=stopLossLong, limit=takeProfitLong)

// Apply stop loss and take profit to short positions
strategy.exit("Short Exit", from_entry="Short Entry", stop=stopLossShort, limit=takeProfitShort)

더 많은