
この戦略は,高点と低点の移動平均と斜率指標を計算することによって市場トレンドを識別し,ダイナミックな止損停止メカニズムと組み合わせてリスク管理を行う,二重均等線に基づくスマートトレンド追跡システムである.戦略の核心は,斜率の値をフィルターして偽信号をフィルターすることであり,トレーリングストップのダイナミックな追跡方法を使用して利益をロックすることであり,トレンド追跡とリスク制御の有機的な組み合わせを実現する.
戦略は,二重均線システムを核心取引論理として採用し,最高価格と最低価格の順序で分別移動平均を計算する.価格が上方平均線を突破し,平均線斜率が顕著に上昇すると,システムは多信号を生成する.価格が下方平均線を突破し,平均線斜率が顕著に低下すると,システムは空信号を生成する.波動的な市場での頻繁な取引を避けるために,戦略は,斜率値の仕組みを導入し,線平均斜率の変化が設定された値を超えた場合にのみ,トレンドの有効性を確認する.リスクの管理に関して,戦略は,ダイナミックなストップ・ロストの仕組みを設計し,当初,比較的激進的なストップ・ロストを設定し,同時に,ストップ・ロスト保護を使用して,既得した利益を追跡する.
これは,トレンド追跡とリスク管理を有機的に組み合わせた量化取引戦略である.双均線システムと斜率の値の組み合わせにより,戦略は市場傾向をより正確に捉えることができ,ダイナミックなストップ・ストップ・ロスの仕組みは,完全なリスク制御を提供します.戦略は,パラメータ選択と市場適応性に関して改善の余地があるが,明確な論理的枠組みと柔軟なシステムによるパラメータの後の最適化には良い基礎を提供します.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-27 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("SMA Buy/Sell Strategy with Significant Slope", overlay=true)
// Parametri configurabili
smaPeriod = input.int(20, title="SMA Period", minval=1)
initialTPPercent = input.float(5.0, title="Initial Take Profit (%)", minval=0.1) // Take Profit iniziale (ambizioso)
trailingSLPercent = input.float(1.0, title="Trailing Stop Loss (%)", minval=0.1) // Percentuale di trailing SL
slopeThreshold = input.float(0.05, title="Slope Threshold (%)", minval=0.01) // Soglia minima di pendenza significativa
// SMA calcolate su HIGH e LOW
smaHigh = ta.sma(high, smaPeriod)
smaLow = ta.sma(low, smaPeriod)
// Funzioni per pendenza significativa
isSignificantSlope(sma, threshold) =>
math.abs(sma - sma[5]) / sma[5] > threshold / 100
slopePositive(sma) =>
sma > sma[1] and isSignificantSlope(sma, slopeThreshold)
slopeNegative(sma) =>
sma < sma[1] and isSignificantSlope(sma, slopeThreshold)
// Condizioni di BUY e SELL
buyCondition = close > smaHigh and low < smaHigh and close[1] < smaHigh and slopePositive(smaHigh)
sellCondition = close < smaLow and high > smaLow and close[1] > smaLow and slopeNegative(smaLow)
// Plot delle SMA
plot(smaHigh, color=color.green, linewidth=2, title="SMA 20 High")
plot(smaLow, color=color.red, linewidth=2, title="SMA 20 Low")
// Gestione TP/SL dinamici
longInitialTP = strategy.position_avg_price * (1 + initialTPPercent / 100)
shortInitialTP = strategy.position_avg_price * (1 - initialTPPercent / 100)
// Trailing SL dinamico
longTrailingSL = close * (1 - trailingSLPercent / 100)
shortTrailingSL = close * (1 + trailingSLPercent / 100)
// Chiusura di posizioni attive su segnali opposti
if strategy.position_size > 0 and sellCondition
strategy.close("Buy", comment="Close Long on Sell Signal")
if strategy.position_size < 0 and buyCondition
strategy.close("Sell", comment="Close Short on Buy Signal")
// Apertura di nuove posizioni con TP iniziale e Trailing SL
if buyCondition
strategy.entry("Buy", strategy.long, comment="Open Long")
strategy.exit("Long TP/Trailing SL", from_entry="Buy", limit=longInitialTP, stop=longTrailingSL)
if sellCondition
strategy.entry("Sell", strategy.short, comment="Open Short")
strategy.exit("Short TP/Trailing SL", from_entry="Sell", limit=shortInitialTP, stop=shortTrailingSL)