다중 요인 양적 거래 전략

저자:차오장, 날짜: 2024-01-31 13:55:37
태그:

img

전반적인 설명

이것은 여러 가지 기술적 지표를 통합하는 양적 거래 전략입니다. 이동 평균, MACD, 볼링거 밴드, RSI 및 기타 지표를 결합하여 다중 요인 모델에 기반한 자동화 거래를 구현합니다.

전략 논리

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

  1. 이중 이동 평균의 황금 십자와 죽음의 십자
  2. MACD 제로 라인 크로스오버
  3. 볼링거 밴드 상부 및 하부 레일 역전
  4. RSI 과잉 구매 및 과잉 판매 회전

위의 지표가 동시에 구매 또는 판매 신호를 발산하면 전략은 그에 따른 긴 또는 짧은 결정을 내릴 것입니다.

특히, 빠른 이동 평균이 느린 평균을 넘어서면, MACD 히스토그램이 증가하기 시작하면, RSI가 과잉 판매 구역에서 뛰어나고, 가격이 볼링거 밴드 하부 레일에 접근하면, 그것은 긴 진입을위한 트렌드 역전 신호로 간주됩니다.

그리고 빠른 MA가 느린 MA 아래로 넘어가면 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)


더 많은