OPEN-SOURCE SCRIPT
OTE - Optimal Trade Entry

OTE - Optimal Trade Entry
Marks the 61.8%–79% Fibonacci retracement of each confirmed impulse leg as a shaded zone. In ICT methodology this band — anchored at 61.8%, centred on the 70.5% "sweet spot," and bounded at 79% — is where institutional flow is most likely to re-enter after a pullback.
A bullish OTE zone is drawn when a swing high confirms after a swing low (an up-leg has completed), marking the expected pullback area for a long re-entry. A bearish OTE zone is drawn when a swing low confirms after a swing high (a down-leg has completed), marking the expected pullback area for a short. Three timeframes overlay simultaneously, with border weight increasing per TF so higher-timeframe zones always stand out.
How it works
For each of the three configured timeframes, the script runs pivot detection inside request.security and tracks the most recent confirmed swing high and swing low.
Each zone records the original swing (the Fibonacci anchor), its 70.5% midline, and its top and bottom bounds. A zone is marked mitigated the first bar price wicks into it. Mitigated zones stop extending right and re-render in grey; they can be hidden entirely if the chart gets busy.
All boxes, lines, and labels are rebuilt on the last bar so styling stays current.
How to read it
Each timeframe is differentiated by border weight (thin → medium → thick), leaving color free for direction:
A few visual elements help anchor each zone:
When OTE zones from different timeframes stack at the same price, that's confluence — a 1H bullish OTE coinciding with a 4H bullish OTE is structurally more interesting than either zone alone.
Inputs
Built-in alerts
Note: these fire on zone formation, not on price entry into the zone. If you want entry-trigger alerts, set TradingView alerts on price crossing into the published zone levels.
Notes
OTE is a focused subset of Fibonacci retracement analysis — it isolates the 61.8%–79% band, where ICT methodology argues the highest-probability re-entry sits. The full Fibonacci grid (0%, 23.6%, 38.2%, 50%, 61.8%, 78.6%, 100%) is available in the Automatic Fibonacci Retracement Levels (MTF) indicator if you want to see the whole structure rather than just the OTE band.
The pivot length controls what counts as an impulse leg. A length of 5 catches most meaningful intraday and swing structure. Smaller values produce overlapping zones from minor swings; larger values restrict to major impulse legs but lag substantially. Pick a value that matches what you'd manually call "the recent leg."
Higher-timeframe pivots don't confirm until pivot length bars after the actual swing. On a Daily timeframe with length 5, that's five days of delay between the actual high or low and the OTE zone appearing. Zones are non-repainting once printed, but they appear later than the swing itself.
A mitigated OTE isn't a failed one. Price wicking into the zone is the expected behaviour — the zone is doing its job. The mitigation flag is informational: it tells you the zone has been tested. Whether the test held or failed is a separate question your own system needs to answer.
The framework here borrows from Smart Money Concepts / ICT trading, where OTE is one of the canonical entry techniques. Whether you accept the institutional-flow narrative or just use the 61.8%–79% band as a high-quality retracement zone, the indicator is purely mechanical: it finds the impulse legs and draws the bands.
This is a structural tool, not a signal generator. It marks the highest-quality retracement zone of each completed impulse.
Five years of work on a trading system left me with dozens of indicators that ultimately didn't earn a place in the final build. They're not failures — they're tools that solved problems I no longer needed solved. So instead of shelving them, I'm publishing the majority of them open-source.
If you're a discretionary trader, take what's useful. If you're a systems builder, the source is yours to dissect, modify, and improve. The best return on five years of work is for it to keep working — for someone.
If you use this script — or part of it — in your own work, please credit the original with a link back to my profile.
Note: these indicators have been updated to Pine Script v6 — some manually, some with AI assistance.
Marks the 61.8%–79% Fibonacci retracement of each confirmed impulse leg as a shaded zone. In ICT methodology this band — anchored at 61.8%, centred on the 70.5% "sweet spot," and bounded at 79% — is where institutional flow is most likely to re-enter after a pullback.
A bullish OTE zone is drawn when a swing high confirms after a swing low (an up-leg has completed), marking the expected pullback area for a long re-entry. A bearish OTE zone is drawn when a swing low confirms after a swing high (a down-leg has completed), marking the expected pullback area for a short. Three timeframes overlay simultaneously, with border weight increasing per TF so higher-timeframe zones always stand out.
How it works
For each of the three configured timeframes, the script runs pivot detection inside request.security and tracks the most recent confirmed swing high and swing low.
- A swing high confirming after the most recent swing low triggers a bullish OTE: the impulse leg is from low to high, and the zone is drawn between the 61.8% and 79% retracements down from the high.
- A swing low confirming after the most recent swing high triggers a bearish OTE: the impulse leg is from high to low, and the zone is drawn between the 61.8% and 79% retracements up from the low.
Each zone records the original swing (the Fibonacci anchor), its 70.5% midline, and its top and bottom bounds. A zone is marked mitigated the first bar price wicks into it. Mitigated zones stop extending right and re-render in grey; they can be hidden entirely if the chart gets busy.
All boxes, lines, and labels are rebuilt on the last bar so styling stays current.
How to read it
Each timeframe is differentiated by border weight (thin → medium → thick), leaving color free for direction:
- Bullish OTE (default teal) — expected pullback area for a long
- Bearish OTE (default red) — expected pullback area for a short
- Mitigated (default grey) — price has already wicked into the zone
A few visual elements help anchor each zone:
- Origin line — a vertical line from the anchor swing point to the zone edge, showing exactly where the Fibonacci was measured from. Useful when several zones stack and you need to identify the impulse leg each one belongs to.
- 70.5% midline — a dashed line through the centre of each zone. ICT methodology treats the midline as the precision-entry level within the band.
- Label — timeframe and direction (▲ bullish, ▼ bearish).
When OTE zones from different timeframes stack at the same price, that's confluence — a 1H bullish OTE coinciding with a 4H bullish OTE is structurally more interesting than either zone alone.
Inputs
- Show mitigated zones — keep entered zones on chart in dimmed style. Default on.
- Labels — show or hide zone labels. Default on.
- 70.5% midline — draw the precision-entry line through the centre of each zone. Default on.
- Origin line — draw the vertical anchor line from swing to zone. Default on.
- Max zones (per TF) — cap on stored zones drawn per timeframe. Default 10.
- Pivot Length — bars required on each side to confirm a swing. Default 5.
- Timeframes 1/2/3 — defaults: 1H, 4H, Daily. Each independently enabled. TF3 off by default.
- Colors — bullish, bearish, mitigated.
Built-in alerts
- Bullish OTE Zone — fires when a new bullish OTE zone is formed on any enabled timeframe
- Bearish OTE Zone — same, for bearish
Note: these fire on zone formation, not on price entry into the zone. If you want entry-trigger alerts, set TradingView alerts on price crossing into the published zone levels.
Notes
OTE is a focused subset of Fibonacci retracement analysis — it isolates the 61.8%–79% band, where ICT methodology argues the highest-probability re-entry sits. The full Fibonacci grid (0%, 23.6%, 38.2%, 50%, 61.8%, 78.6%, 100%) is available in the Automatic Fibonacci Retracement Levels (MTF) indicator if you want to see the whole structure rather than just the OTE band.
The pivot length controls what counts as an impulse leg. A length of 5 catches most meaningful intraday and swing structure. Smaller values produce overlapping zones from minor swings; larger values restrict to major impulse legs but lag substantially. Pick a value that matches what you'd manually call "the recent leg."
Higher-timeframe pivots don't confirm until pivot length bars after the actual swing. On a Daily timeframe with length 5, that's five days of delay between the actual high or low and the OTE zone appearing. Zones are non-repainting once printed, but they appear later than the swing itself.
A mitigated OTE isn't a failed one. Price wicking into the zone is the expected behaviour — the zone is doing its job. The mitigation flag is informational: it tells you the zone has been tested. Whether the test held or failed is a separate question your own system needs to answer.
The framework here borrows from Smart Money Concepts / ICT trading, where OTE is one of the canonical entry techniques. Whether you accept the institutional-flow narrative or just use the 61.8%–79% band as a high-quality retracement zone, the indicator is purely mechanical: it finds the impulse legs and draws the bands.
This is a structural tool, not a signal generator. It marks the highest-quality retracement zone of each completed impulse.
Five years of work on a trading system left me with dozens of indicators that ultimately didn't earn a place in the final build. They're not failures — they're tools that solved problems I no longer needed solved. So instead of shelving them, I'm publishing the majority of them open-source.
If you're a discretionary trader, take what's useful. If you're a systems builder, the source is yours to dissect, modify, and improve. The best return on five years of work is for it to keep working — for someone.
If you use this script — or part of it — in your own work, please credit the original with a link back to my profile.
Note: these indicators have been updated to Pine Script v6 — some manually, some with AI assistance.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.