マルチファクター定量取引戦略に基づく


作成日: 2024-01-31 13:55:37 最終変更日: 2024-01-31 13:55:37
コピー: 0 クリック数: 714
1
フォロー
1617
フォロワー

マルチファクター定量取引戦略に基づく

概要

この戦略は,複数の技術指標を組み合わせた量化取引戦略である.移動平均,MACD,ブリン帯,RSIなどの複数の指標を融合し,多要素モデルで駆動された自動取引を実現する.

戦略原則

この戦略の取引シグナルは以下の部分から得られます.

  1. 移動平均線が金叉死叉になる
  2. MACDは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)