3移動平均トレンドフォロー戦略


作成日: 2024-02-02 17:30:09 最終変更日: 2024-02-02 17:30:09
コピー: 1 クリック数: 567
1
フォロー
1617
フォロワー

3移動平均トレンドフォロー戦略

概要

この策略は,色の閃電と呼ばれるもので,3つの移動平均に基づいてトレンドフォロー策略である.それは,快線,中線,および遅線の交差を計算して価格の傾向を判断し,ATR値でターゲット価格とストップ価格を設定する.

戦略原則

この戦略は以下の3つの移動平均を使用しています.

  1. 短期的なトレンドを判断するための13日目加重移動平均
  2. 55日指数移動平均は,中期トレンドを判断するために使用される.
  3. 長期トレンドを判断するための110日単行移動平均

快線上を中線,中線上を遅線上を穿ったとき,判断は多傾向として;快線下を中線下を穿ったとき,中線下を遅線下を穿ったとき,判断は空頭傾向として.

この戦略は,一部のノイズ取引をフィルタリングするために,いくつかの補助条件を設定しています.

  1. 前5つのK線は中線より上です.
  2. 前2つのK線は,中線より下にある.
  3. 前K線は中線上に閉じる

これらの条件を満たす場合,多額または空白の信号が発せられます. 一度に1つのポジションしか持っていないので,平仓または停止後に再びポジションを開くことができます.

ターゲット価格とストップ価格はATR値に基づいて一定の倍数で設定されます.

優位分析

この戦略の利点は以下の通りです.

  1. 3つの移動平均の組み合わせを使用してトレンドを判断し,単一の指標で判断誤りの確率を避けます.
  2. 複数の補助条件を設定して,ノイズ取引をフィルターすることで,信号の質を向上させることができる.
  3. ATRのダイナミックストップは,単価損失をコントロールするのに役立ちます.

リスク分析

この戦略には以下のリスクもあります.

  1. 移動平均の組み合わせは誤った信号を発し,十分に反省する必要がある.
  2. ATR倍数の設定を誤って設定すると,止損が過度に緩やかまたは厳格になる可能性があります.
  3. 価格の変動は,突然の出来事を効率的にフィルターできない.

リスクを制御するために,移動平均のパラメータを適切に調整し,ATRの倍数を最適化し,単一の損失を過大にしないように最大保有時間を設定することをお勧めします.

最適化の方向

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

  1. 異なる長さやタイプの移動平均をテストする.
  2. 補助条件の最適化パラメータ
  3. MACD,DMIなどの他の指標でトレンドを予測してみてください.
  4. 結合量能指数は,取引量,価格差などのフィルタリング信号である.

要約する

この戦略は,全体として安定したトレンドフォロー戦略である.それは,主に移動平均を判断してトレンドの方向を判断し,特定の技術指標群が協力して,部分的なノイズをフィルタリングすることができます.さらに最適化の余地があるが,全体的なリスクは制御可能であり,中長線トレンドフォローに適した投資である.

ストラテジーソースコード
/*backtest
start: 2024-01-02 00:00:00
end: 2024-02-01 00:00:00
period: 2h
basePeriod: 15m
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/
// © greenmask9

//@version=4
strategy("Dazzling Bolts", overlay=true)
//max_bars_back=3000

// 13 SMMA
len = input(10, minval=1, title="SMMA Period")
src = input(close, title="Source")
smma = 0.0
smma := na(smma[1]) ? sma(src, len) : (smma[1] * (len - 1) + src) / len

// 55 EMA
emalength = input(55, title="EMA Period")
ema = ema(close, emalength)

// 100 SMA
smalength = input(110, title="SMA Period")
sma = sma(close, smalength)

emaforce = input(title="Force trend with medium EMA", type=input.bool, defval=true)
offsetemavalue = input(defval = 6)

bullbounce = smma>ema and ema>sma and low[5]>ema and low[2]<ema and close[1]>ema and (ema[offsetemavalue]>sma or (not emaforce))
bearbounce = smma<ema and ema<sma and high[5]<ema and high[2]>ema and close[1]<ema and (ema[offsetemavalue]<sma or (not emaforce))
plotshape(bullbounce,  title= "Purple", location=location.belowbar, color=#ff33cc, transp=0, style=shape.triangleup, size=size.tiny, text="Bolts")
plotshape(bearbounce,  title= "Purple", location=location.abovebar, color=#ff33cc, transp=0, style=shape.triangledown, size=size.tiny, text="Bolts")
strategy.initial_capital = 50000
ordersize=floor(strategy.initial_capital/close)
longs = input(title="Test longs", type=input.bool, defval=true)
shorts = input(title="Test shorts", type=input.bool, defval=true)
atrlength = input(title="ATR length", defval=12)
atrm = input(title="ATR muliplier",type=input.float, defval=2)
atr = atr(atrlength)

target = close + atr*atrm
antitarget = close - (atr*atrm)

//limits and stop do not move, no need to count bars from since

bullbuy = bullbounce and longs and strategy.opentrades==0
bb = barssince(bullbuy)
bearsell = bearbounce and shorts and strategy.opentrades==0
bs = barssince(bearsell)

if (bullbuy)
    strategy.entry("Boltsup", strategy.long, ordersize)
    strategy.exit ("Bolts.close", from_entry="Boltsup", limit=target, stop=antitarget)
if (crossover(smma, sma))
    strategy.close("Boltsup", qty_percent = 100, comment = "Bolts.crossover")

if (bearsell)
    strategy.entry("Boltsdown", strategy.short, ordersize)
    strategy.exit("Bolts.close", from_entry="Boltsdown", limit=antitarget, stop=target)
if (crossunder(smma, sma))
    strategy.close("Boltsdown", qty_percent = 100, comment = "Bolts.crossover")

// if (bb<5)
//     bulltarget = line.new(bar_index[bb], target[bb], bar_index[0], target[bb], color=color.blue, width=2)
//     bullclose = line.new(bar_index[bb], close[bb], bar_index[0], close[bb], color=color.blue, width=2)
//     bullstop = line.new(bar_index[bb], antitarget[bb], bar_index[0], antitarget[bb], color=color.blue, width=2)
// if (bs<5)
//     bulltarget = line.new(bar_index[bs], antitarget[bs], bar_index[0], antitarget[bs], color=color.purple, width=2)
//     bullclose = line.new(bar_index[bs], close[bs], bar_index[0], close[bs], color=color.purple, width=2)
//     bullstop = line.new(bar_index[bs], target[bs], bar_index[0], target[bs], color=color.purple, width=2)