다중 이동 평균 추세와 ATR 동적 손절매 및 손절매를 기반으로 하는 암호화폐 거래 전략

EMA RSI ATR TP/SL CRYPTO
생성 날짜: 2025-02-19 16:50:10 마지막으로 수정됨: 2025-02-20 14:45:33
복사: 0 클릭수: 385
avatar of ianzeng123 ianzeng123
2
집중하다
319
수행원

다중 이동 평균 추세와 ATR 동적 손절매 및 손절매를 기반으로 하는 암호화폐 거래 전략 다중 이동 평균 추세와 ATR 동적 손절매 및 손절매를 기반으로 하는 암호화폐 거래 전략

개요

이 전략은 주로 주류 암호화폐를 대상으로 거래하고, 매일 거래 빈도 제한과 동적 스톱 로즈를 설정하여 위험을 제어합니다. 전략은 9주기, 20주기 및 50주기 3개 지수 이동 평균 (EMA) 을 사용하여 트렌드 방향을 판단하고, 상대적으로 강한 지수 (RSI) 와 평균 실제 파도 (ATR) 를 보조 지수로 사용하여 거래 필터링을 수행합니다.

전략 원칙

이 전략의 핵심 거래 논리는 다음과 같은 핵심 요소를 포함합니다.

  1. 트렌드 판단: 세 개의 EMA ((9/20/50) 를 사용하여 트렌드 방향을 판단합니다. 단기 EMA가 중기 EMA를 통과하고 가격이 장기 EMA 위에있을 때 상승 추세가 확립된 것으로 간주됩니다. 반대로 하향 추세가 확립 된 것으로 간주됩니다.
  2. 거래 필터: RSI ((14) 를 사용하여 과매매 과매매 필터, 구매 신호 요구 RSI 45-70 사이, 판매 신호 요구 RSI 30-55 사이.
  3. 트렌드 강도 확인: 50주기 EMA와 1.1배 이상의 ATR의 거리를 요구하여 트렌드가 충분히 강하다는 것을 확인한다.
  4. 위험 관리: 다른 암호화폐의 변동성에 따라 2.5-3.2배의 ATR의 중지와 3.5-5.0배의 ATR의 중지 설정.
  5. 거래 주파수 제어: 거래 당 최대 1 건의 거래가 허용되며 과도한 거래가 발생하지 않습니다.

전략적 이점

  1. 동적 리스크 관리: ATR을 통해 동적으로 중지 중지 손실 위치를 조정하여 암호화폐 시장의 높은 변동성에 적응합니다.
  2. 차별화 처리: 다른 암호화폐의 변동성 특성에 대해 다른 위험 매개 변수를 설정한다.
  3. 다중 필터링 메커니즘: 트렌드, 동력 및 변동성 지표를 결합하여 거래 품질을 향상시킵니다.
  4. 거래 주파수 제한: 매일 거래 제한을 통해 과도한 거래 위험을 줄이고, 특히 암호화폐 시장의 높은 변동성 특성에 적합하다.
  5. 재원 관리 합리적인: 계좌 크기와 위험 수준에 따라 거래 규모를 동적으로 계산하고, 자금을 안전하게 보호한다.

전략적 위험

  1. 트렌드 리버스 위험: 암호화폐 시장의 급격한 변동으로 인해 큰 손실을 입을 수 있습니다.
  2. 슬라이드 위험: 유동성이 부족할 때 더 큰 슬라이드 위험에 직면할 수 있다.
  3. 거래 기회 제한: 하루 거래 수 제한은 빠른 시장에서 기회를 놓칠 수 있습니다.
  4. 매개 변수 민감성: 여러 지표 매개 변수의 설정은 전략 성능에 영향을 미치며 주기적으로 최적화가 필요합니다.
  5. 시장 환경 의존성: 전략은 추세 시장에서 잘 작동하지만, 흔들림 시장에서는 잘못된 신호를 일으킬 수 있다.

전략 최적화 방향

  1. 시장의 변동 주기 분석을 도입한다: 암호화폐 시장의 다른 변동 주기 역학에 따라 변수를 조정할 수 있다.
  2. 거래 시간 필터링을 최적화: 주요 글로벌 거래 시간대에 기반한 필터링 조건을 추가한다.
  3. 출전 메커니즘을 개선한다: 이동식 중지 또는 시장 감정에 기반한 동적 출전 메커니즘을 추가할 수 있다.
  4. 거래 규모 관리: 시장의 변동에 따라 거래 규모를 동적으로 조정할 수 있다.
  5. 시장 감정 지표를 추가: 거래 필터링을 강화하기 위해 온라인 데이터 또는 소셜 미디어 감정 지표를 도입하십시오.

요약하다

이 전략은 다중 기술 지표의 종합적인 사용으로 비교적 안정적인 암호화폐 거래 시스템을 달성한다. 차별화된 위험 매개 변수 설정과 엄격한 거래 주파수 제어로 수익과 위험을 더 잘 균형 잡는다. 전략의 핵심 장점은 역동적인 위험 관리 장치와 완벽한 필터링 시스템이지만, 암호화폐 시장에 특유의 높은 변동성과 유동성 위험을 고려해야합니다. 지속적인 최적화와 개선으로, 이 전략은 다양한 시장 환경에서 안정적인 성능을 유지할 것으로 예상된다.

전략 소스 코드
/*backtest
start: 2015-02-22 00:00:00
end: 2025-02-18 17:23:25
period: 1h
basePeriod: 1h
*/

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © buffalobillcody

//@version=6
strategy("Backtest Last 2880 Baars Filers and Exits", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=2, backtest_fill_limits_assumption=0)

// Define EMAs
shortEMA = ta.ema(close, 9)
longEMA = ta.ema(close, 20)
refEMA = ta.ema(close, 50)

// **Force Strategy to Trade on Historical Bars**
barLimit = bar_index > 10  // Allow trading on past bars
allowTrade = strategy.opentrades == 0 or barLimit  // Enable first trade on history

// **Define ATR for Stop-Loss & Take-Profit**
atrLength = 14
atrValue = ta.atr(atrLength)
atr50 = ta.sma(atrValue, 50)  // 50-period ATR average

// **Relaxed RSI Filters (More Trades Allowed)**
rsi = ta.rsi(close, 14)
rsiFilterBuy = rsi > 45 and rsi < 70  
rsiFilterSell = rsi < 55 and rsi > 30  

// **Reduce Trend Filter - Allow Smaller Price Movement**
minDistance = atrValue * 1.1  
isTrending = math.abs(close - refEMA) > minDistance  

// **Allow Trading in All Conditions (No ATR Filter)**
atrFilter = true  

// **Allow Flat EMA Slopes - Increase Trade Frequency**
emaSlope = ta.linreg(refEMA, 5, 0) > -0.2  
emaSlopeSell = ta.linreg(refEMA, 5, 0) < 0.2  

// **Trade Counter: Allow 1 Trade Per Day**
var int dailyTradeCount = 0
if dayofweek != dayofweek[1]  
    dailyTradeCount := 0  

// **ATR-Based Stop-Loss & Take-Profit Per Pair**
atrSL = switch syminfo.ticker
    "EURUSD" => 3.0 * atrValue,  
    "USDJPY" => 2.5 * atrValue,  
    "GBPUSD" => 3.0 * atrValue,  
    "AUDUSD" => 3.2 * atrValue,  
    "GBPJPY" => 3.0 * atrValue,  
    => 2.5 * atrValue  

atrTP = switch syminfo.ticker
    "EURUSD" => 3.8 * atrValue,  
    "USDJPY" => 3.5 * atrValue,  
    "GBPUSD" => 4.0 * atrValue,  
    "AUDUSD" => 4.0 * atrValue,  
    "GBPJPY" => 5.0 * atrValue,  
    => 3.5 * atrValue  

// **Ensure Trade Size is Not Zero**
riskPerTrade = 2  
accountSize = strategy.equity
tradeSize = (accountSize * (riskPerTrade / 100)) / atrSL
tradeSize := tradeSize < 1 ? 1 : tradeSize  // Minimum lot size of 1

// **Buy/Sell Conditions (Now More Trades Will Trigger)**
buyCondition = ta.crossover(shortEMA, longEMA) and rsiFilterBuy and close > refEMA and close > longEMA and isTrending and emaSlope and allowTrade and dailyTradeCount < 1
sellCondition = ta.crossunder(shortEMA, longEMA) and rsiFilterSell and close < refEMA and close < longEMA and isTrending and emaSlopeSell and allowTrade and dailyTradeCount < 1

// **Execute Trades**
if buyCondition
    strategy.entry("Buy", strategy.long, qty=tradeSize)
    strategy.exit("Take Profit/Stop Loss", from_entry="Buy", limit=close + atrTP, stop=close - atrSL)
    label.new(x=bar_index, y=low, text="BUY", color=color.green, textcolor=color.white, size=size.small, style=label.style_label_down)
    alert("BUY", alert.freq_once_per_bar_close)  
    dailyTradeCount := dailyTradeCount + 1  

if sellCondition
    strategy.entry("Sell", strategy.short, qty=tradeSize)
    strategy.exit("Take Profit/Stop Loss", from_entry="Sell", limit=close - atrTP, stop=close + atrSL)
    label.new(x=bar_index, y=high, text="SELL", color=color.red, textcolor=color.white, size=size.small, style=label.style_label_up)
    alert("SELL", alert.freq_once_per_bar_close)  
    dailyTradeCount := dailyTradeCount + 1  

// **Plot Indicators**
plot(shortEMA, color=color.yellow, title="9 EMA")
plot(longEMA, color=color.fuchsia, title="20 EMA")
plot(refEMA, color=color.blue, title="50 EMA")