モメンタム移動平均クロスオーバー戦略


作成日: 2023-09-21 21:29:22 最終変更日: 2023-09-21 21:29:22
コピー: 1 クリック数: 596
1
フォロー
1617
フォロワー

概要

この戦略は,迅速な移動平均と遅い移動平均の交差原理を適用して,市場トレンドの方向を判断し,買取と売却のシグナルを発信する.戦略は,簡単に理解し,簡単に実施し,中短線取引に適用されます.

戦略原則

この戦略は,2つの移動平均線,高速線と遅い線を使用する.高速線は3日EMA,遅い線は15日EMAのパラメータを使用する.戦略は,高速線が下方から遅い線を突破すると,現在上昇傾向にあると判断し,その瞬間は買取信号である.逆に,高速線が上方から下方へ下り,遅い線を破ると,現在下方傾向にあると判断し,その瞬間は売り信号である.

戦略はまた,より速いパラメータである3日間のEMAを急速脱出ラインとして設定している.価格が急速脱出ラインを下回ると,トレンドの逆転が判定され,元の多頭ポジションから脱出すべきである.また,価格が再びこの脱出ラインを突破すると,再び看板に転向し,したがって再入場の信号である.

特定の操作信号の設定は以下の通りです.

  1. スラップラインは,スローラインを突破し,下から上へと進みます.

  2. 速線は上から下へと落ちて 緩慢線を抜けて空きをする.

  3. 価格が急降下線を下回り,株価が上昇

  4. 価格が急降下線を突破し,再び多量生産

戦略的優位性

  • シンプルで,移動平均の2つのパラメータを配置するだけで,非常に簡単に実行できます.

  • 追跡データは充実しており,戦略の有効性を評価するための指標が使用されています.

  • 設定可能なパラメータが多く,パラメータを調整することで戦略を最適化できます.

  • 平均を速やかに移動するストップ・ローズで,リスクをコントロールできます.

  • 戦略が明確で,売り場がはっきりしている.

  • 取引頻度を適正に設定し,取引頻度を過度にするな.

戦略リスク

  • トレンドフォローの戦略として,トレンドが目立たない場合,より多くの偽信号を生成します.

  • 移動平均は後退し,ターニングポイントを逃す可能性があります.

  • 固定パラメータの設定は,市場の変化に適応できないので,パラメータの最適化使用と連携する必要があります.

  • 止損設定が弱すぎて止損が間に合わない

  • 戦略的なシグナルが多く,取引コストが高くなる可能性

  • 取引シグナルが異動する可能性があるので,他の指標と組み合わせて確認してください.

パラメータの最適化,他の指標で補足された確認,適切な緩解の止損基準,適切なタイミングでパラメータを更新するなどの方法によってリスクを制御することができます.

戦略の最適化

  • モバイル平均のパラメータを最適化して,現在の市場特性に適合するようにテストできます.

  • より多くの指標を導入し,組み合わせることで,より強力な戦略システムを作ることができます.

  • 市場に応じてリアルタイムにパラメータを調整する自主的なパラメータ設定を設定できます.

  • 機械学習のアルゴリズムを導入し,より賢明な戦略の最適化を実現します.

  • ダイナミック・ストップを設定し,ストップをトラッキングして,リスクをコントロールできます.

  • 量子エネルギー指標を組み合わせて,誤セットによる偏差を回避できる

要約する

この戦略は,全体として,比較的単純な双動平均線交差戦略である.それは,急速平均線と遅い平均線との交差関係を利用して,市場の傾向と買い売りのタイミングを判断する.戦略の優点は,考えが明確で,実行が容易であり,パラメータ最適化によって異なる市場に適応することができる.しかし,いくつかのリスクも存在し,より多くの指標を導入して検証し,リスクをよく制御する必要がある.もし中線短取引に使用され,継続的な最適化による調整を行うならば,この戦略は,非常に実用的な量化取引システムになることができる.

ストラテジーソースコード
/*backtest
start: 2023-01-01 00:00:00
end: 2023-02-03 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ehaarjee, ECHKAY, JackBauer007

//@version=4
//study(title="Tale_indicators", overlay=true)
strategy("Tale Indicators Strategy", overlay=true, precision=8, max_bars_back=200, pyramiding=0, initial_capital=20000, commission_type="percent", commission_value=0.1)

len_fast = input(3, minval=1, title="FAST EMA")
src_fast = input(close, title="Source for Fast")
fastMA = ema(src_fast, len_fast)
plot(fastMA, title="Slow EMA", color=color.orange)

len_slow = input(15, minval=1, title="SLOW EMA")
src_slow = input(close, title="Source for Slow")
slowMA = ema(src_slow, len_slow)
plot(slowMA, title="Fast EMA", color=color.blue)

len_fast_exit = input(3, minval=1, title="FAST EMA Exit")
src_fast_exit = input(close, title="Source for Fast Exit")
fastMAE = ema(src_fast_exit, len_fast_exit)
plot(fastMAE, title="Fast EMA Ex", color=color.red)


src_slow_enter_short = input(low, title="Source for Short Entry")
slowMASEn = ema(src_slow_enter_short, len_slow)

src_slow_enter_long = input(high, title="Source for Long Entry")
slowMALEn = ema(src_slow_enter_long, len_slow)

src_slow_exit_short = input(low, title="Source for Short Exit")
slowMASEx = ema(src_slow_enter_short, len_slow)

src_slow_exit_long = input(high, title="Source for Long Exit")
slowMALEx = ema(src_slow_enter_long, len_slow)

enter_long = crossover(fastMA, slowMALEn)
enter_short = crossunder(fastMA, slowMASEn)
exit_long = crossunder(fastMAE, slowMALEx)
exit_short = crossover(fastMAE, slowMALEx)

out_enter = iff(enter_long == true, 1, iff(enter_short == true, -1, 0))
plotarrow(out_enter, "Plot Enter Points", colorup=color.green, colordown=color.red, maxheight = 30)

bull = fastMA > slowMALEn
bear = fastMA < slowMASEn

c = bull ? color.green : bear ? color.red  : color.white
bgcolor(c)

exit_tuner = input(0.005, title="Exit Tuner to touch slowEMA")

bull_exit = (bull and (low>(fastMAE*(1+exit_tuner)))) or exit_long or (not(bear) and (fastMAE>high))
bear_exit = (bear and ((fastMAE*(1-exit_tuner))>high)) or exit_short or (not(bull) and (low>fastMAE))

bull_r = (bull and ((bull_exit[1]) or (bull_exit[2] and bull_exit[1])) and (low<=fastMAE))
bear_r = (bear and ((bear_exit[1]) or (bull_exit[2] and bull_exit[1])) and (fastMAE<=high))

bull_re = (bull and (low<slowMALEn)) and not(enter_long)
bear_re = (bear and (high>slowMASEn)) and not(enter_short)

bull_ree = (bull and ((low<slowMALEn) and not(bull_re[1] or enter_long[1]))) 
bear_ree = (bear and ((high>slowMASEn) and not(bear_re[1] or enter_short[1])))

bull_reenter =  (bull_r) and not(enter_long)
bear_reenter =  (bear_r) and not(enter_short)

plotshape(bull_exit, "Plot Bull Exit", style = shape.arrowdown, color=color.green, size=size.small, text="ExL", location=location.abovebar)
plotshape(bear_exit, "Plot Bear Exit", style = shape.arrowup, color=color.red, size=size.small, text="ExS", location=location.belowbar)

plotshape(bull_reenter, "Plot Bull ReEnter", style = shape.arrowup, color=color.green, size=size.small, text="ReL", location=location.belowbar)
plotshape(bear_reenter, "Plot Bear ReEnter", style = shape.arrowdown, color=color.red, size=size.small, text="ReS", location=location.abovebar)

run_strategy = input(true, title="Run Strategy")
// === INPUT BACKTEST RANGE ===
fromMonth = input(defval = 1,    title = "From Month",      type = input.integer, minval = 1, maxval = 12)
fromDay   = input(defval = 1,    title = "From Day",        type = input.integer, minval = 1, maxval = 31)
fromYear  = input(defval = 2020, title = "From Year",       type = input.integer, minval = 2000)
thruMonth = input(defval = 1,    title = "Thru Month",      type = input.integer, minval = 1, maxval = 12)
thruDay   = input(defval = 1,    title = "Thru Day",        type = input.integer, minval = 1, maxval = 31)
thruYear  = input(defval = 2100, title = "Thru Year",       type = input.integer, minval = 2000)

// === INPUT SHOW PLOT ===
showDate  = input(defval = true, title = "Show Date Range", type = input.bool)
// === FUNCTION EXAMPLE ===
start     = timestamp(fromYear, fromMonth, fromDay, 00, 00)        // backtest start window
finish    = timestamp(thruYear, thruMonth, thruDay, 23, 59)        // backtest finish window
window()  => true       // create function "within window of time"

var long_position_open = false
var short_position_open = false


if (enter_long and not(bull_exit) and not(long_position_open))
//    strategy.entry("LO", strategy.long, qty=4)
    long_position_open := true
    if (short_position_open)
//        strategy.close("SO")
        short_position_open := false

if (bull_reenter and not(long_position_open))  
//    strategy.entry("LO", strategy.long, qty=1)
    long_position_open := true

if (bull_exit and long_position_open)
//  strategy.close("LO")
    long_position_open := false
    
if (enter_short and not(bear_exit) and not(short_position_open))
//    strategy.entry("SO", strategy.short, qty=4)
    short_position_open := true
    if(long_position_open)
//        strategy.close("LO")
        long_position_open := false

if (bear_reenter and not(short_position_open))  
//    strategy.entry("SO", strategy.long, qty=1)
    long_position_open := true

if (bear_exit and short_position_open)
//    strategy.close("SO")
    short_position_open := false

if(run_strategy)
    strategy.entry("LO", strategy.long, when=(window() and enter_long), qty=4)
    strategy.entry("LO", strategy.long, when=(window() and bull_reenter and not(long_position_open)), qty=1)
    strategy.close("LO", when=(window() and bull_exit and long_position_open))
    strategy.entry("SO", strategy.short, when=(window() and enter_short), qty=4)
    strategy.entry("SO", strategy.short, when=(window() and bear_reenter and not(short_position_open)), qty=1)
    strategy.close("SO", when=(window() and bear_exit and short_position_open))