Optimal Trade Entry (OTE) Zone Plotter [algo_aakash]Optimal Trade Entry (OTE) Zone Plotter locates the 62%-79% institutional retracement zone of a confirmed impulsive swing and keeps only the single most relevant zone per direction on the chart, fading it through disclosed mitigation states as price interacts with it.
Problem Statement
The Optimal Trade Entry concept, retracing into the 62%-79% region of an impulsive leg before continuation, is a well-known Fibonacci convention, but most public implementations simply plot every Fibonacci level on every swing they detect. This produces charts covered in overlapping retracement boxes, most of which come from insignificant swings that carry no real weight, and gives no visual indication of which zones are still fresh, already tested, or fully invalidated.
This indicator addresses that gap by filtering which swings are allowed to generate a zone in the first place, by showing only the current zone per direction at full strength, and by changing each zone's appearance as price actually interacts with it.
Methodology
Swing highs and lows are identified with ta.pivothigh/ta.pivotlow using a user-defined Pivot Length, so every swing referenced by the script is a confirmed pivot, evaluated only after barstate.isconfirmed is true.
Consecutive pivots of the same type extend a running swing extreme; a leg is only registered when the pivot type alternates (a low following a high, or a high following a low). Each candidate leg must then clear three disclosed checks before it is allowed to create a zone: the leg's price range must reach a minimum multiple of ATR, the swing candle's own body-to-range ratio must reach a minimum threshold, and, if the Break of Structure filter is enabled, the new swing must exceed the prior swing of the same type. Legs that fail any check produce no zone, no label, and no alert.
A qualifying leg generates one OTE zone: the shaded region between the 62% and 79% retracement of that leg, with the 70.5% level drawn as a two-layer glowing midline inside it. Only one bullish and one bearish zone are ever active at a time. When a new qualifying leg forms, the previous zone of that direction is frozen in place and, if enabled, kept as a single low-opacity historical reference rather than removed outright or left overlapping the new zone.
Each active zone tracks its own mitigation state on every confirmed bar: Fresh (untouched), Touched (price has wicked into the 62%-79% region), Mitigated (a confirmed close through the 79% boundary), or Invalidated (a confirmed close back through the leg's own origin point). State can only advance forward, and the zone's fill opacity and border color update automatically at each transition, so the chart communicates a zone's condition without any additional label or panel.
Signal Workflow
Step 1 — a confirmed swing pivot alternates direction, registering a candidate leg from the prior opposite pivot to the new one.
Step 2 — the leg is checked against the Minimum Swing Size, Body Ratio, and optional Break of Structure filters; legs that fail are discarded with no chart output.
Step 3 — a qualifying leg creates a new active OTE zone (62%-79%) with its 70.5% midline, and the previous zone of the same direction is frozen and faded.
Step 4 — the active zone's state advances from Fresh to Touched as price wicks into the zone on a confirmed bar.
Step 5 — the zone advances to Mitigated on a confirmed close through the 79% boundary, or to Invalidated on a confirmed close back through the leg's origin, at which point it is greyed out.
Step 6 — each transition and each zone entry/exit can trigger its own alert, gated by the corresponding toggle in the Alerts group.
Why This Indicator Is Different
Most public OTE/Fibonacci scripts draw a zone for every detected swing regardless of its significance, leaving multiple overlapping retracement boxes on the chart at once.
This script applies a disclosed three-part quality filter (ATR-relative swing size, swing candle body ratio, optional break-of-structure confirmation) before a swing is even allowed to generate a zone.
Only one zone per direction is ever shown at full strength; the prior zone automatically fades to a quiet historical reference the moment a new qualifying swing appears, keeping the chart focused on the current opportunity.
Zone fill opacity and border color are driven entirely by a four-state mitigation engine (Fresh/Touched/Mitigated/Invalidated) computed from confirmed price action against the zone's own boundaries, so the visual state of a zone is informative rather than purely decorative.
The 70.5% equilibrium level is rendered as a two-layer glow line rather than a plain dashed line, giving the zone's mid-point a distinct, non-generic appearance.
Inputs
Swing Detection
Pivot Length
ATR Length
OTE Quality Filter
Minimum Swing Size (x ATR)
Minimum Swing Candle Body Ratio
Require Break of Structure
OTE Zone
Show Bullish OTE Zones
Show Bearish OTE Zones
Zone Extension (bars)
Show Institutional Midline (70.5%)
Fade Previous Zone on New Swing
Visual Settings
Bullish/Bearish Zone Colour
Bullish/Bearish Midline Colour
Label Size
Alerts
Alert: New OTE Zone Created
Alert: Price Entered OTE Zone
Alert: Price Left OTE Zone
Alert: OTE Zone Mitigated
Alert: OTE Zone Invalidated
Alerts
Alerts are available for:
New Bullish/Bearish OTE Zone Created
Price Entered Bullish/Bearish OTE Zone
Price Left Bullish/Bearish OTE Zone
Bullish/Bearish OTE Zone Mitigated
Bullish/Bearish OTE Zone Invalidated
Practical Usage
Treat an active, Fresh OTE zone in the direction of the prevailing structure as a region to watch for a retracement entry, not a standalone entry signal by itself.
Use the Break of Structure filter on trending instruments to restrict zones to swings that genuinely extended structure, and disable it on ranging instruments where internal swings may still be meaningful.
Raise the Minimum Swing Size and Body Ratio filters on lower timeframes or noisy instruments to reduce the number of zones generated.
Watch the zone's fill opacity as a quick visual read of its condition: a bold zone has not been tested, a lighter fill has already been touched or mitigated, and a greyed zone has been invalidated and should generally be disregarded.
Combine the Entered/Exited alerts with your own confirmation criteria (candlestick behavior, lower-timeframe structure, etc.) rather than treating zone entry alone as a trigger.
Limitations
Swing pivots require bars to form on both sides before they confirm, so every zone is inherently placed a Pivot Length number of bars after the actual swing extreme occurred.
The quality filter reduces the number of zones shown but does not evaluate or predict the outcome of any individual retracement.
Only one active zone per direction is displayed at a time; if you want to review multiple historical zones simultaneously, enable "Fade Previous Zone on New Swing" and note that only the single most recent prior zone is retained, not a full history.
As with any retracement-based tool, results will vary across instruments, timeframes, and market regimes.
Notes
This indicator is a zone-location tool intended to highlight the current, quality-filtered Optimal Trade Entry region and its mitigation state through a disclosed, rule-based process.
All swing confirmations, zone creation, mitigation-state transitions, and invalidations are evaluated on confirmed bar closes only, so no element of the script repaints once drawn.
The output is intended to support retracement-based analysis and is not a standalone buy or sell recommendation.
Indicator

NQ Hourly Retracement Levels# NQ Hourly Retracement Levels
## Overview
This indicator identifies key price levels derived from hourly opens and midpoints formed during the overnight session (6:00 PM – 7:00 AM New York time) and displays them at the start of the New York futures session (8:00 AM ET). Each level is annotated with a statistically-derived hit rate — the historical probability that price will retrace to that level at some point during the 8:00 AM – 4:00 PM NY futures session.
⚠️ IMPORTANT: These statistics are derived exclusively from NQ (Nasdaq 100 E-mini futures) 1-minute data spanning 2013–2025 (~3,785 trading days). They are only valid when applied to NQ futures. Do not use this indicator on ES, YM, RTY, equities, forex, crypto, or any other instrument — the hit rates will not apply.
---
## What Problem Does This Solve?
During the NY futures session, price frequently retraces to levels established in the overnight session before making its directional move. Knowing which overnight levels have the highest historical probability of being touched — and how far away price currently is from them — helps traders identify high-probability targets and plan entries accordingly.
Rather than eyeballing overnight structure, this indicator quantifies it: each level shown on the chart has been tested across thousands of sessions to determine how reliably price returns to it.
---
## How the Statistics Were Calculated
### Data
- Instrument: NQ (Nasdaq 100 E-mini Futures, continuous contract)
- Source data timeframe: 1-minute bars
- Date range: January 2013 – March 2025
- Total days analysed: ~3,785 NY trading sessions
### Methodology
For each trading day, the following were calculated for every hourly level from 12:00 AM through 7:00 AM NY time (opens and midpoints):
1. Level price — For opens, the first 1-minute bar's open at the start of that hour. For midpoints, the high-to-low midpoint of the entire hourly candle ((high + low) / 2).
2. Retracement check — During the NY futures session (8:00 AM – 4:00 PM ET), every 1-minute bar was checked to see if its high-low range contained the level price (i.e., low ≤ level ≤ high). If yes, the level was marked as "hit" for that day.
3. Hit rate — The percentage of days on which the level was hit: retraced_days / total_days × 100.
4. Session pattern — Each day was classified into one of four patterns based on the relationship between the London session range (2:00 AM – 8:00 AM) and the Asia session range (8:00 PM – 2:00 AM):
- London Engulfs Asia: London high > Asia high AND London low < Asia low
- Asia Engulfs London: Asia high ≥ London high AND Asia low ≤ London low
- London Partial Up: London high > Asia high AND London low ≥ Asia low
- London Partial Down: London low < Asia low AND London high ≤ Asia high
5. Pattern-conditional hit rates — Hit rates were recalculated separately within each of the four session patterns, giving more precise probabilities when the morning pattern is known.
6. Adverse Excursion (MAE) — For each retracement, the maximum adverse move was tracked: how far price moved away from the level (in % terms) before eventually hitting it. This was used to derive a typical "tolerance band" per level — the MAE % shown in the table. In the indicator, this value serves as a reference threshold: the Distance from Level column uses it to colour-code how close current price is to each level, giving a sense of whether the level is immediately in play or still some distance away.
### Important Caveats
- Hit rates are historical averages. Any individual session can and will deviate.
- Hit rates do not indicate direction — they only say that price touched the level, not whether it reversed or broke through.
- A level being "hit" does not constitute a trade signal. It is one input among many.
- Statistics are based on the continuous NQ futures contract. Minor differences may exist between contract months or between NQ and MNQ (Micro NQ).
---
## Levels Displayed
At 8:00 AM NY time, the indicator draws horizontal lines for up to 16 overnight levels, subject to the Minimum Hit Rate % filter. Levels are drawn from most recent to oldest:
- 7–8am Mid — High/low midpoint of the 7:00–8:00 AM hourly candle
- 7am Open — Open price of the 7:00 AM hour
- 6–7am Mid — High/low midpoint of the 6:00–7:00 AM hourly candle
- 6am Open — Open price of the 6:00 AM hour
- 5–6am Mid — High/low midpoint of the 5:00–6:00 AM hourly candle
- 5am Open — Open price of the 5:00 AM hour
- 4–5am Mid — High/low midpoint of the 4:00–5:00 AM hourly candle
- 4am Open — Open price of the 4:00 AM hour
- 3–4am Mid — High/low midpoint of the 3:00–4:00 AM hourly candle
- 3am Open — Open price of the 3:00 AM hour
- 2–3am Mid — High/low midpoint of the 2:00–3:00 AM hourly candle
- 2am Open — Open price of the 2:00 AM hour
- 1–2am Mid — High/low midpoint of the 1:00–2:00 AM hourly candle
- 1am Open — Open price of the 1:00 AM hour
- 12–1am Mid — High/low midpoint of the 12:00–1:00 AM hourly candle
- 12am Open — Open price of the 12:00 AM hour
Lines are colour-coded by their MAE tier (see MAE % explanation below) so you can visually distinguish tighter from wider levels at a glance. Each line is labelled with the level name and its hit rate percentage.
Lines extend bar-by-bar through the NY session and are optionally removed when price touches them (see Remove Level When Hit input).
---
## The Statistics Table
The table (displayed during the NY session) provides a live, per-bar reference for the top 11 levels. It has five columns:
### Column 1 — Level
The name of the overnight level (e.g. "7-8am Mid", "6am Open").
### Column 2 — Hit %
The historical hit rate for this level given today's session pattern. If the pattern cannot yet be determined, the overall (pattern-agnostic) hit rate is shown instead. Levels are listed in descending order of hit rate.
### Column 3 — MAE %
The typical Maximum Adverse Excursion tier for this level. This is the approximate percentage move away from the level that was observed in historical data before price eventually retraced — a rough guide to how much drawdown a position targeting this level may experience before it pays off.
MAE colour coding (also applied to the level lines on the chart):
- Blue (≤ 0.25%) — Very tight. Price tended to reach the level quickly with minimal adverse move.
- Purple (≤ 0.30%) — Tight. Small adverse excursion typical.
- Deep Orange (≤ 0.35%) — Moderate. Some heat expected.
- Teal (≤ 0.40%) — Moderate-wide.
- Orange (≤ 0.45%) — Wide. Requires more tolerance.
- Pink (≤ 0.50%) — Wide. Older or more distant levels.
### Column 4 — Dist Now (live, updates every bar)
The current distance between the last close price and the level, expressed as a percentage: abs(close − level) / close × 100.
Colour coding:
- Green — Distance ≤ MAE %. Price is within the typical adverse excursion range. Level is right here and very much in play.
- Yellow — Distance ≤ 2× MAE %. Price is approaching. Worth watching closely.
- Orange — Distance ≤ 3× MAE %. Level is possible but price needs to travel further to reach it.
- Grey — Distance > 3× MAE %. Level is far away, lower priority for the current bar.
Once a level has been hit, this cell shows "Hit ✓" in teal rather than a distance.
### Column 5 — Status
- Pending (yellow) — Level has not yet been touched this session.
- Hit ✓ (teal) — Price has traded through this level at some point during today's NY session.
### Header rows
- Active Session — Confirms the NY session is live (shown in red). Outside NY hours the table shows "Closed".
- Pattern — The detected London/Asia session pattern for today. This determines which set of conditional hit rates is shown.
- Active Levels — The number of level lines currently drawn on the chart (decreases as levels are hit and removed, if that option is enabled).
---
## Session Boxes
In addition to the level lines, the indicator draws session range boxes for three sessions:
- NY Session (8:00 AM – 4:00 PM ET) — Red by default
- London Session (2:00 AM – 8:00 AM ET) — Blue by default
- Asia Session (8:00 PM – 2:00 AM ET) — Orange by default
Each box tracks the high and low of its session in real time. These boxes serve both as visual context and as the input to the London/Asia pattern detection logic.
---
## Inputs Reference
### Trading Sessions
- Show NY Session (default: On) — Draws the NY session range box.
- NY Session Colour (default: Red) — Colour of the NY box border and background tint.
- Show London Session (default: On) — Draws the London session range box.
- London Session Colour (default: Blue) — Colour of the London box.
- Show Asia Session (default: On) — Draws the Asia session range box.
- Asia Session Colour (default: Orange) — Colour of the Asia box.
- Range Area Transparency (default: 90) — Opacity of the session box fill. 0 = fully opaque, 100 = invisible.
- Range Outline (default: On) — Whether to draw the session box border.
### Hourly Levels
- Show Hourly Levels at NY Open (default: On) — Master toggle. Draws all overnight levels at 8:00 AM.
- Show Hourly Opens (default: On) — Whether to include hourly open levels.
- Show Hourly Midpoints (default: On) — Whether to include hourly midpoint levels.
- Minimum Hit Rate % to Display (default: 75%) — Only levels with a hit rate at or above this threshold are drawn. Raise it to reduce clutter; lower it to see more levels. 75% is a reasonable default for NQ.
- Line Width (default: 1) — Thickness of the level lines. Range: 1–5.
- Retracement Line Style (default: Dashed) — Visual style of the level lines: Solid, Dashed, or Dotted.
- Label Size (default: Small) — Size of the text labels on each line: Tiny, Small, Normal, or Large.
- Remove Level When Hit (default: On) — When enabled, a level line and its label are deleted the moment price touches the level. Keeps the chart clean as the session progresses. Disable if you want all levels to remain visible throughout the session.
### Table Settings
- Show Statistics Table (default: On) — Master toggle for the stats table.
- Stats Table Position (default: Bottom Right) — Where the table appears on the chart. Options: Bottom/Middle/Top combined with Left/Center/Right.
- Stats Table Size (default: Small) — Text size inside the table: Auto, Tiny, Small, Normal, Large, or Huge.
---
## Recommended Usage
1. Apply only to NQ futures (CME: NQ1!, NQ continuous, or a specific front-month contract). The statistics do not transfer to other instruments.
2. Use on a timeframe of 1 minute to 15 minutes for the level lines and distance column to be most meaningful. On higher timeframes, individual bars may span several levels simultaneously.
3. Check the Pattern row in the table at the NY open. The indicator automatically applies pattern-conditional hit rates — so the percentages shown already reflect the historical accuracy for today's specific London/Asia relationship. The Asia Engulfs London pattern historically produces the highest hit rates across nearly all levels; London Engulfs Asia tends to produce the lowest. If the pattern shows as "Unknown" (rare, typically on the first bars of a chart load), the indicator falls back to overall hit rates.
4. Focus on green Dist Now cells at the NY open — these are levels price is already at or very close to. Green means you are within the typical adverse excursion zone, so risk is relatively defined.
5. Use the MAE % as a stop/risk guide — if price is at a level with a 0.25% MAE, a stop placed beyond 0.25% from the level is consistent with how the historical data behaved. This is not a hard rule but a statistical reference point.
6. Hit rate ≠ trade signal. A 94% hit rate on the 7–8am midpoint means price touched that level on 94% of historical days. It says nothing about whether price reversed, broke through, or what the risk/reward of any particular trade was.
---
## Known Limitations
- Replay / historical bars: The Dist Now column is live and reflects the current bar's close. On historical bars it will show the closing price of that bar, not today's live price.
- Pattern detection requires completed sessions: If the London or Asia session data is incomplete (e.g. on the first few bars of a new chart load), the pattern may show as "Unknown" and overall hit rates will be used instead of pattern-conditional rates.
- Level collisions: If two levels are very close in price (within ~0.5 points), their labels may overlap. Switching Label Size to Tiny can help if this is an issue on your layout.
- Contract rollovers: Around futures contract expiry, price gaps can cause overnight levels to be further from price than usual. Exercise judgement during roll weeks.
---
## Methodology Notes
Pattern classification, hit rate calculation, and adverse excursion analysis were computed from 12 years of NQ 1-minute data using Python (pandas). All times are New York (Eastern) time. Indicator

NQ Hourly Retracements - 12y Stats with LevelsHour Stats with Levels - PulseWire Indicator Description
IMPORTANT: NQ FUTURES ONLY
This indicator is specifically designed for and calibrated to NQ (Nasdaq-100 E-mini) futures only. The statistical data is derived exclusively from 13 years of NQ price action (2013-2025). Do not use this indicator on any other asset, ticker, or market as the statistics will not be applicable and may lead to incorrect trading decisions.
Overview
"Hour Stats with Levels" is a statistical analysis indicator that provides real-time probability-based insights into hourly price behavior patterns. The indicator combines historical pattern recognition with live price action to help traders anticipate potential sweep and reversal scenarios within each trading hour.
Originality and Core Concept
This indicator is based on a comprehensive statistical analysis of 12y years of 1-minute NQ futures data, examining a specific price pattern: when an hourly candle opens inside the previous hour's range. Unlike generic support/resistance indicators, this tool provides hour-specific, context-aware probabilities based on 30,000+ historical occurrences of this pattern.
The originality lies in three key areas:
Pattern-Specific Statistics: Rather than applying generic technical analysis, the indicator only activates when the current hour opens within the previous hour's range, providing relevant statistics for this exact scenario.
Context-Aware Probabilities: Statistics are differentiated based on whether the current hour opened above or below the previous hour's open, recognizing that bullish and bearish opening contexts produce different behavioral patterns.
Comprehensive Retracement Tracking: The indicator tracks four independent retracement levels after a sweep occurs, showing the probability of price returning to: the swept level itself (90+% probability), the 50% level, the current hour's open, and the opposite extreme.
How It Works
The Core Pattern
The indicator monitors a specific price structure:
Setup Condition: The current hourly candle opens inside (between) the previous hour's high and low
Sweep Event: Price then breaks above the previous high (high sweep) or below the previous low (low sweep)
Retracement Analysis: After a sweep, the indicator tracks whether price retraces to key levels
Statistical Foundation
The underlying analysis processed 1-minute bar data from 2013-2025, identifying every instance where an hourly candle opened inside the previous hour's range. For each occurrence, the system tracked:
Whether the high, low, or both were swept during that hour
The distance of the sweep measured as a percentage of the previous hour's range
Whether price retraced to four key levels: the swept level, the 50% point, the current open, and the opposite extreme
These measurements were aggregated for all 24 hours of the trading day, with separate statistics for bullish contexts (opening above previous open) and bearish contexts (opening below previous open), creating 48 unique statistical profiles.
Sweep Distance Percentiles
The "reversal levels" are drawn based on historical sweep distance distributions:
25th Percentile: 75% of historical sweeps were larger than this distance. This represents a conservative reversal zone where smaller, contained sweeps typically reverse.
Median (50th Percentile): The midpoint of all historical sweep distances. Half of all sweeps reversed before reaching this level, half extended beyond it.
75th Percentile: Only 25% of sweeps extended beyond this distance. This represents an extended sweep zone where price has historically shown exhaustion.
For example, if the previous hour's range was 20 points and the median high sweep distance is 40% of range, the median reversal level would be placed 8 points above the previous high.
How to Use the Indicator
Sweeps were calculated using 1m data - as such, it's recommended to use the indicator on a 1min chart
Visual Components
Hour Delimiter (Gray Vertical Line)
Marks the start of each new hour
Helps identify when new statistics become active
Sweep Markers
Green "H" label: High sweep has occurred this hour
Red "L" label: Low sweep has occurred this hour
Markers appear on the exact bar where the sweep happened
Target Levels (Blue Lines)
Prev Open: Previous hour's opening price
Prev High: Previous hour's highest price (sweep target)
Prev Low: Previous hour's lowest price (sweep target)
Prev 50%: Midpoint of previous hour's range
Current Open: Current hour's opening price (key retracement target)
Reversal Levels (Purple Dashed Lines)
Positioned beyond the previous high/low based on historical sweep percentiles
Three levels above previous high (for high sweeps)
Three levels below previous low (for low sweeps)
These represent statistically-derived zones where sweeps typically exhaust
The Statistics Table
The table dynamically updates each hour and displays different statistics based on whether the current hour opened above or below the previous hour's open.
Status Row
Shows current state: waiting for sweep, or which sweep(s) have occurred
If waiting, indicates which sweep is more probable based on historical data
SWEEP PROBABILITIES Section
High Sweep: Historical probability (%) that price will sweep the previous high this hour
Low Sweep: Historical probability (%) that price will sweep the previous low this hour
Both Sweeps: Historical probability (%) that price will sweep both levels this hour
These probabilities are derived from counting how many times each pattern occurred in similar historical contexts. For example, "High Sweep: 73.18%" means that in 73.18% of historical occurrences where the hour opened in this same context (same hour of day, same position relative to previous open), price swept the previous high before the hour closed.
AFTER HIGH SWEEP → Section
These statistics activate only after a high sweep has occurred. They show the probability of price retracing to various levels:
→ Prev High: Probability that price returns to (or below) the level it just swept. This is typically 90%+ because sweeps often act as "false breakouts" or liquidity grabs before reversal.
→ 50% Level: Probability that price retraces at least halfway back into the previous hour's range. This represents a moderate retracement.
→ Current Open: Probability that price retraces all the way back to where the current hour opened. This indicates a complete reversal of the sweep move.
→ Prev Low: Probability that price retraces entirely through the previous range to touch the opposite extreme. This represents a full reversal pattern.
AFTER LOW SWEEP → Section
Mirror of the above, but for low sweeps:
→ Prev Low: Retracement to the swept low level (90%+ probability)
→ 50% Level: Retracement to middle of range
→ Current Open: Full retracement to current hour's open
→ Prev High: Complete reversal to opposite extreme
Important Note on Retracement Statistics: These percentages are tracked independently. A 90% probability of returning to the swept level doesn't mean there's only a 10% chance of deeper retracement. Price can (and often does) retrace through multiple levels sequentially. The percentages show how many times price reached at least that level, not where it stopped.
Trading Applications
Anticipating Sweeps
When an hour opens inside the previous range, check the probabilities. If "High Sweep: 70%" and "Low Sweep: 30%", you know there's a 70% historical likelihood of an upside sweep occurring this hour. This doesn't guarantee it will happen, but provides statistical context for potential setups.
Reversal Trading
The most reliable pattern in the data is the 90%+ retracement probability to swept levels. When a sweep occurs, traders can anticipate a retracement back to at least the swept level in the vast majority of cases. The reversal level percentiles help identify where sweeps may exhaust.
Position Management
The retracement probabilities help manage existing positions. For example, if you're long and a high sweep occurs, you know there's a 90%+ chance of at least some retracement to the swept level, which might inform profit-taking or stop-loss decisions.
Confluence with Current Open
The "Current Open" retracement statistics (typically 60-70%) highlight the magnetic quality of the hour's opening price. After a sweep, price frequently returns to test this level.
Customization Options
The indicator offers extensive visual customization:
Toggle on/off: hour delimiters, sweep markers, target levels, reversal levels, statistics table
Customize colors, line widths, and styles for all visual elements
Adjust label sizes and table position
Show/hide individual target levels and reversal percentiles
Limitations and Considerations
Pattern-Specific: The indicator only provides statistics when the current hour opens inside the previous hour's range. If the hour opens outside this range (gaps up or down), the statistics are not applicable.
Historical Probabilities: The percentages represent historical frequencies, not predictions. A 70% probability means it happened 70% of the time historically, not that it will definitely happen 7 out of 10 times going forward.
NQ-Specific Calibration: All statistics are derived from NQ futures data. Market behavior, volatility, and patterns differ across assets.
Hour-Specific Behavior: Different hours show dramatically different statistics. For example, the 9 AM EST hour (market open) shows much higher sweep probabilities (80%+) than the 5 PM EST hour (30-50%) due to differing liquidity and volatility conditions.
No Guarantee of Execution: While a 90% retracement probability is high, it means 10% of the time, price did NOT retrace. Always use proper risk management.
Technical Notes
The indicator uses hourly timeframe data via request.security() to determine previous hour values
Sweep detection occurs in real-time on the chart's timeframe
Statistics are hardcoded from the comprehensive backtested analysis (not calculated on-the-fly)
The indicator stores static values at the start of each hour to ensure consistency as the hour progresses
All percentage values are rounded to one decimal place for clarity
This indicator provides a statistically-grounded framework for understanding hourly price behavior in NQ futures. By combining real-time pattern detection with comprehensive historical analysis, it offers traders probabilistic insights to inform decision-making process within the specific context of each trading hour. Indicator

Indicator

Indicator

Auto Fibonacci and Gann Fan/Retracements ComboIntroduction
This is a combination of Fibonacci and Gann fan/retracements.
The script can automatically draw as many:
Fibonacci Retracements
Fibonacci Fan
Gann Retracements
Gann Fan
as the user requires on the chart. Each level set or fan consists of 7 lines based on the most important ratios of Fibonacci/Gann.
Basics
What are Fibonacci retracements?
Fibonacci retracement levels are horizontal lines that indicate where support and resistance are likely to occur. They stem from Fibonacci’s sequence. Each level is associated with a percentage which is how much of a prior move the price has retraced. The Fibonacci retracement levels are 23.6%, 38.2%, 61.8%, and 78.6%. While not officially a Fibonacci ratio, 50% is also used. The indicator is useful because it can be drawn between any two significant price points, such as a high and a low. The indicator will then create the levels between those two points.
What are Gann retracements?
A developer of technical analysis and trading was W.D. Gann. Gann theory expects a normal retracement of 50 percent. This means that under normal selling pressure, the stock price will decline half the amount of its most recent rise, and vice versa. It also suggests that retracements occur at the halfway point of a move, such as 25 percent (half of 50 percent), 12.5 percent (half of 25 percent), and so on.
What is Fibonacci fan?
Fibonacci fan is a set of sequential trend lines drawn from a trough or peak through a set of points dictated by Fibonacci retracements. The first step to create it is to draw a trend line covering the local lowest and highest prices of a security. To reach retracement levels, the trader divides the difference in price at the low and high end by ratios determined by the Fibonacci series. The lines formed by connecting the starting point for the base trend line and each retracement level create the Fibonacci fan.
What is Gann fan?
A Gann fan consists of a series of lines called Gann angles. These angles are superimposed over a price chart to show potential support and resistance levels. The resulting image is supposed to help technical analysts predict price changes. Gann believed the 45-degree angle to be most important, but the Gann fan also draws angles at degrees like 75, 63.75, 26.25 and 15. The Gann fan originates at a low or high point. The resulting lines show areas of potential future support and resistance. The 45-degree line is known as the 1:1 line because the price will rise or fall at a 45-degree angle when the price moves up/down one unit for each unit of time. All other lines in the Gann fan are drawn above and below the 1:1 line. The other angles are associated with 2:1, 3:1, 4:1, 8:1 and 1:8, 1:4, 1:3, and 1:2 time-to-price moves.
Challenges
The most of the time I dedicated to writing this script has been spent on handling these problems:
1. Finding Local Highest/Lowest Prices
In order to draw Fibonacci and Gann fan/retracements, it's necessary to find local highest and lowest price points (Extrema) on the chart. As this could be so challenging, most traders and coders draw the lines covering the low and high prices over a given period of time or a limited number of bars back instead. I already wrote an indicator using this approach ( Auto Fibonacci Combo ).
In this new script I tried to find the exact highest and lowest prices based on this idea that: if a high point is formed lower than previous high which was after a lowest point, then that previous one was the local highest point, and vice versa if a low point is formed higher than previous low which was after a highest point, then that previous one was the local lowest point. So logically an extremum price on the chart won't be found until the next high/low point is formed.
2. Finding Proper Chart Scale for Gann Fan
Based on the theory, Gann angles are sensitive to the chart price scale and in order to have the right angles, the chart must be made with the proper scale. J.A. Hyerczyk in his book "Pattern, Price & Time - Using Gann Theory in Technical Analysis" suggests that the easiest way to determine the scale of a market is by taking the difference between top-to-top and bottom-to-bottom and dividing it by the time it took the market to move from top to top and bottom to bottom.
Thus on a properly constructed chart, the basic equation for calculating Gann angles is: Price * Time.
3. Drawing Fans and Relocating Fan Labels at Each New Bar in Pine (A Programming-Related Subject)
To do this, I used linear equations and line slopes. Of course it was so complicated and exhausting, but finally I overcame that thanks to my genius cousin.
Settings and Usage
By default, the script shows detected extremum points plus 1 Fibonacci fan, 1 Gann fan, 1 set of Fibonacci retracements and no Gann retracements on the chart. All of these could be changed in the indicator settings beside the color and transparency of each line.
Feel free to use this and send me your thoughts! Indicator

Indicator
