ダイナミック・ムービング・アベア・リトレースメント マーティン戦略

作者: リン・ハーンチャオチャン, 日付: 2023-11-24 10:19:21
タグ:

img

概要

ダイナミック・ムービング・アベア・リトレースメント・マーティン戦略は,移動平均クロスオーバーとプルバック・シグナルを組み合わせてエントリー・エグジット・シグナルを生成する頻繁な取引戦略である.この戦略は,3日間のシンプル・ムービング・アベアと8日間のクロスオーバーとディバージェンスを利用し,短期的トレンドを把握し,リスクを制御するためにストップと利益を取ることを採用する.この戦略は,異なる市場状況に応じて取引方向を選択することを可能にする.

戦略の論理

この戦略は,3日および8日間の単純な移動平均値とそのクロスオーバーシグナルを使用する. 3日間のMAが8日間のMAを超えると長信号が生成され, 3日間のMAが8日間のMAを下回ると短信号が生成される. 長信号は長エントリーを誘発し,短信号は短エントリーを誘発する.

ポジションがない場合,戦略はクロスオーバー信号に基づいてエントリーを決定する.エントリー後,ストップ・ロスト価格とテイク・プロフィート価格は,最新の閉店価格,ストップ・ロストパーセント,テイク・プロフィートパーセントに基づいて計算される.例えば,ロングポジションを保持する場合は,ストップ・ロスト価格は,ストップ・ロストパーセントを8日MAで倍した最新の閉店価格マイナスで,テイク・プロフィート価格は,最新の閉店価格プラス,テイク・プロフィートパーセントを8日MAで倍したものです.

既存のロングポジションがある場合,価格がメリットまたはストップロスを引き起こすとき,8日MAのプルバック信号が発生した場合,ポジションは閉鎖されます.この時点で,ストップロスト価格とメリット価格が0にリセットされます.ショートポジションの処理の論理は類似しています.

この戦略は,チャート上のエントリーと出口点をプロットする.例えば,長いエントリは上方三角形,長い出口は下方三角形としてプロットされる.これは,エントリーと出口を視覚的に判断するのに役立ちます.

利点分析

この戦略の利点は次のとおりです.

  1. 移動平均のクロスオーバー信号を用いて短期的なトレンドを把握し,頻繁な取引を可能にします.
  2. ストップ損失メカニズムは 単一の損失を制御できます
  3. 部分的な利益が確保できます
  4. 取引方向は異なる段階に合わせて選択できます.
  5. グラフの入口と出口点を表示します.

リスク分析

この戦略の主なリスクは,

  1. 短期的な MA 戦略は 切り裂かれる傾向があります
  2. 移動平均値からの遅延信号の可能性
  3. 連続した損失は悪化する損失につながる可能性があります
  4. 誤って設定されたストップロスの割合は,緩すぎたり,狭すぎたりする可能性があります.

ストップ・ロスの割合を合理的に拡大し,MAパラメータを最適化し,追加のフィルター条件を導入することでリスクは軽減できます.また,個人の耐性を正しく評価し,過剰取引を避けることも重要です.

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

この戦略は,次の側面から最適化できます.

  1. 最適なパラメータを見つけるために より多くの MA 組み合わせをテストします
  2. RSI,KDなどの他の指標を追加して信号品質を向上させる.
  3. ストップ・ロスの割合を 異なる製品と時間枠に応じて調整する.
  4. 固定量や固定資本などのポジションサイズ制御を追加します.
  5. 入力順序のルールを追加します.
  6. ストップ・ロスのレベルを最適化し評価する

概要

ダイナミック・ムービング・アベア・リトレースメント・マーティン戦略は,短期間の取引戦略である.移動平均クロスオーバーによって形成された短期的トレンドを把握し,適切なストップと利益を得ることでリスクを管理する.頻繁な取引性質により,利益の機会とリスクが与えられます.パラメータを最適化し,シグナルをフィルタリングし,リスクを制御することによって,この戦略はより信頼性のためにさらに改善することができます.


/*backtest
start: 2022-11-17 00:00:00
end: 2023-11-23 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/
// © blackcat1402
//@version=5
strategy('[blackcat] L1 MartinGale Scalping Strategy', overlay=true, pyramiding = 5)

// Define input variables
takeProfit = input(1.03, title='Take Profit')
stopLoss = input(0.95, title='Stop Loss')
inputTradingMode = input.string(defval='Long', options=['Long', 'Short', 'BiDir'], title='Trading Mode')

//The purpose of this rule is to forbid short entries, only long etries will be placed. The rule affects the following function: 'entry'.
strategy.risk.allow_entry_in(inputTradingMode == 'Long' ? strategy.direction.long : inputTradingMode == 'Short' ? strategy.direction.short : strategy.direction.all)

// Define strategy logic
entryPrice = 0.0
stopPrice = 0.0
takeProfitPrice = 0.0
stopLossPrice = 0.0

// Define SMA crossover and crossunder signals
sma3 = ta.sma(close, 3)
sma8 = ta.sma(close, 8)
plot(sma3, color=color.yellow)
plot(sma8, color=color.fuchsia)
crossoverSignal = ta.crossover(sma3, sma8)
crossunderSignal = ta.crossunder(sma3, sma8)
crossoverState = sma3 > sma8
crossunderState = sma3 < sma8

if strategy.position_size == 0
    if crossoverState
        strategy.entry('Buy', strategy.long)
        entryPrice := close
        stopPrice := close - stopLoss * sma8[1]
        takeProfitPrice := close + takeProfit * sma8[1]
        stopLossPrice := stopPrice
        stopLossPrice
    if crossunderState
        strategy.entry('Sell', strategy.short)
        entryPrice := close
        stopPrice := close + stopLoss *  sma8[1]
        takeProfitPrice := close - takeProfit *  sma8[1]
        stopLossPrice := stopPrice
        stopLossPrice

if strategy.position_size > 0
    if (close > takeProfitPrice or close < stopLossPrice) and crossunderState
        strategy.close('Buy')
        entryPrice := 0.0
        stopPrice := 0.0
        takeProfitPrice := 0.0
        stopLossPrice := 0.0
        stopLossPrice
    else
        strategy.entry('Buy', strategy.long)
        entryPrice := close
        stopPrice := close - stopLoss *  sma8[1]
        takeProfitPrice := close + takeProfit *  sma8[1]
        stopLossPrice := stopPrice
        stopLossPrice

if strategy.position_size < 0
    if (close > takeProfitPrice or close < stopLossPrice) and crossoverState
        strategy.close('Sell')
        entryPrice := 0.0
        stopPrice := 0.0
        takeProfitPrice := 0.0
        stopLossPrice := 0.0
        stopLossPrice
    else
        strategy.entry('Sell', strategy.short)
        entryPrice := close
        stopPrice := close + stopLoss *  sma8[1]
        takeProfitPrice := close - takeProfit *  sma8[1]
        stopLossPrice := stopPrice
        stopLossPrice

// Plot entry and exit points
plotshape(strategy.position_size > 0 and crossoverSignal, 'Buy Entry', shape.triangleup, location.belowbar, color.new(color.green, 0), size=size.small)
plotshape(strategy.position_size > 0 and (close >= takeProfitPrice or close <= stopLossPrice), 'Buy Exit', shape.triangledown, location.abovebar, color.new(color.red, 0), size=size.small)
plotshape(strategy.position_size < 0 and crossunderSignal, 'Sell Entry', shape.triangledown, location.abovebar, color.new(color.red, 0), size=size.small)
plotshape(strategy.position_size < 0 and (close >= takeProfitPrice or close <= stopLossPrice), 'Sell Exit', shape.triangleup, location.belowbar, color.new(color.green, 0), size=size.small)



もっと