ダイナミックフォローアップストップロス戦略


作成日: 2023-12-21 15:58:54 最終変更日: 2023-12-21 15:58:54
コピー: 1 クリック数: 761
1
フォロー
1623
フォロワー

ダイナミックフォローアップストップロス戦略

概要

この戦略は日線に基づいてトレンドの方向を決定し,15分間のK線が形成された新しい高点または低点をストップ・ロースまたはストップ・ロースの追跡として使用し,より多くの利益をロックするためにストップ・ロスを動的に調整する戦略である.

戦略原則

  1. 日K線の閉盘価格と前日の最高価格と最低価格を比較して,トレンドの方向を判断する.閉盘価格が前日の最高価格より高い場合は,上昇傾向と定義する.閉盘価格が前日の最低価格より低い場合は,下降傾向と定義する.

  2. 上向きのトレンドでは,15分Kラインの閉盘価格が前15分Kラインの最高価格より高いとき,多めに; 下向きのトレンドでは,15分Kラインの閉盘価格が前15分Kラインの最低価格より低いとき,空っぽに.

  3. プラスした後に,前15分K線の最低価格がストップポイントとなる.空白した後に,前15分K線の最高価格がストップポイントとなる.

  4. 15分K線が再び新しい高点または低点を作るとき,ストップレスを調整する. オーバーする時は新しい低点に調整し,空いている時は新しい高点に調整し,ダイナミック・トラッキングストップを実現する.

優位分析

この戦略の最大の利点は,ストップを動的に調整することができ,リスク管理を保証しながら,利益を最大限にロックし,ストップが衝撃を受ける確率を減らすことです.

具体的には以下の通りです.

  1. トレンド計算により,市場の動きを判断し,正しい取引方向を選択できます.

  2. 15分程度の取引で,より多くのチャンスを掴むことができます.

  3. 動的にストップ戦略を調整し,新しい高値や新しい低値に応じてストップが衝撃を受けるリスクを低減する.

  4. 止損位置は合理的に設定され,無意味な損失を最大限に防ぐ.

リスク分析

この戦略の主なリスクは,トレンド判断の誤りである.具体的リスク点は以下の通りである.

  1. 日経トレンド判断の誤りにより,取引の方向が誤りになる可能性があります.

  2. 短期間の急激な波動により,15分間のストップレードが突破される可能性が高い.

  3. トレンドの転換点を正しく認識できなければ,損失を招く可能性があります.

対応方法は以下の通りです.

  1. 他の時間周期指標を加えて総合判断し,単一の周期だけで誤りを避ける.

  2. 市場の波動性を評価し,波動が大きい場合,適切な緩解の止損範囲を与える.

  3. トレンドの転換点判断のメカニズムを追加し,転換前に適切なタイミングでポジションを平らげます.

最適化の方向

この戦略をさらに改善する余地があります.

  1. 他の周期指標の判断を加え,トレンドの把握を最適化する.

  2. 異なる止損比設定をテストし,最適なパラメータを選択する.

  3. 誤った取引を避けるために,エネルギー指数を増やします.

  4. トレンド転換メカニズムを追加し,エクジットポイントを最適化します.

  5. トレーリングストップの範囲を増加させ,ストップダメージが衝撃を受ける確率をさらに減らすことを評価する.

要約する

この戦略は,全体的に良好な運行効果があり,考え方が明確で理解しやすい,止損ダイナミック調整,頻繁な取引,順番によるなどの利点があり,リスクを効果的に制御し,利益をロックすることができる.さらなるテストと最適化の適用に値する.しかし,一定の改善の余地があり,複数の角度から総合判断,最適化パラメータ設定,トレンド転換判別を増やすなどで始めるのが推奨される.

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

//@version=5
strategy("Anand's Strategy", overlay=true)

// Get the high and low of the previous day's candle
prev_high = request.security(syminfo.tickerid, "D", high[2])
prev_low = request.security(syminfo.tickerid, "D", low[2])

// var float prev_high = na
// var float prev_low = na

prev_close = request.security(syminfo.tickerid, "D", close[1])


getDayIndexedHighLow(_bar) =>
    _indexed_high = request.security(syminfo.tickerid, "D", high[_bar])
    _indexed_low = request.security(syminfo.tickerid, "D", low[_bar])
    [_indexed_high, _indexed_low]

var index = 2

while index >= 0
    [indexed_high_D, indexed_low_D] =  getDayIndexedHighLow(index)
  
    if prev_close > indexed_high_D or prev_close < indexed_low_D
        prev_high := indexed_high_D
        prev_low := indexed_low_D
        break
    // Decrease the index to move to the previous 15-minute candle
    index := index - 1


// Determine the trade direction based on the candle criterion
trade_direction = prev_close > prev_high ? 1 : (prev_close < prev_low ? -1 : 0)

// Get the current close from 15-minute timeframe
current_close = request.security(syminfo.tickerid, "15", close[1])
prev_high_15m = request.security(syminfo.tickerid, "15", high[2])
prev_low_15m = request.security(syminfo.tickerid, "15", low[2])

// var float prev_high_15m = na
// var float prev_low_15m = na

getIndexedHighLow(_bar) =>
    _indexed_high = request.security(syminfo.tickerid, "15", high[_bar])
    _indexed_low = request.security(syminfo.tickerid, "15", low[_bar])
    [_indexed_high, _indexed_low]


// Loop through previous 15-minute candles until the condition is met
var  i = 2

while i >= 2
    [indexed_high_15m, indexed_low_15m] =  getIndexedHighLow(i)
  
    if current_close > indexed_high_15m or current_close < indexed_low_15m
        prev_high_15m := indexed_high_15m
        prev_low_15m := indexed_low_15m
        break
    // Decrease the index to move to the previous 15-minute candle
    i := i - 1



buy_condition = trade_direction == 1 and current_close > prev_high_15m
stop_loss_buy = prev_low_15m

// Sell Trade Criteria in Negative Trend
sell_condition = trade_direction == -1 and current_close < prev_low_15m
stop_loss_sell = prev_high_15m


// Trailing Stop Loss for Buy Trade
// Custom Trailing Stop Function for Buy Trade
var float trail_stop_buy = na
trailing_buy_condition = buy_condition and current_close > trail_stop_buy
if trailing_buy_condition
    trail_stop_buy := current_close

// Custom Trailing Stop Function for Sell Trade
var float trail_stop_sell = na
trailing_sell_condition = sell_condition and current_close < trail_stop_sell
if trailing_sell_condition
    trail_stop_sell := current_close

// Take Buy Trade with Stop Loss
if (buy_condition)
    strategy.entry("Buy", strategy.long)
    strategy.exit("Buy Stop Loss", "Buy", stop=stop_loss_buy)

// Take Sell Trade with Stop Loss
if (sell_condition)
    strategy.entry("Sell", strategy.short)
    strategy.exit("Sell Stop Loss", "Sell", stop=stop_loss_sell)

// Set the background color based on the trade direction
bgcolor(trade_direction == 1 ? color.new(color.green, 90) : trade_direction == -1 ? color.new(color.red, 90) : na)