OPEN-SOURCE SCRIPT
Enhanced OB Retest Strategy v7.0

The OB Retest Strategy is a full Order Block retest trading system that detects, plots, and trades OB zones across multiple timeframes. It uses structure breaks, retrace depth, and ATR filters to identify strong reversal or continuation setups.
⸻
⚙️ Core Features
• Multi-timeframe OB detection using break-of-structure (BOS) logic
• Automatic zone creation for bullish and bearish order blocks
• Smart merging of overlapping OB zones
• Dynamic flip-zone logic that turns invalidated OBs into new zones
• Wick zone detection for high-precision entries
• ATR-based trailing stop and optional breakeven
• Adjustable retrace depth, breakout %, and ATR filters
• Built-in performance table showing PnL, win rate, and total trades
• Fully backtestable with date range and commission control
⸻
🧠 Logic Summary
1. Detects a BOS on the higher timeframe.
2. Identifies the last opposing candle as the valid OB.
3. Validates the OB based on ATR size and breakout strength.
4. Waits for price to retest the zone to a set depth.
5. Executes trades and manages exits using trailing stop or breakeven.
6. Flips invalidated zones automatically.
⸻
💡 Usage Tips
• Best used on 1H to 4H charts for swing setups.
• Tune ATR and breakout thresholds for your market’s volatility.
• Combine with higher-timeframe bias or liquidity levels for better accuracy.
⸻
⚠️ Notes
• For educational and testing purposes only.
• Backtested results do not predict future performance.
• Always test before live use.
⸻
⚙️ Core Features
• Multi-timeframe OB detection using break-of-structure (BOS) logic
• Automatic zone creation for bullish and bearish order blocks
• Smart merging of overlapping OB zones
• Dynamic flip-zone logic that turns invalidated OBs into new zones
• Wick zone detection for high-precision entries
• ATR-based trailing stop and optional breakeven
• Adjustable retrace depth, breakout %, and ATR filters
• Built-in performance table showing PnL, win rate, and total trades
• Fully backtestable with date range and commission control
⸻
🧠 Logic Summary
1. Detects a BOS on the higher timeframe.
2. Identifies the last opposing candle as the valid OB.
3. Validates the OB based on ATR size and breakout strength.
4. Waits for price to retest the zone to a set depth.
5. Executes trades and manages exits using trailing stop or breakeven.
6. Flips invalidated zones automatically.
⸻
💡 Usage Tips
• Best used on 1H to 4H charts for swing setups.
• Tune ATR and breakout thresholds for your market’s volatility.
• Combine with higher-timeframe bias or liquidity levels for better accuracy.
⸻
⚠️ Notes
• For educational and testing purposes only.
• Backtested results do not predict future performance.
• Always test before live use.
Script de código aberto
No verdadeiro espirito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam entendê-lo e verificá-lo. Parabéns ao autor Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações e regida pelas Regras da Casa.
Aviso legal
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.
Script de código aberto
No verdadeiro espirito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam entendê-lo e verificá-lo. Parabéns ao autor Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações e regida pelas Regras da Casa.
Aviso legal
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.