モメンタムフォローとトレンド戦略に基づく


作成日: 2024-02-22 17:27:18 最終変更日: 2024-02-22 17:27:18
コピー: 0 クリック数: 550
1
フォロー
1617
フォロワー

モメンタムフォローとトレンド戦略に基づく

概要

この戦略の核心構想は,超トレンド指標と平均トレンド指標 ((ADX) を組み合わせて,トレンドの判断と追跡を実現することである.超トレンド指標は,現在の価格トレンドの方向を識別するために使用され,ADXは,トレンドの強さを判断するために使用され,強いトレンドの下でのみ取引される.さらに,戦略は,K線実体色,取引量指標などを使用して確認し,比較的に完全な取引規則を形成する.

総じて,この戦略はトレンド追跡戦略に属し,整合と振動による干渉を避けるために中長線の明確なトレンドを捉えることを目的としています.

戦略原則

  1. 超トレンド指標を用いて価格トレンドの方向を判断する。価格が上昇する際は超トレンドの多頭信号で,下落する際は空頭信号である。

  2. ADXでトレンドの強さを判断する.ADXが設定のスレッジより大きい場合にのみ取引シグナルが生成される.これにより,整理の不明な期間をフィルターすることができます.

  3. K線実体色の判断は,現在の上昇パターンまたは下降パターンとして,超トレンド指標と組み合わせて,確認を形成する.

  4. 取引量が増大すると確認信号となる. 取引量が増大した時にのみポジションを立てます.

  5. 利益とリスクの管理のために,ストップ・ロスとストップ・ポジションを設定します.

  6. 設定した盤の時間終了前にすべてのポジションをクリアする.

戦略的優位性

  1. 中長線は明瞭なトレンドを追跡し,波動を回避し,より高い利益率を得ることができます.

  2. 戦略のパラメータが少なく,理解し,実行しやすい.

  3. リスクコントロールが設定され,止損と停止が設定されています.

  4. 複数の指標を用いて確認することで,偽信号を減らすことができます.

戦略リスク

  1. 大盘の深度調整では大きな損失を招く可能性があります.

  2. 株価が変化すると 劇的な逆転が起こる可能性があります.

  3. 政策の大きな変化である”黒天事件”に注目しています.

リスクに対する対処法:

  1. ADXパラメータを適切に調整して,強気なトレンドのみで取引することを保証します.

  2. ストップ・ロスの幅を拡大し,単一損失を抑制する.

  3. 政策や重要な出来事を注意深く観察し,必要に応じて,主動的に損害を止めます.

戦略最適化の方向性

  1. 異なるスーパートレンドのパラメータの組み合わせをテストし,より安定した信号を生成するパラメータを選択できます.

  2. ADXの異なるパラメータをテストして,最適なパラメータの組み合わせを決定することができる.

  3. 波動率,ブリン帯などの他の指標を追加して,偽信号をさらに減らすことができます.

  4. トレンドの破裂時に,その時にストップする戦略を組み合わせることができる.

要約する

この戦略の概観は明確で,スーパートレンドで価格トレンドの方向を判断し,ADXでトレンドの強さを判断し,強烈なトレンド下でトレンド追跡を行う。同時に,リスクを制御するためにストップ・ストップを設定する。戦略のパラメータは少ないで,最適化が容易である。学習の簡単な有効なトレンド戦略の例として使用できる。その後,パラメータ最適化,信号フィルターなどの方法によってさらに完善することができる。

ストラテジーソースコード
/*backtest
start: 2023-02-15 00:00:00
end: 2024-02-21 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//Intraday Strategy Template

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © vikris

//@version=4
strategy("[VJ]Hulk Smash Intra", overlay=true, calc_on_every_tick = false, pyramiding=0,default_qty_type=strategy.percent_of_equity, default_qty_value=100,initial_capital=2000)

// ********** Strategy inputs - Start **********

// Used for intraday handling
// Session value should be from market start to the time you want to square-off 
// your intraday strategy
// Important: The end time should be at least 2 minutes before the intraday
// square-off time set by your broker
var i_marketSession = input(title="Market session", type=input.session, 
     defval="0915-1455", confirm=true)

// Make inputs that set the take profit % (optional)
longProfitPerc = input(title="Long Take Profit (%)",
     type=input.float, minval=0.0, step=0.1, defval=1) * 0.01

shortProfitPerc = input(title="Short Take Profit (%)",
     type=input.float, minval=0.0, step=0.1, defval=1) * 0.01
     
// Set stop loss level with input options (optional)
longLossPerc = input(title="Long Stop Loss (%)",
     type=input.float, minval=0.0, step=0.1, defval=0.5) * 0.01

shortLossPerc = input(title="Short Stop Loss (%)",
     type=input.float, minval=0.0, step=0.1, defval=0.5) * 0.01    
     
var float i_multiplier = input(title = "ST Multiplier", type = input.float, 
     defval = 2, step = 0.1, confirm=true)

var int i_atrPeriod = input(title = "ST ATR Period", type = input.integer, 
     defval = 10, confirm=true)     
     
len = input(title="ADX Length", type=input.integer, defval=14)
th = input(title="ADX Threshold", type=input.integer, defval=20)
adxval = input(title="ADX Momemtum Value", type=input.integer, defval=25)     



// ********** Strategy inputs - End **********


// ********** Supporting functions - Start **********

// A function to check whether the bar or period is in intraday session
barInSession(sess) => time(timeframe.period, sess) != 0

// ********** Supporting functions - End **********


// ********** Strategy - Start **********

[superTrend, dir] = supertrend(i_multiplier, i_atrPeriod)

colResistance = dir == 1 and dir == dir[1] ? color.new(color.red, 0) : color.new(color.red, 100)
colSupport = dir == -1 and dir == dir[1] ? color.new(color.green, 0) : color.new(color.green, 100)


// Super Trend Long/short condition
stlong = close > superTrend
stshort = close < superTrend



// Figure out take profit price
longExitPrice  = strategy.position_avg_price * (1 + longProfitPerc)
shortExitPrice = strategy.position_avg_price * (1 - shortProfitPerc)

// Determine stop loss price
longStopPrice  = strategy.position_avg_price * (1 - longLossPerc)
shortStopPrice = strategy.position_avg_price * (1 + shortLossPerc)

//Vol Confirmation
vol = volume > volume[1]


//Candles colors
greenCandle = (close > open)
redCandle = (close < open)

// See if intraday session is active
bool intradaySession = barInSession(i_marketSession)

// Trade only if intraday session is active




TrueRange = max(max(high - low, abs(high - nz(close[1]))), abs(low - nz(close[1])))
DirectionalMovementPlus = high - nz(high[1]) > nz(low[1]) - low ? max(high - nz(high[1]), 0) : 0
DirectionalMovementMinus = nz(low[1]) - low > high - nz(high[1]) ? max(nz(low[1]) - low, 0) : 0


SmoothedTrueRange = 0.0
SmoothedTrueRange := nz(SmoothedTrueRange[1]) - nz(SmoothedTrueRange[1]) / len + TrueRange
SmoothedDirectionalMovementPlus = 0.0
SmoothedDirectionalMovementPlus := nz(SmoothedDirectionalMovementPlus[1]) - 
   nz(SmoothedDirectionalMovementPlus[1]) / len + DirectionalMovementPlus
SmoothedDirectionalMovementMinus = 0.0
SmoothedDirectionalMovementMinus := nz(SmoothedDirectionalMovementMinus[1]) - 
   nz(SmoothedDirectionalMovementMinus[1]) / len + DirectionalMovementMinus

DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100
DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100
DX = abs(DIPlus - DIMinus) / (DIPlus + DIMinus) * 100
ADX = sma(DX, len)

// a = plot(DIPlus, color=color.green, title="DI+", transp=100)
// b = plot(DIMinus, color=color.red, title="DI-", transp=100)

//Final Long/Short Condition
longCondition = stlong and redCandle and vol and ADX>adxval
shortCondition = stshort and greenCandle and vol and ADX >adxval



//Long Strategy - buy condition and exits with Take profit and SL
if (longCondition and intradaySession)
    stop_level = longStopPrice
    profit_level = longExitPrice
    strategy.entry("My Long Entry Id", strategy.long)
    strategy.exit("TP/SL", "My Long Entry Id",stop=stop_level, limit=profit_level)
    


//Short Strategy - sell condition and exits with Take profit and SL
if (shortCondition and intradaySession)
    stop_level = shortStopPrice
    profit_level = shortExitPrice
    strategy.entry("My Short Entry Id", strategy.short)
    strategy.exit("TP/SL", "My Short Entry Id", stop=stop_level, limit=profit_level)
    
 
 
// Square-off position (when session is over and position is open)
squareOff = (not intradaySession) and (strategy.position_size != 0)
strategy.close_all(when = squareOff, comment = "Square-off")

// ********** Strategy - End **********