2つのMAトレンドブレイク戦略

作者: リン・ハーンチャオチャン,日付: 2024-01-08 16:43:38
タグ:

img

概要

ダブルMAトレンドブレイクアウト戦略は,トレンドを決定し,エントリーシグナルを生成するために異なる期間の移動平均を2つ使用する定量的な取引戦略である.主に,スローMAを通じて全体的なトレンド方向を判断し,エントリーフィルタリングのために高速MAを使用する.より大きなタイムフレームトレンドの方向性が一貫しているとき,より高い勝利率と収益性を追求するために,エントリーする逆転バーを選択する.

戦略の論理

戦略は以下の主要な部分で構成されています.

トレンド判断: 緩やかなMAとして定義される21期MAを計算します. その位置は比較的安定しており,全体的な傾向の方向を判断するために使用できます. このMAに近い価格上昇は上昇傾向です. このMAに近い価格低下は下落傾向です.

エントリーフィルタリング: 5期間のMAを計算し,高速MAとして定義します.価格がスローMAと高速MAの両方を突破したときのみ,取引シグナルが起動します.このデザインは主に誤ったブレイクの可能性をさらにフィルターします.

キャンドルフィルタリング: 戦略は,現在のキャンドルが下落しているときにのみ長引く,または現在のキャンドルが上昇しているときに短引く.これは,エントリーのために逆転バーを使用することでより高い成功率を得ることができると考えられています.また,過買いまたは過売れ地域に入ることを避けるために,急速なRSI指標を組み合わせます.

ピラミッド型フィルター: 暗号市場では,戦略には,大幅な下落傾向における過剰販売機会を把握するための変動の3倍のブレイクアウト条件も含まれています.

損失を止める: ストップロスは移動するストップロスをサポートします. ポジションを開いた後,ストップロスは設定されたパーセントに基づいてリアルタイムで更新されます.

利点分析

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

  1. 二重MA設計はシンプルで実用的で,理解し,習得しやすい.
  2. 迅速なMAと遅いMAを組み合わせることで,信頼性の高い傾向判断
  3. リバースバーのエントリにより取引の勝率が向上します
  4. 全体的な方法論は保守的で安定しており,すべての時間枠に適しています.
  5. ストップ・ロスをリスク管理に移行することを支援する.
  6. 特に暗号市場の特徴を考慮し,過剰売れたピラミディング機会を追加し,過剰収益を得ます.

リスク分析

この戦略にはいくつかのリスクもあります:

  1. 範囲に限定されたダブルMA期間中,複数の小さな勝利と損失があります.
  2. 逆行バーエントリでは タイムフレームでは 勝率が低い可能性があります
  3. 仮想通貨市場には高い波動性があり ストップロスの可能性も高い
  4. 過剰に売れたピラミッド投資の機会は多くありません 高い収益の波動性があります

これらのリスクに対処するために,次の側面で最適化を行うことができます:

  1. 効果のないウィップソウを避けるために,より多くのエントリー条件を追加します.
  2. 時間枠を調整するか,フィルタリングのための他の指標を追加する.
  3. ストップ・ロスのアルゴリズムを最適化し,ミッドライン近くを追跡する.
  4. 過剰販売のピラミッド戦略の実際のパフォーマンスを評価します

オプティマイゼーションの方向性

この戦略を最適化するための主な側面は以下のとおりです.

  1. パラメータ最適化: リスク調整回帰を向上させるため,最適な高速および遅いMA期間の組み合わせを見つけるため,体系的なバックテストを行う.

  2. パターン 認識: KDJ,MACDなどの他の指標を追加して,より信頼性の高い逆転信号を識別します.

  3. ストップ損失最適化: 停止される可能性を減らすため,浮遊または尾行ストップ損失アルゴリズムを開発します.

  4. 機械学習: ML を使って自動で取引ルールを生成するために,より多くの歴史的なデータを収集し,ラベルを付けます.

  5. 位置 サイズ: 市場の状況に基づいてポジションサイズを動的に調整します.

結論

ダブルMAトレンドブレイクアウト戦略は,一般的にシンプルで実践的なトレンドフォロー戦略である.複雑な機械学習アルゴリズムと比較して,この戦略はより簡単に解釈し,マスターし,より高い信頼性を持つ.パラメータチューニング,機能拡張およびML増強により,この戦略は改善の可能性が高く,定量的な取引のための素晴らしい出発点である.


/*backtest
start: 2023-12-31 00:00:00
end: 2024-01-07 00:00:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy(title = "Noro's Trend MAs Strategy v2.0 +CB", shorttitle = "Trend MAs str 2.0", 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")
needstops = input(false, "stops")
stoppercent = input(5, defval = 5, minval = 1, maxval = 50, title = "Stop, %")
useohlc4 = input(false, defval = false, title = "Use OHLC4")
usefastsma = input(true, "Use fast MA Filter")
fastlen = input(5, defval = 5, minval = 1, maxval = 50, title = "fast MA Period")
slowlen = input(21, defval = 20, minval = 2, maxval = 200, title = "slow MA Period")
bars = input(2, defval = 2, minval = 0, maxval = 3, title = "Bars Q")
needbg = input(false, defval = false, title = "Need trend Background?")
needarr = input(false, defval = false, title = "Need entry arrows?")
needex = input(true, defval = true, title = "Need extreme? (crypto/fiat only!!!)")

src = useohlc4 == true ? ohlc4 : close

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

//PriceChannel 2
lasthigh2 = highest(src, fastlen)
lastlow2 = lowest(src, fastlen)
center2 = (lasthigh2 + lastlow2) / 2

//Trend
trend = low > center and low[1] > center[1] ? 1 : high < center and high[1] < center[1] ? -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

//Fast RSI
fastup = rma(max(change(close), 0), 2)
fastdown = rma(-min(change(close), 0), 2)
fastrsi = fastdown == 0 ? 100 : fastup == 0 ? 0 : 100 - (100 / (1 + fastup / fastdown))

//CryptoBottom
mac = sma(close, 10)
len = abs(close - mac)
sma = sma(len, 100)
max = max(open, close)
min = min(open, close)
up3 = close < open and len > sma * 3 and min < min[1] and fastrsi < 10 ? 1 : 0

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

up2 = high < center and high < center2 and bar == -1 ? 1 : 0
dn2 = low > center and low > center2 and bar == 1 ? 0 : 0

//Lines
plot(center, color = blue, linewidth = 3, transp = 0, title = "Slow MA")
plot(center2, color = red, linewidth = 3, transp = 0, title = "PriceChannel 2")

//Arrows
plotarrow(up == 1 and needarr == true ? 1 : 0, colorup = black, colordown = black, transp = 0)
plotarrow(dn == 1 and needarr == true ? -1 : 0, colorup = black, colordown = black, transp = 0)

//Background
col = needbg == false ? na : trend == 1 ? lime : red
bgcolor(col, transp = 90)

//Alerts
alertcondition(up == 1, title='buy', message='Uptrend')
alertcondition(dn == 1, title='sell', message='Downtrend')

//Trading
stoplong = up == 1 and needstops == true ? close - (close / 100 * stoppercent) : stoplong[1]
stopshort = dn == 1 and needstops == true ? close + (close / 100 * stoppercent) : stopshort[1]

longCondition = up == 1 or (up2 == 1 and needex == true) or up3 == 1
if (longCondition)
    strategy.entry("Long", strategy.long, needlong == false ? 0 : na)
    strategy.exit("Stop Long", "Long", stop = stoplong)

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

もっと