ダブル移動平均クロスオーバー戦略


作成日: 2023-12-01 18:18:16 最終変更日: 2023-12-01 18:18:16
コピー: 2 クリック数: 668
1
フォロー
1619
フォロワー

ダブル移動平均クロスオーバー戦略

概要

この戦略は,二重平均線交差に基づくトレンド追跡戦略である.それは,迅速なシンプル移動平均 ((SMA)) とゆっくりとした重み付けの移動平均 ((VWMA) を組み合わせて,2つの平均線の交差を利用して,買入と売却のシグナルを形成する.

速いSMAがゆっくりVWMAを上向きに通過すると,買いのシグナルが生成され,速いSMAがゆっくりVWMAを下向きに通過すると,売りのシグナルが生成されます. 戦略は,ストップ・ロスのメカニズムを使用してリスクを制御します.

戦略原則

この戦略の核心的な論理は,二重均線交差系に基づいています.具体的には,以下の技術指標を同時に使用しています.

  1. 単純移動平均 ((SMA):近日n日の閉店価格の算術平均を取って,近期間の平均価格を反映する.
  2. 重量移動平均 ((VWMA):最近n日の閉盘価格の重量移動平均,近期価格により大きな重みを与え,価格の変化により迅速に反応する.

双均線における急速SMAのパラメータは短く設定され,価格の変化に迅速に反応する.緩慢VWMAのパラメータは長く,波作用がある.短期および長期のトレンドが同じ方向に進んでいるとき,急速SMAは,緩慢VWMAを上方横断すると,買入信号を生じ,下方横断すると,売り信号を生じます.

この戦略は同時に,価格が不利な方向に走るときに,リスクを制御するために,タイミングでストップするメカニズムを設定する.

優位分析

  1. 市場動向の変化に迅速に対応する
  2. 撤収はコントロールされ,止損メカニズムがリスクをコントロールする
  3. シンプルで直感的で理解しやすい
  4. パラメータの調整により,異なる市場環境に対応して最適化できます.

リスク分析

  1. 双重均線戦略は多頭市場への偽信号を容易にする
  2. 適切なパラメータを選択し,誤った設定で損失を発生させる
  3. Marktの突発的な事件によって,時折頭痛が起こることもあります.

リスク管理の方法:

  1. トレンドフィルターで確認
  2. パラメータの設定を最適化
  3. 損失を抑える戦略を導入し,単一損失を合理的に制御する

最適化の方向

この戦略は以下の点で最適化できます.

  1. RSI,ブリンラインなどの他の技術指標と組み合わせて確認し,信号の正確性を向上させる
  2. 平均線参数長さを最適化して,異なる周期に応じて参数調整
  3. 取引量指数と組み合わせて,大量のエネルギーが入る出力点で取引する
  4. 回測結果に応じてパラメータを調整し,最適なパラメータを選択
  5. ダイナミックストップを使用して,市場の変動に応じてストップポイントを調整します.

要約する

この戦略は全体的に非常に実用的なトレンド追跡戦略である.これは,簡単な直感的な二重平均線交差を用い,取引信号を生成し,急速平均線と遅い平均線を組み合わせることで,市場のトレンドの変化を効果的に捉えることができる.ストップダストメカニズムは,また,優れたリスク管理を可能にする.他の指標とパラメータの最適化と組み合わせることで,戦略の取引効果をさらに向上させることができる.

ストラテジーソースコード
/*backtest
start: 2023-11-23 00:00:00
end: 2023-11-28 00:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
//strategy(title="Bitlinc Entry v0.1 VWMA / SMA / MRSI SQQQ 94M", overlay=true, initial_capital=10000, currency='USD')

strategy(title="Bitlinc Entry v0.1 VWMA / SMA / MRSI SQQQ 94M", overlay=true)

// Credit goes to this developer for the "Date Range Code"
// https://www.tradingview.com/script/62hUcP6O-How-To-Set-Backtest-Date-Range/

// === GENERAL INPUTS ===
// short ma
maFastSource   = input(defval = close, title = "Simple MA Source")
maFastLength   = input(defval = 6, title = "Simple MA Length", minval = 1)
// long ma
maSlowSource   = input(defval = high, title = "VW MA Source")
maSlowLength   = input(defval = 7, title = "VW MA Period", minval = 1)


// === SERIES SETUP ===
// a couple of ma's...
maFast = sma(maFastSource, maFastLength)
maSlow = vwma(maSlowSource, maSlowLength)


// === PLOTTING ===
fast = plot(maFast, title = "Fast MA", color = color.green, linewidth = 2, style = plot.style_line, transp = 30)
slow = plot(maSlow, title = "Slow MA", color = color.red, linewidth = 2, style = plot.style_line, transp = 30)

// === INPUT BACKTEST RANGE ===
FromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
FromDay   = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
FromYear  = input(defval = 2018, title = "From Year", minval = 2017)
ToMonth   = input(defval = 1, title = "To Month", minval = 1, maxval = 12)
ToDay     = input(defval = 1, title = "To Day", minval = 1, maxval = 31)
ToYear    = input(defval = 9999, title = "To Year", minval = 2017)

// === FUNCTION EXAMPLE ===
start     = timestamp(FromYear, FromMonth, FromDay, 00, 00)  // backtest start window
finish    = timestamp(ToYear, ToMonth, ToDay, 23, 59)        // backtest finish window
window()  => time >= start and time <= finish ? true : false // create function "within window of time"

// === LOGIC ===
enterLong = crossover(maFast, maSlow)
exitLong = crossover(maSlow, maFast)
//enterLong = crossover(maSlow, maFast)
//exitLong = crossover(maFast, maSlow)

// Entry //
strategy.entry(id="Long Entry", long=true, when=window() and enterLong)
strategy.entry(id="Short Entry", long=false, when=window() and exitLong)

// === FILL ====
fill(fast, slow, color = maFast > maSlow ? color.green : color.red)

// === MRSI ===
//
//

basis = rsi(close, input(50))

ma1 = ema(basis, input(2))
ma2 = ema(basis, input(27))

oversold = input(32.6)
overbought = input(63)

//plot(ma1, title="RSI EMA1", color=blue)
//plot(ma2, title="RSI EMA2", color=yellow)

obhist = ma1 >= overbought ? ma1 : overbought
oshist = ma1 <= oversold ? ma1 : oversold

//plot(obhist, title="Overbought Highligth", style=columns, color=color.maroon, histbase=overbought)
//plot(oshist, title="Oversold Highligth", style=columns, color=color.yellow, histbase=oversold)

//i1 = hline(oversold, title="Oversold Level", color=white)
//i2 = hline(overbought, title="Overbought Level", color=white)

//fill(i1, i2, color=olive, transp=100)

// === LOGIC ===
enterLongMrsi = crossover(ma1, oversold)
exitLongMrsi = crossover(ma1, overbought)

// Entry //
strategy.entry(id="MRSI Long Entry", long=true, when=window() and enterLongMrsi)
strategy.entry(id="MRSI Short Entry", long=false, when=window() and exitLongMrsi)

//hline(50, title="50 Level", color=white)