OPEN-SOURCE SCRIPT
Modüler Trailing Stop (Doğru Ölçekli)

📌 Modular Trailing Stop – Advanced Risk Management for Long & Short Strategies
Modular Trailing Stop is a dual-direction stop management tool that calculates independent stop levels for long and short positions. It is fully scale-adjusted, strategy-agnostic, and optimized for TradingView integration.
🚀 Key Features
🔹 Dual-Side Stop Logic
Separate Ref High and Stop levels for long and short trades, allowing precise and directional control.
🔹 Modular Architecture
Designed to be easily integrated into any indicator or strategy. Operates independently from entry signals.
🔹 Accurate Price Scaling
Automatically adjusts to symbol tick size using syminfo.mintick, ensuring precision across all markets (BTCUSD, ETHUSD, USDTRY...).
🔹 Static Trailing Logic
Once a position is opened, stop levels are anchored to a fixed reference price and adjusted by ATR volatility.
🔹 User-Configurable
- Customizable ATR period and multiplier
- Manual reference high percentages for long and short
- Real-time table display on the chart with key values
⚙️ Calculation Formulas
- Ref High (Long) = Base Price × (1 + %Offset) × scaleFix
- Ref High (Short) = Base Price × (1 - %Offset) × scaleFix
- Step = ATR × Multiplier
- Long Stop = Ref High (Long) – Step
- Short Stop = Ref High (Short) + Step
📈 Use Cases
- Volatility-based static stop-loss framework
- Compatible with RSI, EMA crossover, breakout, and custom signal systems
- Backtesting via TradingView Strategy Tester (WinRate, Sharpe, AvgPnL...)
🧪 Example Backtest (BTCUSDT, 4H Timeframe)
- Win Rate: 41.9%
- Sharpe Ratio: 0.27
- Profit Factor: 1.31
- Avg Trade Duration: 18 bars
- Test Strategy: RSI-based entries + modular trailing stops
🧩 Strategy Integration (Sample)
strategy.exit("Long Exit", from_entry="Long", stop=longStop)
strategy.exit("Short Exit", from_entry="Short", stop=shortStop)
🏁 Summary
Modular Trailing Stop is a robust and intuitive stop-loss management tool. It can be used as a standalone module or combined with any strategy for improved position handling, effective drawdown control, and systematic risk management.
Whether you're building strategies or optimizing entries and exits, this tool brings precision and modular flexibility to your trading workflow.
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。