最高のスリッページ トレーリング ストップ戦略


作成日: 2023-09-21 20:58:22 最終変更日: 2023-09-21 20:58:22
コピー: 0 クリック数: 741
1
フォロー
1617
フォロワー

概要

この戦略は,価格の変動幅に応じてストップラインを移動させ,ダイナミックなストップを実現するために,スライドポイント追跡ストップメカニズムを採用している.価格が指定された利益レベルに達した後にストップ追跡ストップを開始し,利益を保護することを目的とし,同時に,ストップが過早に誘発される可能性を最小限に抑える.

戦略原則

この戦略は,二重均等線判断のトレンド方向に基づいて入場し,入場シグナルは,高速均等線の上に遅い均等線を穿越する.

ストップ・ダメージのデザインが革新的だ:

  1. ストップ・ロスのスタートラインを設定する. 価格がストップ・ロスを破るときにストップ・トラッキングを起動する.

  2. ストップラインは,設定された滑り点Percentageに従って移動追跡する。3%の滑り点を設定すると,ストップラインは最低価格の3%以下になります。

  3. 価格が不利な方向に逆転し,追跡ストップラインに触れたとき,平仓ストップ.

このデザインは,ストップ・ローンが自動的に利益を追跡することを保証するだけでなく,利益が良好なときにストップ・ローンの可能性も減らす.

戦略的優位性

  • スライドポイント比率の止損,自動追跡止損
  • スタートラインを設定し,早期起動停止を避ける
  • ストップラインを動的に追跡し,利益を守ります.
  • 短期的なリコールで 損失を免れる
  • スタートラインとスライドポイントの比率は市場に応じて調整できます.

戦略リスク

  • 平均線判断は遅滞し,誤った信号を生成する可能性があります.
  • スタートラインの設定が不適切で,早すぎたり遅すぎたりして停止を有効にします.
  • スライドポイントの比率は,不適切な設定,過松または過緊縮
  • 完全には逃れられない
  • 市場変動に最適化されるパラメータ

リスクは以下の方法で軽減できます.

  • 平均線周期を最適化し,入場率を向上させる
  • スタートラインのパラメータをテストして,最適な位置を特定します.
  • 歴史的な撤回状況によるテスト最適滑点比率
  • また,学校への再入学を考慮し,欠席を減らす.
  • 逆転を避けるために,他の条件の判断を加える.

最適化の方向

この戦略は以下の点で最適化できます.

  1. 双均線周期パラメータを最適化

異なる快線と遅線の組み合わせをテストする.

  1. スタートラインを最適化または削除

追跡ストップを直接有効にするか,異なる品種に応じて異なるパラメータを設定する

  1. 滑点比のパラメータをテストする

種ごとに最適の止損滑点比率を探す

  1. 再入学制度への参加

ストップ・ロスの終了後に再入場条件を設定する

  1. ストップ・フォースは変動率に合わせて調整されます.

市場波動が拡大した場合には,適正に止損範囲を緩める

要約する

この戦略は,スライドポイントトラッキングストップ方式を採用し,スタートラインの後に動的にストップロスを調整する.このストップ方式は,市場の変動に応じて自動的にストップロスの強さを調整し,利益を保護し,不要なストップロスを減らすとのバランスを実現する.しかし,品種特性の最適化パラメータ,および均一線判定などの他の技術指標を補助して入場の正確性を向上させる必要がある.また,再入場メカニズムは,早すぎるストップロスのリスクを減らすことができます.継続的な学習と最適化のみで,戦略がさまざまな市場環境に継続的に適応できるようにする.

ストラテジーソースコード
/*backtest
start: 2022-09-14 00:00:00
end: 2023-09-20 00:00:00
period: 2d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
//@author=Daveatt

SystemName = "BEST Trailing Stop Strategy"
TradeId = "BEST"

InitCapital = 100000
InitPosition = 100
InitCommission = 0.075
InitPyramidMax = 1
CalcOnorderFills = true
CalcOnTick = true
DefaultQtyType = strategy.fixed
DefaultQtyValue = strategy.fixed
Precision = 2
Overlay=true


// strategy(title=SystemName, shorttitle=SystemName, overlay=Overlay, 
//  pyramiding=InitPyramidMax, initial_capital=InitCapital, default_qty_type=DefaultQtyType, default_qty_value=InitPosition, commission_type=strategy.commission.percent, 
//  commission_value=InitCommission, calc_on_order_fills=CalcOnorderFills, calc_on_every_tick=CalcOnTick, precision=2)


src = close
// Calculate moving averages
fastSMA = sma(close, 15)
slowSMA = sma(close, 45)

// Calculate trading conditions
enterLong  = crossover(fastSMA, slowSMA)
enterShort = crossunder(fastSMA, slowSMA)

// trend states
since_buy  = barssince(enterLong)
since_sell = barssince(enterShort)
buy_trend  = since_sell > since_buy
sell_trend = since_sell < since_buy 

change_trend = (buy_trend and sell_trend[1]) or (sell_trend and buy_trend[1])

//plot(buy_trend ? 1 : 0, title='buy_trend', transp=100)
//plot(sell_trend ? 1 : 0, title='sell_trend', transp=100)

// get the entry price
entry_price = valuewhen(enterLong or enterShort, close, 0)

// Plot moving averages
plot(series=fastSMA, color=color.teal)
plot(series=slowSMA, color=color.orange)

// Plot the entries
plotshape(enterLong, style=shape.circle, location=location.belowbar, color=color.green, size=size.small)
plotshape(enterShort, style=shape.circle, location=location.abovebar, color=color.red, size=size.small)



///////////////////////////////
//======[ Trailing STOP ]======//
///////////////////////////////

// use SL?
useSL = input(true, "Use stop Loss")
// Configure trail stop level with input
StopTrailPerc = input(title="Trail Loss (%)", type=input.float, minval=0.0, step=0.1, defval=3) * 0.01
// Will trigger the take profit trailing once reached
use_SL_Trigger = input(true, "Use stop Loss Trigger")
StopTrailTrigger   = input(2.0, "SL Trigger (%)",minval=0,step=0.5,type=input.float) * 0.01


StopLossPriceTrigger = 0.0
StopLossPriceTrigger := if (use_SL_Trigger)
    if buy_trend
        entry_price * (1 + StopTrailTrigger) 
    else
        entry_price * (1 - StopTrailTrigger)
else
    -1


var SL_Trigger_Long_HIT = false
SL_Trigger_Long_HIT := useSL and use_SL_Trigger and buy_trend and high >= StopLossPriceTrigger
 ? true : SL_Trigger_Long_HIT[1]


var SL_Trigger_Short_HIT = false
SL_Trigger_Short_HIT := useSL and use_SL_Trigger and sell_trend and low <= StopLossPriceTrigger
 ? true : SL_Trigger_Short_HIT[1]


display_long_SL_trigger     = useSL and buy_trend  and use_SL_Trigger 
 and SL_Trigger_Long_HIT == false and StopLossPriceTrigger != -1
display_short_SL_trigger    = useSL and sell_trend and use_SL_Trigger 
 and SL_Trigger_Short_HIT == false and StopLossPriceTrigger != -1
display_SL_trigger          = display_long_SL_trigger or display_short_SL_trigger

plot(display_SL_trigger ? StopLossPriceTrigger : na, title='SLPriceTrigger', transp=0, 
 color=color.maroon, style=plot.style_circles, linewidth=3)


// Determine trail stop loss prices
longStopPrice = 0.0, shortStopPrice = 0.0

longStopPrice := if useSL and buy_trend
    stopValue = low * (1 - StopTrailPerc)
    max(stopValue, longStopPrice[1])
else
    0

shortStopPrice := if useSL and sell_trend
    stopValue = high * (1 + StopTrailPerc)
    min(stopValue, shortStopPrice[1])
else
    999999

//////////////////////////////////////////////////////////////////////////////////////////
//*** STOP LOSS HIT CONDITIONS TO BE USED IN ALERTS  ***//
//////////////////////////////////////////////////////////////////////////////////////////

cond_long_stop_loss_hit  = useSL and buy_trend and crossunder(low, longStopPrice[1]) 
 and (SL_Trigger_Long_HIT or use_SL_Trigger == false)
cond_short_stop_loss_hit = useSL and sell_trend and crossover(high, shortStopPrice[1]) 
 and (SL_Trigger_Short_HIT or use_SL_Trigger == false)


// Plot stop loss values for confirmation
plot(series=useSL and buy_trend and low >= longStopPrice 
 and (SL_Trigger_Long_HIT or use_SL_Trigger == false)
 ? longStopPrice : na,
 color=color.fuchsia, style=plot.style_cross,
 linewidth=2, title="Long Trail Stop")

plot(series=useSL and sell_trend and high <= shortStopPrice 
 and (SL_Trigger_Short_HIT or use_SL_Trigger == false)
 ? shortStopPrice : na,
 color=color.fuchsia, style=plot.style_cross,
 linewidth=2, title="Short Trail Stop")

close_long  = cond_long_stop_loss_hit
close_short = cond_short_stop_loss_hit

// Submit entry orders
strategy.entry(TradeId + " L", long=true, when=enterLong)
strategy.close(TradeId + " L", when=close_long)

//if (enterShort)
strategy.entry(TradeId + " S", long=false, when=enterShort)
strategy.close(TradeId + " S", when=close_short)


if change_trend
    SL_Trigger_Long_HIT := false
    SL_Trigger_Short_HIT := false