
移動平均線交差取引戦略は,より一般的な量化取引戦略である.この戦略は,異なる周期の移動平均を計算し,それらの交差状況に応じて取引信号を生成する.具体的には,4周期,8周期および20周期の指数移動平均を計算し,短期EMAで長期EMAを突破すると,多めに行い,短期EMAで長期EMAを破ると,空っぽに行い.
この戦略の核心的な論理は:
この方法では,異なる周期平均線の交差を活用して市場シグナルを判断し,最も長い周期平均線の方向を活用して誤った信号をフィルターし,安定した取引戦略を構築します.
この戦略の利点は以下の通りです.
この戦略にはいくつかのリスクがあります.
解決策は以下の通りです.
この戦略は以下の点で最適化できます.
4.モデル融合:LSTM,RNNなどの深層学習モデルと統合し,より多くのAlphaを抽出する
移動平均線交差戦略は,全体として,より古典的で一般的な量化取引戦略である.この戦略の論理は単純で,容易に理解し,実行し,一定の安定性がある.しかし,偽信号を生成し,市場の変化に適応できないなど,いくつかの問題もある.これらの問題は,パラメータ最適化,ストップ損失最適化,モデル融合などの方法によって改善することができる.全体として,移動平均線戦略は,戦略ツールキットの基本的なモジュールとして,他のより複雑な戦略と組み合わせて,安定した複合戦略を構築することができる.
/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
//future strategy
//strategy(title = "stub", default_qty_type = strategy.fixed, default_qty_value = 1, overlay = true, commission_type=strategy.commission.cash_per_contract,commission_value=2.05)
//stock strategy
strategy(title = "stub", overlay = true)
//forex strategy
//strategy(title = "stub", default_qty_type = strategy.percent_of_equity, default_qty_value = 100, overlay = true)
//crypto strategy
//strategy(title = "stub", default_qty_type = strategy.percent_of_equity, default_qty_value = 100, overlay = true, commission_type=strategy.commission.percent,commission_value=.0,default_qty_value=10000)
testStartYear = input(1900, "Backtest Start Year")
testStartMonth = input(1, "Backtest Start Month")
testStartDay = input(1, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)
testEndYear = input(2018, "Backtest Start Year")
testEndMonth = input(12, "Backtest Start Month")
testEndDay = input(1, "Backtest Start Day")
testPeriodEnd = timestamp(testStartYear,testStartMonth,testStartDay,0,0)
testPeriod() => true
ema1 = ema(close,4)
ema2 = ema(close,8)
ema3 = ema(close,20)
go_long = ema1[0] > ema2[0] and ema3[0] > ema3[1]
exit_long = ema1[0] < ema2[0] or ema3[0] < ema3[1]
go_short = ema1[0] < ema2[0] and ema3[0] < ema3[1]
exit_short = ema1[0] > ema2[0] or ema3[0] > ema3[1]
if testPeriod()
strategy.entry("simpleBuy", strategy.long, when=go_long)
strategy.exit("simpleBuy", "simpleSell",when=exit_long)
strategy.entry("simpleSell", strategy.short,when=go_short)
strategy.exit("simpleSell", "simpleSell",when=exit_short)