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.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.