トレンドフィルター移動平均クロスオーバー量的な戦略

作者: リン・ハーンチャオチャン開催日:2023年12月1日 14:25:08
タグ:

img

概要

トレンドフィルター移動平均クロスオーバー定量戦略は,中期から長期間の定量的な取引戦略である.高速および遅い移動平均のクロスオーバーを通じて市場のトレンド方向を決定し,効果的なトレンドを特定するという前提で市場に参入する.同時に,この戦略は,より長いサイクル移動平均をトレンドフィルターとして設定し,価格が移動平均を突破したときのみ有効な取引信号が生成される.

戦略の論理

この戦略は主に移動平均クロスオーバーの原則に基づいている.特に,異なる期間を持つ2つの移動平均が計算され,通常は20日線と50日線に設定される.20日線が50日線を下から上へと突破すると買い信号が生成され,20日線が50日線を上から下へと突破すると売り信号が生成される.これらの単純なクロスオーバー信号は中長期間のブレイクを捕捉すると考えられる.

さらに,戦略は,全体的なトレンドベンチマークとして200日移動平均値を設定する.価格が200日線を突破する時のみ,上記の単純なクロスオーバー信号が有効とみなされる.これは,範囲限定市場で多くの無効な信号を生むのを避けるためのトレンドフィルタリングメカニズムを構成する.

利点分析

  1. 中期から長期間の取引頻度は,過剰な取引を避け,取引コストとスリップリスクを削減します.

  2. 移動平均のクロスオーバー決定は明確で理解し,実行しやすい.

  3. トレンドフィルタリングメカニズムは ほとんどの無効な信号をフィルタリングし 勝率を向上させることができます

  4. 移動平均のパラメータの柔軟な調整は,異なる品種と時間サイクルに適用されます.

  5. ストップ・ロストとテイク・プロフィートは,単一の利益と損失を制御するために設定できます.

リスク分析

  1. 価格が移動平均値の周りに振動すると,複数の無効信号が生成され,過剰取引が起こる可能性があります.

  2. 長期周期移動平均は市場を遅らせて,トレンド逆転点を逃す可能性があります.

  3. 移動平均基準を確立するには,比較的長い過去データが必要であり,新しい種類や短い周期は適用できない.

  4. 戦略パラメータは繰り返しテストと最適化が必要で,不適切な設定は戦略の失敗を引き起こす可能性があります.

リスク軽減

  1. 長いサイクル移動平均を採用するか,傾向フィルタリング条件を増やすか.

  2. 主な傾向を決定するために,エネルギー指標,変動指標など他の指標を組み込む.

  3. 移動平均周期パラメータの適応性を改善する.

  4. 戦略パラメータを動的に調整するためのパラメータ最適化とフィードバックメカニズムを増やす.

戦略の最適化

  1. 線形重量移動平均など 異なる種類の移動平均を試してください

  2. 適応性のある移動平均周期機能を増やす.

  3. 動向平均のクロスオーバーの有効性を向上させる傾向の段階を決定するための変動指標を組み込む.

  4. 機械学習アルゴリズムを導入して 戦略パラメータを自動的に最適化します

  5. 利益のための資産間の相関を活用して多資産組み合わせ戦略を探求する.

概要

トレンドフィルター移動平均クロスオーバー戦略は,全体としてシンプルで実用的な中長期的定量戦略である.移動平均クロスオーバーを通じて中長期的傾向を決定し,その後無効な信号を減らすためにトレンドフィルタリングを使用する.この戦略は,理解し実行しやすく,定量取引の初心者にとって適している利点があります.改善の可能性のある分野は,移動平均の最適化,その他の指標と機械学習アルゴリズムとの統合にあります.基本的な戦略として,より高度な定量仲介アルゴリズムのための取引信号を提供することができます.


/*backtest
start: 2023-11-23 00:00:00
end: 2023-11-30 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

////////////////////////////////////////////////////////////////////////////////
// Booz Strategy
// Developed for Godstime
// Version 1.1
// 11/28/2021
////////////////////////////////////////////////////////////////////////////////

//@version=4
strategy("Booz Strategy", "", true)

// ----------------------------- Inputs ------------------------------------- //
source_ma_type = input("EMA", "Source MA Type", options=["SMA", "EMA"])
source_ma_length = input(50, "Source MA Length")
fast_ma_length = input(20, "Fast MA Length")
slow_ma_length = input(50, "Slow MA Length")        
use_trend_filter = input(true, "Trend Filter")
trend_filter_ma_type = input("EMA", "Trend Filter MA Type", options=["SMA", "EMA"])
trend_filter_ma_length = input(200, "Trend Filter MA Period")
show_mas = input(true, "Show MAs")
swing_trading_mode = input(false, "Swing Trading")

// -------------------------- Calculations ---------------------------------- //
fast_ma = ema(close, fast_ma_length)
slow_ma = ema(close, slow_ma_length)
source_ma = source_ma_type == "EMA"? ema(close, source_ma_length): 
                                     sma(close, source_ma_length)
trend_filter_ma = trend_filter_ma_type == "EMA"? ema(close, trend_filter_ma_length): 
                                                 sma(close, trend_filter_ma_length)

// --------------------------- Conditions ----------------------------------- //
uptrend = not use_trend_filter or close > trend_filter_ma
buy_cond = crossover(fast_ma, slow_ma) and uptrend

downtrend = not use_trend_filter or close < trend_filter_ma
sell_cond = crossunder(fast_ma, slow_ma) and downtrend

// ---------------------------- Plotting ------------------------------------ //
bgcolor(use_trend_filter and downtrend? color.red: use_trend_filter? color.green: na)
plot(show_mas? fast_ma: na, "Fast MA", color.green)
plot(show_mas? slow_ma: na, "Slow MA", color.red)
plot(show_mas? source_ma: na, "Source MA", color.purple)
plot(show_mas? trend_filter_ma: na, "Trend Filter MA", color.blue)


// ---------------------------- Trading  ------------------------------------ //
// Inputs
sl_perc = input(1.0, "Stop Loss (in %)", group="Backtest Control")/100
tp_perc = input(1.0, "Take Profit (in %)", group="Backtest Control")/100
leverage = input(10, "Leverage", maxval=100, group="Backtest Control")
bt_start_time = input(timestamp("2021 01 01"), "Backtest Start Time", input.time, group="Backtest Control")
bt_end_time = input(timestamp("2021 12 31"), "Backtest End Time", input.time, group="Backtest Control")

// Trading Window
in_trading_window = true
trade_qty = 1

// Long Side
strategy.entry("Long Entry", strategy.long, trade_qty, when=buy_cond and in_trading_window)
long_tp = strategy.position_avg_price * (1 + tp_perc)
long_sl = strategy.position_avg_price * (1 - sl_perc)
if not swing_trading_mode
    strategy.exit("Long Exit", "Long Entry", limit=long_tp, stop=long_sl)

// Short Side
strategy.entry("Short Entry", strategy.short, trade_qty, when=sell_cond and in_trading_window)
short_tp = strategy.position_avg_price * (1 - tp_perc)
short_sl = strategy.position_avg_price * (1 + sl_perc)
if not swing_trading_mode
    strategy.exit("Short Exit", "Short Entry", limit=short_tp, stop=short_sl)

// End of trading window close
strategy.close_all(when=not in_trading_window)

もっと