표준편차와 이동평균을 기반으로 한 Elder's Power Index 양적 거래 전략

EFI ATR EMA SMA SD
생성 날짜: 2024-11-28 17:08:24 마지막으로 수정됨: 2024-11-28 17:08:24
복사: 1 클릭수: 498
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

표준편차와 이동평균을 기반으로 한 Elder’s Power Index 양적 거래 전략

개요

이 전략은 Elder’s strength index (EFI) 를 기반으로 한 정량 거래 시스템으로, 표준 차와 이동 평균을 결합하여 신호 판단을 하고, ATR를 사용하여 동적으로 중지 손실을 조정합니다. 이 전략은 빠른 속도와 느린 EFI 지표를 계산하고, 표준화 된 후 교차 신호 판단을 통해 전체 거래 시스템을 구현합니다. 전략은 동적인 중지 및 추적 중지 장치를 채택하여 위험을 효과적으로 제어하면서 더 큰 수익을 추구합니다.

전략 원칙

이 전략은 다음과 같은 핵심 요소들에 기반을 두고 있습니다.

  1. 두 개의 다른 주기 ((13과 50) 의 EFI 지표를 사용하여 빠른 힘과 느린 힘 지수를 계산한다
  2. 두 주기의 EFI에 대한 표준비차 일원화 처리는 신호를 더 통계적으로 의미있게 만듭니다.
  3. 빠른 EFI와 느린 EFI가 상위 표준 차이를 동시에 돌파할 때, 다중 신호를 트리거
  4. 빠른 EFI와 느린 EFI가 동시에 하위 표준 차이를 돌파하면 공백 신호가 발생
  5. ATR을 사용하여 동적으로 중지 위치를 설정하고 가격 변화에 따라 중지 위치를 조정
  6. ATR 기반의 추적 차단 메커니즘을 사용하여 수익을 보호하면서 수익을 계속 증가시킵니다.

전략적 이점

  1. 신호 시스템은 역량과 변동률 특성을 결합하여 거래의 신뢰성을 향상시킵니다.
  2. 표준비동일화 처리를 사용하여 신호를 통계적으로 의미하게 하고 가짜 신호를 감소시킨다.
  3. 다이내믹 스포드 메커니즘은 리스크를 효과적으로 제어하고, 큰 철수를 방지합니다.
  4. 트래킹 중지 메커니즘은 이미 벌어들인 수익을 보호하고 계속 성장할 수 있게 해줍니다.
  5. 전략 논리가 명확하고, 매개 변수가 조정 가능하며, 다양한 시장에 대한 최적화가 가능합니다.

전략적 위험

  1. 급격한 변동 시장에서 가짜 신호가 발생할 수 있으므로 추가 필터링 장치가 필요합니다.
  2. 너무 민감한 변수 선택은 과도한 거래와 거래 비용을 증가시킬 수 있습니다.
  3. 트렌드 전환점에서의 지연이 전략의 성과에 영향을 미칠 수 있습니다.
  4. 부적절한 정지 위치 설정으로 인해 조기 출전 또는 과도한 손실이 발생할 수 있습니다.
  5. 거래 비용이 전략 수익에 미치는 영향을 고려해야 합니다.

전략 최적화 방향

  1. 시장 상황 판단 메커니즘을 추가하여 다른 시장 상태에서 다른 파라미터 설정을 사용합니다.
  2. 교통량 필터를 도입하여 신호의 신뢰성을 높였다.
  3. 시장의 변동에 더 잘 적응할 수 있도록 스톱 스톱 패러미터를 최적화
  4. 트렌드 필터를 추가하여 불안정한 시장에서 자주 거래하는 것을 피하십시오.
  5. 시간 필터를 추가하여 불리한 시간대에 거래하는 것을 피하십시오.

요약하다

이 전략은 EFI 지표, 표준 차수 및 ATR을 결합하여 완전한 거래 시스템을 구축한다. 이 전략의 장점은 신호 시스템의 신뢰성이 높고, 위험 관리가 합리적이지만, 여전히 다양한 시장 환경에 맞게 최적화해야 한다는 것이다. 시장 환경 판단, 거래량 필터링과 같은 메커니즘을 추가함으로써 전략의 안정성과 수익성을 더욱 향상시킬 수 있다.

전략 소스 코드
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-27 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Elder's Force Index Strategy with ATR-Based SL and TP", overlay=true)

// Input parameters for fast and long EFI
efi_fast_length = input.int(13, "Fast EFI Length", minval=1)
efi_long_length = input.int(50, "Long EFI Length", minval=1)
stdev_length = input.int(50, "Standard Deviation Length", minval=2, maxval=300)
numdev = input.float(2, "Number of Deviations", minval=1, maxval=20, step=0.1)
atr_length = input.int(14, "ATR Length", minval=1)
atr_multiplier_sl = input.float(1.5, "ATR Multiplier for Stop Loss", step=0.1)
trailing_tp_multiplier = input.float(0.5, "Multiplier for Trailing Take Profit", step=0.1)

// Elder's Force Index Calculation for Fast and Long EFI
efi_fast = ta.ema((close - close[1]) * volume, efi_fast_length)
efi_long = ta.ema((close - close[1]) * volume, efi_long_length)

// Calculate Standard Deviation for Fast EFI
efi_fast_average = ta.sma(efi_fast, stdev_length)
efi_fast_stdev = ta.stdev(efi_fast, stdev_length)
efi_fast_diff = efi_fast - efi_fast_average
efi_fast_result = efi_fast_diff / efi_fast_stdev

// Calculate Standard Deviation for Long EFI
efi_long_average = ta.sma(efi_long, stdev_length)
efi_long_stdev = ta.stdev(efi_long, stdev_length)
efi_long_diff = efi_long - efi_long_average
efi_long_result = efi_long_diff / efi_long_stdev

// Define upper and lower standard deviation levels
upper_sd = numdev
lower_sd = -numdev

// Define entry conditions based on crossing upper and lower standard deviations
long_condition = efi_fast_result > upper_sd and efi_long_result > upper_sd
short_condition = efi_fast_result < lower_sd and efi_long_result < lower_sd

// Check if a position is already open
is_position_open = strategy.position_size != 0

// Calculate ATR for stop loss and take profit
atr = ta.atr(atr_length)

// Initialize stop loss and take profit variables
var float stop_loss = na
var float take_profit = na

// Execute trades based on conditions, ensuring only one trade at a time
if (long_condition and not is_position_open)
    strategy.entry("Long", strategy.long)
    stop_loss := close - atr * atr_multiplier_sl  // Set initial stop loss based on ATR
    take_profit := close + atr * trailing_tp_multiplier  // Set initial take profit based on ATR

if (short_condition and not is_position_open)
    strategy.entry("Short", strategy.short)
    stop_loss := close + atr * atr_multiplier_sl  // Set initial stop loss based on ATR
    take_profit := close - atr * trailing_tp_multiplier  // Set initial take profit based on ATR

// Update exit conditions
if (is_position_open)
    // Update stop loss for trailing
    if (strategy.position_size > 0)  // For long positions
        stop_loss := math.max(stop_loss, close - atr * atr_multiplier_sl)
        
        // Adjust take profit based on price movement
        take_profit := math.max(take_profit, close + atr * trailing_tp_multiplier)

    else if (strategy.position_size < 0)  // For short positions
        stop_loss := math.min(stop_loss, close + atr * atr_multiplier_sl)
        
        // Adjust take profit based on price movement
        take_profit := math.min(take_profit, close - atr * trailing_tp_multiplier)

    // Set exit conditions
    strategy.exit("Long Exit", from_entry="Long", stop=stop_loss, limit=take_profit)
    strategy.exit("Short Exit", from_entry="Short", stop=stop_loss, limit=take_profit)