
この戦略は,トレンド追跡,動態指標,自主停止を組み合わせた多次元取引システムである.戦略は,スーパートレンド指標を使用して市場のトレンド方向を識別し,RSI動態指標と均線システムと組み合わせて取引確認を行い,ATR波動率指標を使用して動態停止管理を実現する.この多次元分析方法は,市場トレンドを効果的に捉え,リスクを合理的に制御することができます.
戦略の中核となるロジックは、次の 3 つの次元に基づいています。
購入条件は,スーパートレンドの看板 ((緑色) +RSI<65+価格が50周期平均線上にあることを同時に満たす必要があります. 販売条件: スーパートレンドが下落に転じると平仓する. ストップマネジメント:ATRベースの追跡ストップを使用し,ストップ距離はATRの1.5倍である.
この戦略は,トレンド追跡,動力,均線システムを統合して,論理的に完全な取引システムを構築している.戦略の優位性は,多次元的な信号確認機構と完善したリスク管理システムにある.提供された最適化方向によって,戦略はさらに向上する余地がある.戦略の核心論理を保持しながら,異なる市場環境下での適応性を強化することに重点が置かれている.
/*backtest
start: 2025-01-08 00:00:00
end: 2025-02-07 00:00:00
period: 3h
basePeriod: 3h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Gladston_J_G
//@version=5
strategy("Trend Strategy with Stop Loss", overlay=true, margin_long=100, margin_short=100)
// ———— Inputs ———— //
atrLength = input(14, "ATR Length")
supertrendMultiplier = input(3.0, "Supertrend Multiplier")
rsiLength = input(14, "RSI Length")
maLength = input(50, "MA Length")
trailOffset = input(1.5, "Trailing Stop ATR Multiplier")
// ———— Indicators ———— //
// Supertrend for trend direction
[supertrend, direction] = ta.supertrend(supertrendMultiplier, atrLength)
// RSI for momentum filter
rsi = ta.rsi(close, rsiLength)
// Moving Average for trend confirmation
ma = ta.sma(close, maLength)
// ATR for volatility-based stop loss
atr = ta.atr(atrLength)
// ———— Strategy Logic ———— //
// Buy Signal: Supertrend bullish + RSI not overbought + Price above MA
buyCondition = direction < 0 and rsi < 65 and close > ma
// Sell Signal: Supertrend turns bearish
sellCondition = direction > 0
// ———— Stop Loss & Trailing ———— //
stopPrice = close - (atr * trailOffset)
var float trail = na
if buyCondition and strategy.position_size == 0
trail := stopPrice
else
trail := math.max(stopPrice, nz(trail[1]))
// ———— Execute Orders ———— //
strategy.entry("Long", strategy.long, when=buyCondition)
strategy.close("Long", when=sellCondition)
strategy.exit("Trail Exit", "Long", stop=trail)
// ———— Visuals ———— //
plot(supertrend, "Supertrend", color=direction < 0 ? color.green : color.red)
plot(ma, "MA", color=color.blue)
plot(strategy.position_size > 0 ? trail : na, "Trailing Stop", color=color.orange, style=plot.style_linebr)
// ———— Alerts ———— //
plotshape(buyCondition, "Buy", shape.triangleup, location.belowbar, color.green, size=size.small)
plotshape(sellCondition, "Sell", shape.triangledown, location.abovebar, color.red, size=size.small)
plot(close)