다중 요인 양적 거래 전략 기반


생성 날짜: 2024-01-31 13:55:37 마지막으로 수정됨: 2024-01-31 13:55:37
복사: 0 클릭수: 714
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

다중 요인 양적 거래 전략 기반

개요

이 전략은 여러 기술 지표와 결합된 양적 거래 전략이다. 그것은 이동 평균, MACD, 브린 밴드, RSI 등과 같은 여러 지표를 결합하여 다인자 모델에 구동된 자동 거래를 구현한다.

전략 원칙

이 전략의 거래 신호는 다음과 같은 부분에서 나옵니다.

  1. 이중 이동 평균은 골드 포크를 형성합니다.
  2. MACD는 0축 상단과 0축 하단으로 형성됩니다.
  3. 브린이 역전선에 올랐다.
  4. RSI는 매도와 매도 지대를 뒤집습니다.

위와 같은 여러 지표가 동시에 구매 또는 판매 신호를 발신할 때, 이 전략은 그에 따른 구매 또는 판매 포지션 개시 또는 매각 작업을 수행한다.

구체적으로, 빠른 이동 평균이 느린 이동 평균을 통과하고 MACD 히스토그램이 기둥 모양으로 성장하면 RSI가 초과 지역에서 반발하고 가격이 브린의 하향 궤도에 가까워지면 거래가 반전되었다고 생각하여 구매 신호를 생성합니다.

빠른 이동 평균 아래의 느린 이동 평균을 통과하면 MACD 히스토그램은 기둥이 줄어들며 RSI는 초고의 구매 지역에서 내려가며 가격이 브린 대역에 가까워지면 판매 신호가 발생합니다.

이러한 다중 지표 조합을 통해 신호를 발산하면, 가짜 신호를 효과적으로 필터링하여 전략의 안정성을 향상시킬 수 있다.

우위 분석

이 전략의 가장 큰 장점은 다중 요소 모델을 사용하여 거래하는 것으로 신호의 신뢰성을 높이고 전략의 안정성과 수익률을 높일 수 있습니다.

  1. 다인자 모델은 거래 신호를 서로 확인하여 가짜 신호의 간섭을 효과적으로 줄일 수 있다.

  2. 다양한 카테고리의 지표는 시장의 상황을 더 포괄적으로 파악하여 보다 정확한 판단을 할 수 있습니다.

  3. 다중 요소의 조합은 단일 지표의 현존하는 흔들림 특성을 평형화하여 수익을 더 안정적으로 보장할 수 있다.

  4. 포트폴리오의 지표와 각각의 지표의 무게를 조정할 수 있는 유연성, 다른 시장에 맞는 개인화 전략.

위험 분석

이 전략에는 몇 가지 위험도 있습니다.

  1. 복잡한 다중 지표 조합, 변수 설정 및 지표 선택은 정확한 계산과 테스트를 필요로 하며, 그렇지 않으면 실패 신호가 발생하기 쉽다.

  2. 단일 품종 효과는 불안정할 수 있으며, 적절한 품종 조합을 선택하여 단일 품종 위험을 분산하는 크로스 품종 거래가 필요합니다.

  3. 극한상황으로 인한 손실 확산을 막기 위해 포지션 규모와 손해배상 전략을 엄격히 통제해야 한다.

최적화 방향

이 전략에는 다음과 같은 몇 가지 개선방향이 있습니다.

  1. 더 많은 지표의 조합을 테스트하여 최적의 파라미터를 찾습니다. 예를 들어 변동률, 거래량과 같은 다른 지표가 포트폴리오에 포함됩니다.

  2. 기계 학습 방법을 사용하여 최적의 전략 조합과 매개 변수 구성을 자동으로 생성합니다.

  3. 더 긴 시간 스케일에서 테스트하고 최적화하고, 다른 시장 단계에 맞게 무게를 조정한다.

  4. 리스크 관리 도구와 결합하여, 단편적 스톱 손실과 전체 포지션을 엄격하게 제어한다.

요약하다

이 전략은 다양한 거래 지표를 종합적으로 사용하여 다중 인자 모델을 형성하고, 다양한 지표의 장점을 효과적으로 활용하여 신호 판단 능력을 강화합니다. 또한 위험 예방에 주의를 기울여야하며, 매개 변수 최적화 및 업데이트를 통해 전략의 안정성과 수익성을 지속적으로 향상시킬 수 있습니다.

전략 소스 코드
/*backtest
start: 2023-12-31 00:00:00
end: 2024-01-30 00:00:00
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Математическая Торговая Система с Ишимоку, TP/SL, ADX, RSI, OBV", shorttitle="МТС Ишимоку TP/SL ADX RSI OBV", overlay=true)

is_short_enable = input(0, title="Короткие сделки")
is_long_enable = input(1, title="Длинные сделки")

// Входные параметры для скользящих средних
fast_length = input(21, title="Быстрый период")
slow_length = input(26, title="Медленный период")

// Входные параметры для Ишимоку
tenkan_length = input(9, title="Тенкан-сен")
kijun_length = input(26, title="Киджун-сен")
senkou_length = input(52, title="Сенкоу-спан B")

// Входные параметры для ADX
adx_length = input(14, title="ADX период")
adx_level = input(30, title="ADX уровень")

// Входные параметры для RSI
rsi_length = input(14, title="RSI период")
rsi_overbought = input(70, title="RSI перекупленность")
rsi_oversold = input(30, title="RSI перепроданность")

// Входные параметры для OBV
obv_length = input(14, title="OBV период")

// Вычисление скользящих средних
fast_ma = ta.sma(close, fast_length)
slow_ma = ta.sma(close, slow_length)

// Вычисление Ишимоку
tenkan_sen = ta.sma(high + low, tenkan_length) / 2
kijun_sen = ta.sma(high + low, kijun_length) / 2
senkou_span_a = (tenkan_sen + kijun_sen) / 2
senkou_span_b = ta.sma(close, senkou_length)

// Вычисление ADX
[diplus, diminus, adx_value] = ta.dmi(14, adx_length)

// Вычисление RSI
rsi_value = ta.rsi(close, rsi_length)

// Вычисление OBV
f_obv() => ta.cum(math.sign(ta.change(close)) * volume)
f_obv_1() => ta.cum(math.sign(ta.change(close[1])) * volume[1])
f_obv_2() => ta.cum(math.sign(ta.change(close[2])) * volume[2])
f_obv_3() => ta.cum(math.sign(ta.change(close[3])) * volume[3])
obv_value = f_obv()

price_is_up = close[1] > close[3] 
price_crossover_fast_ma = close > fast_ma
fast_ma_is_up = ta.sma(close[1], fast_length) > ta.sma(close[3], fast_length)
rsi_is_trand_up = ta.rsi(close[1], rsi_length) > ta.rsi(close[3], rsi_length)
rsi_is_upper_50 = rsi_value > 50
obv_is_trand_up = f_obv_1() > f_obv_3() and obv_value > ta.sma(obv_value, obv_length)
is_up = price_is_up and price_crossover_fast_ma and fast_ma_is_up and rsi_is_trand_up and rsi_is_upper_50 and obv_is_trand_up

fast_ma_is_down = close < fast_ma
rsi_is_trend_down =  ta.rsi(close[1], rsi_length) < ta.rsi(close[2], rsi_length)
rsi_is_crossover_sma = rsi_value < ta.sma(rsi_value, rsi_length)
obv_is_trend_down =  f_obv_1() < f_obv_2()
obv_is_crossover_sma = obv_value < ta.sma(obv_value, obv_length)
is_down = fast_ma_is_down and rsi_is_trend_down and rsi_is_crossover_sma and obv_is_trend_down and obv_is_crossover_sma

//----------//
// MOMENTUM //
//----------//
ema8 = ta.ema(close, 8)
ema13 = ta.ema(close, 13)
ema21 = ta.ema(close, 21)
ema34 = ta.ema(close, 34)
ema55 = ta.ema(close, 55)

longEmaCondition = ema8 > ema13 and ema13 > ema21 and ema21 > ema34 and ema34 > ema55
exitLongEmaCondition = ema13 < ema55

shortEmaCondition = ema8 < ema13 and ema13 < ema21 and ema21 < ema34 and ema34 < ema55
exitShortEmaCondition = ema13 > ema55

// ----------  //
// OSCILLATORS //
// ----------- //
rsi = ta.rsi(close, 14)
longRsiCondition = rsi < 70 and rsi > 40
exitLongRsiCondition = rsi > 70

shortRsiCondition = rsi > 30 and rsi < 60
exitShortRsiCondition = rsi < 30

// Stochastic
length = 14, smoothK = 3, smoothD = 3
kFast = ta.stoch(close, high, low, 14)
dSlow = ta.sma(kFast, smoothD)

longStochasticCondition = kFast < 80
exitLongStochasticCondition = kFast > 95

shortStochasticCondition = kFast > 20
exitShortStochasticCondition = kFast < 5

// Логика входа и выхода
longCondition = longEmaCondition and longRsiCondition and longStochasticCondition and strategy.position_size == 0
exitLongCondition = (exitLongEmaCondition or exitLongRsiCondition or exitLongStochasticCondition) and strategy.position_size > 0

shortCondition = shortEmaCondition and shortRsiCondition and shortStochasticCondition and strategy.position_size == 0
exitShortCondition = (exitShortEmaCondition or exitShortRsiCondition or exitShortStochasticCondition) and strategy.position_size < 0

enter_long = (ta.crossover(close, senkou_span_a) or is_up) and longCondition
enter_short = (ta.crossunder(close, senkou_span_a) or is_down) and shortCondition

exit_long = ((ta.crossunder(fast_ma, slow_ma) or ta.crossunder(close, senkou_span_b) or enter_short) or exitLongCondition) 
exit_short = ((ta.crossover(fast_ma, slow_ma) or ta.crossover(close, senkou_span_b) or enter_long) or exitShortCondition)

// Выполнение сделок
if is_long_enable == 1
    strategy.entry("Long", strategy.long, when=enter_long)
    strategy.close("Long", when=exit_long)

if is_short_enable == 1
    strategy.entry("Short", strategy.short, when=enter_short)
    strategy.close("Short", when=exit_short)