この戦略は,取引リスクを制御するための構成可能なパーセンテージ・トラッキング・ストップ・メカニズムを実現している.これは,ロングポジションとショートポジションのストップ・幅のパーセンテージを設定し,エントリー価格から継続的に有利な方向に最高価格または最低価格を追跡し,ダイナミック・ストップを実現することを可能にする.
この戦略の主な論理は:
策略は,カスタムストップパーセンテージを許可します.例えば,10%に設定します.長いポジションの場合,それは最低価格の10%以上をストップラインとしてリアルタイムで計算します.短いポジションの場合,最高価格の10%以下をストップラインとして計算します.
この方法で,ストップラインは有利な方向に常に移動し,ダイナミックなストップを追跡し,利潤を最大限に保護し,同時にリスクを制御します.
どう対処するか?
この戦略の改善点:
この戦略は,有効なパーセンテージ・トラッキング・ストップ・メソッドを提供し,ストップ・ラインを動的に調整することができる.それは,利潤を最大限に保護し,リスクを効果的に制御することができる.パラメータ・最適化,指標・統合などの方法によって,ストップ・戦略をより賢く,最適化することができる.
/*backtest
start: 2023-08-19 00:00:00
end: 2023-09-18 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// © theCrypster
//@version=4
strategy("Percent Trailing Stop %", overlay=true)
//ENTER SOME SETUP TRADES FOR TSL EXAMPLE
longCondition = crossover(sma(close, 10), sma(close, 20))
if (longCondition)
strategy.entry("My Long Entry Id", strategy.long)
shortCondition = crossunder(sma(close, 10), sma(close, 20))
if (shortCondition)
strategy.entry("My Short Entry Id", strategy.short)
//TRAILING STOP CODE
trailStop = input(title="Long Trailing Stop (%)", type=input.float, minval=0.0, step=0.1, defval=10) * 0.01
longStopPrice = 0.0
shortStopPrice = 0.0
longStopPrice := if strategy.position_size > 0
stopValue = close * (1 - trailStop)
max(stopValue, longStopPrice[1])
else
0
shortStopPrice := if strategy.position_size < 0
stopValue = close * (1 + trailStop)
min(stopValue, shortStopPrice[1])
else
999999
//PLOT TSL LINES
plot(series=strategy.position_size > 0 ? longStopPrice : na, color=color.red, style=plot.style_linebr, linewidth=1, title="Long Trail Stop", offset=1, title="Long Trail Stop")
plot(series=strategy.position_size < 0 ? shortStopPrice : na, color=color.red, style=plot.style_linebr, linewidth=1, title="Short Trail Stop", offset=1, title="Short Trail Stop")
//EXIT TRADE @ TSL
if strategy.position_size > 0
strategy.exit(id="Close Long", stop=longStopPrice)
if strategy.position_size < 0
strategy.exit(id="Close Short", stop=shortStopPrice)