動向平均の二重トレンド追跡戦略

作者: リン・ハーンチャオチャン,日付: 2024-02-04 15:57:12
タグ:

img

概要

ダブル・ムービング・アベア トレンド・トラッキング戦略は,トレンド方向を決定するために,テンポと速度を緩める移動平均を組み合わせ,エントリー信号としてキャンドルスタイクの体色を使用する.この戦略にはトレンドフォローと平均逆転の両方の特徴がある.

原則

この戦略は,全体的なトレンドを定義するために20期間のスロームービング・平均値を使用する. 上向きクロスオーバーは上昇傾向を示唆し,下向きクロスオーバーは下向き傾向を示唆する. 5期間の速いMAはエントリーフィルターとして機能する. 価格が速いMAを突破するときにのみ取引が起動する. さらに,最近のNキャンドルボディカラーがチェックされる. 上向きのトレンドでボディカラーが赤くなるときにロング信号が起動する. 下向きのトレンドでボディカラーが緑色になるとショート信号が起動する. これは偽のブレイクを避けるのに役立ちます.

この戦略は,トレンド,短期MA,キャンドルスタイクボディの3つの次元を用いて価格アクションを調査し,シグナル信頼性を向上させる.

利点

  1. トレンドフォローと平均逆転を組み合わせ,市場環境に適応できる.

  2. 複数の要素による 前の信号のレビューは 誤った信号を回避することで 勝利率を向上させます

  3. MA長さ,キャンドル色等をチェックして最適化できます

  4. わかりやすく,簡潔で,初心者向けです.

リスク

  1. レンジ市場におけるウィップソーは損失/引き下げにつながる.損失制限またはMAパラメータの最適化を検討する.

  2. 横向する際に潜在的な鞭打ちは損失を引き起こす可能性があります.チェックされたろうそくの数を調整したり,平均逆転を無効にしようとします.

  3. パラメータとパフォーマンスを検証するために 広範なバックテストが必要でした

強化

  1. 他のMA型を調査する.EMA,KAMAなど.

  2. 固定量または%の株式に基づいて,例えば,ポジションのサイズのルールを追加します.

  3. ストップ・ロスのメカニズムを組み込む.価格がMAの低値を下回る場合はロングを終了することを検討する.

  4. 安定性を確認するために,異なる機器でテストする.

結論

ダブルMA戦略は,より短い時間枠で平均逆転アルファを抽出しながらトレンドトレードから利益を得ます.最適化によってパフォーマンスと利益の可能性はさらに向上することができます. シンプルにもかかわらず,初心者はトレンドと平均逆転を組み合わせるための重要な概念を把握することができます. ツールとパラメータ全体で包括的な検証が必要です.


/*backtest
start: 2024-01-04 00:00:00
end: 2024-02-03 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy(title = "Noro's Trend MAs 1.5", shorttitle = "Trend MAs 1.5", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value=100.0, pyramiding=0)

//Settings
needlong = input(true, "long")
needshort = input(true, "short")
type = input(7, defval = 7, minval = 1, maxval = 7, title = "Type of Slow MA")
src = input(close, defval = close, title = "Source of Slow MA")
usefastsma = input(true, "Use fast MA Filter")
fastlen = input(5, defval = 5, minval = 1, maxval = 50, title = "fast MA Period")
len = input(20, defval = 20, minval = 2, maxval = 200, title = "slow MA Period")
bars = input(2, defval = 2, minval = 0, maxval = 3, title = "Bars Q")

fastsma = ema(src, fastlen)

//DEMA
dema = 2 * ema(src, len) - ema(ema(close, len), len)

//TEMA
xPrice = close
xEMA1 = ema(src, len)
xEMA2 = ema(xEMA1, len)
xEMA3 = ema(xEMA2, len)
tema = 3 * xEMA1 - 3 * xEMA2 + xEMA3

//KAMA
xvnoise = abs(src - src[1])
nfastend = 0.20
nslowend = 0.05
nsignal = abs(src - src[len])
nnoise = sum(xvnoise, len)
nefratio = iff(nnoise != 0, nsignal / nnoise, 0)
nsmooth = pow(nefratio * (nfastend - nslowend) + nslowend, 2) 
kama = nz(kama[1]) + nsmooth * (src - nz(kama[1]))

//PriceChannel
lasthigh = highest(src, len)
lastlow = lowest(src, len)
center = (lasthigh + lastlow) / 2

//Trend
ma = type == 1 ? sma(src, len) : type == 2 ? ema(src, len) : type == 3 ? vwma(src, len) : type == 4 ? dema : type == 5 ? tema : type == 6 ? kama : type == 7 ? center : 0
trend = low > ma ? 1 : high < ma ? -1 : trend[1]

//Bars
bar = close > open ? 1 : close < open ? -1 : 0
redbars = bars == 0 ? 1 : bars == 1 and bar == -1 ? 1 : bars == 2 and bar == -1 and bar[1] == -1 ? 1 : bars == 3 and bar == -1 and bar[1] == -1 and bar[2] == -1 ? 1 : 0
greenbars = bars == 0 ? 1 : bars == 1 and bar == 1 ? 1 : bars == 2 and bar == 1 and bar[1] == 1 ? 1 : bars == 3 and bar == 1 and bar[1] == 1 and bar[2] == 1 ? 1 : 0

//Signals
up = trend == 1 and (low < fastsma or usefastsma == false) and redbars == 1 ? 1 : 0
dn = trend == -1 and (high > fastsma or usefastsma == false) and greenbars == 1 ? 1 : 0

//Lines
colorfastsma = usefastsma == true ? red : na
plot(fastsma, color = colorfastsma, title = "Fast MA")
plot(ma, color = blue, linewidth = 3, transp = 0, title = "Slow MA")

//Trading
longCondition = up == 1
if (longCondition)
    strategy.entry("Long", strategy.long, needlong == false ? 0 : na)

shortCondition = dn == 1
if (shortCondition)
    strategy.entry("Short", strategy.short, needshort == false ? 0 : na)

もっと