OPEN-SOURCE SCRIPT

S4_IBS_Mean_Rev_3candleExit

300
Overview:
This is a rules-based, mean reversion strategy designed to trade pullbacks using the Internal Bar Strength (IBS) indicator. The system looks for oversold conditions based on IBS, then enters long trades, holding for a maximum of 3 bars or until the trade becomes profitable.

The strategy includes:
✅ Strict entry rules based on IBS
✅ Hardcoded exit conditions for risk management
✅ A clean visual table summarizing key performance metrics

How It Works:
1. Internal Bar Strength (IBS) Setup:
The IBS is calculated using the previous bar’s price range:
IBS = (Previous Close - Previous Low) / (Previous High - Previous Low)
IBS values closer to 0 indicate price is near the bottom of the previous range, suggesting oversold conditions.

2. Entry Conditions:
IBS must be ≤ 0.25, signaling an oversold setup.
Trade entries are only allowed within a user-defined backtest window (default: 2024).
Only one trade at a time is permitted (long-only strategy).

3. Exit Conditions:
If the price closes higher than the entry price, the trade exits with a profit.
If the trade has been open for 3 bars without showing profit, the trade is forcefully exited.
All trades are closed automatically at the end of the backtest window if still open.

Additional Features:
📊 A real-time performance metrics table is displayed on the chart, showing:

- Total trades
- % of profitable trades
- Total P&L
- Profit Factor
- Max Drawdown
- Best/Worst trade performance

📈 Visual markers indicate trade entries (green triangle) and exits (red triangle) for easy chart interpretation.

Who Is This For?
This strategy is designed for:
✅ Traders exploring systematic mean reversion approaches
✅ Those who prefer strict, rules-based setups with no subjective decision-making
✅ Traders who want built-in performance tracking directly on the chart

Note: This strategy is provided for educational and research purposes. It is a backtested model and past performance does not guarantee future results. Users should paper trade and validate performance before considering real capital.

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.