Book: Understanding Gaps: Profiting from the Opening Gap
Author: Scott Andrews
Difficulty: Intermediate
The Big Idea
A market can revisit yesterday’s close frequently and still be difficult to trade profitably. Small successes can be outweighed by fewer large losses, while waiting for a more distant target changes both the payoff and the probability of reaching it.
Scott Andrews organizes this problem around the opening gap’s location, stop distance, and exit plan. This companion develops the reasoning behind those choices with original calculations, timestamped observation exercises, and a session-mapping indicator. Keep the book beside you for its charts and historical research.
The supplied 2008 Traders Press edition identifies Andrews as author and Edward Dobson as editor. References below use the book’s printed Arabic page numbers: printed page 1 is PDF page 7, so add six to find its PDF page. The file contains 61 PDF pages, including front matter and advertising. ISBN: 978-1-934674-01-7. The filename’s shared author field should not be read as evidence of coauthorship.
Quick study guide
| Concept | Working definition | Watch for |
|---|---|---|
| Opening gap | Session opening price minus the previous chosen session close | A futures settlement or full electronic-session close is a different reference. See lesson 2. |
| Fade / go with / fade the fill | Oppose the opening gap / follow it / wait for its retracement then consider the original direction | These are separate events and entry protocols. See lesson 5. |
| Gap zone | Opening location relative to prior OHLC, conditioned on prior open-to-close direction | Use known prior values, define boundary equality, and retain dojis. See lesson 3. |
| Fill rate / win rate | Prior close reached / a trade meets its stated profitable-outcome definition | The book sometimes counts profitable end-of-day exits as wins without a full fill. |
| Expectancy | p × average win − (1 − p) × average loss − per-trade cost | Use common units and include the entire candidate population. |
| Profit factor | Sum of positive trade P/L divided by the absolute sum of negative trade P/L | An average of yearly ratios is not the pooled ratio. |
| Sizing | Floor of planned risk budget divided by assumed stop-risk plus cost per unit | Margin and notional exposure are not the same as a loss budget. See lesson 4. |
| Research discipline | Lock definitions before evaluating later data | Thirty observations is not a guarantee of adequate evidence. See lesson 7. |
Seven-session reading map
These are study sessions, not a seven-day earnings plan. Shorten or split them as needed. The substantive chapters, glossary, and bibliography all have a place; publisher advertising is not a lesson assignment.
| Session / printed pages | Learning goal | Produce |
|---|---|---|
| 1 · Introduction, pp. 1–3 | Separate personal fit from evidence of an edge | Process constraints and practice 1 |
| 2 · What Are Gaps?, pp. 4–12 | Define sessions, outcomes, and the high-win-rate paradox | Outcome ledger and practice 2 |
| 3 · Creating a Profitable Strategy, pp. 13–16 | Measure size, zone, and calendar effects without hindsight | Classification rules and practice 3 |
| 4 · Same chapter, pp. 16–19 | Connect risk distance, payoff, costs, and expectancy | Risk calculation and practice 4 |
| 5 · Real World Examples, pp. 20–38 | Separate the author’s observations, decisions, and later explanations | Case audit and practice 5 |
| 6 · Gap Trading Tips, pp. 39–40 | Translate selected advice into falsifiable rules | Decision checklist and practice 6 |
| 7 · Get Started!, pp. 41–45; glossary pp. 46–48; bibliography pp. 49–50 | Build a reproducible plan and evaluate supporting sources | Practice 7, worksheets, and capstone |
1. Fit the process to the trader
Read: pp. 1–3. Goal: distinguish a process you can execute from a process shown to have an edge.
Andrews describes moving away from a discretionary approach that did not suit his temperament. His preference for structure, short holding periods, and a narrow market focus explains why he studied opening gaps. It does not independently establish that opening gaps will suit every trader.
Write two separate questions: “Can I follow this procedure reliably?” and “Does the procedure produce attractive outcomes after costs?” Strong execution cannot rescue a weak method, and a plausible method can still fail through inconsistent execution.
Original example: two reasons for the same loss
Fictional audit of a planned short. The rule required a six-point stop and an end-of-session exit if neither stop nor target occurred.
| Step | Original calculation or observation | Meaning |
|---|---|---|
| Plan followed | The market moves six points against the assumed entry and the planned stop is triggered | A losing observation can be consistent with the method. |
| Execution deviates | The trader cancels the stop and later exits twelve points worse | The deviation changes the result; record it separately. |
| Research question | Retain both the rule-based hypothetical result and the actual documented result | Do not change the rule retroactively to explain the loss. |
Keep this distinction: A loss is not automatically proof of either bad execution or a bad method.
Practice 1
- Name one process preference Andrews describes.
- Why does a preferred lifestyle not establish positive expectancy?
- What should an execution-deviation log contain?
- What would you decide before studying the opening gap?
Check your answers — practice 1
- Examples include structured rules, a narrow market focus, preparation before the open, and avoiding long holding periods. These describe his preferences.
- Personal fit concerns execution and attention; expectancy concerns the distribution of costs and outcomes. They require different evidence.
- The intended rule, information and timestamp, actual action, reason for deviation, and both outcomes where independently reconstructable.
- A study instrument, session definition, available observation time, and whether the data can support the intended measurements.
2. Separate gap fills from trade wins
Read: pp. 4–12. Goal: define the event being counted before interpreting a percentage.
The book measures its opening gap from the prior regular-session close, rather than requiring an opening price beyond the entire prior range. Its historical S&P futures convention uses a 09:30 ET open and a 16:15 ET prior close. That convention must travel with any attempt to reproduce the study.
Our indicator defaults to a deliberately chosen 09:30–16:00 New York window and offers a 16:15 alternative. This is an adjustable observation convention, not a declaration of current exchange trading hours. A custom-session final trade, a futures settlement, and a data vendor’s daily close need not be identical. Compare data definitions before comparing percentages.
Original example: different closing references create different gaps
Fictional index prices. No market data or fills are claimed.
| Step | Original calculation or observation | Meaning |
|---|---|---|
| Chosen 16:00 close | 5,000.00 | Reference A |
| Chosen 16:15 close | 5,004.00 | Reference B |
| Next 09:30 open | 5,010.00 | Gap A = +10.00; gap B = +6.00. |
| Morning low | 5,002.00 | Reference B is reached; reference A is not yet reached. |
Keep this distinction: A “filled gap” depends on which prior close was specified.
Breakaway, common, continuation, and exhaustion are the reading’s four descriptive patterns. Some definitions rely on what subsequently happens. For an opening-time study, record observable prior trend, opening location, and available volume; keep the later pattern label in a separate outcome column.
Figure 6 reports a 72.6% average win figure for a no-stop hypothetical fade study covering 2,167 gaps from January 1998 through April 2008. A win includes hitting the gap-fill target or finishing the day profitably.
That statistic is not interchangeable with a pure full-fill rate or the win rate of a stopped trading method. Figure 7’s average yearly profit factor of 1.08 also is not automatically a pooled, after-cost profit factor.
Original example: 75% winners can still lose
Fictional 100-trade sample, measured in points per equal-sized unit before and after a fixed hypothetical 0.25-point round-trip cost.
| Step | Original calculation or observation | Meaning |
|---|---|---|
| Winners | 75 × 2 = 150 points | Average winner: 2 points. |
| Losers | 25 × 7 = 175 points | Average loss: 7 points. |
| Gross expectancy | 0.75 × 2 − 0.25 × 7 = −0.25 points | Win rate alone conceals the loss. |
| Gross profit factor | 150 / 175 ≈ 0.857 | Below 1 despite frequent winners. |
| Net expectancy | −0.25 − 0.25 = −0.50 points | Costs worsen a weak gross result. |
Keep this distinction: Always ask what wins pay and what losses cost.
Practice 2
- Which fictional reference was reached by the 5,002 low?
- Does Figure 6 establish a 72.6% full-gap-fill rate?
- Calculate the gross P/L of the fictional 100-trade sample.
- Can full daily high/low data establish whether a stop or target occurred first?
Check your answers — practice 2
- The 5,004 reference was crossed; the 5,000 reference was not reached by that low.
- No. Its stated win definition also includes profitable end-of-day exits. It is historical, hypothetical, and no-stop.
- 150 − 175 = −25 points, before 25 points of assumed aggregate costs.
- No. When both thresholds lie within a daily range, intraday sequencing is needed; otherwise record ambiguity.
3. Classify location before studying outcomes
Read: pp. 13–16. Goal: construct reproducible gap groups using information available at the open.
Gap size tells you the distance to the reference close. Zone adds the prior day’s shape and the new opening location. The same point gap can open outside yesterday’s high, inside an upper wick, or within the body; these are different contexts worth comparing.
The book’s zone results are historical summaries, not probabilities assigned to today. Its detailed Otis subzones, parameters, and selection rules are not fully disclosed. Our broad classification below is a study framework, not an attempted reconstruction of those proprietary signals.
| Known feature | Our classification rule | Boundary treatment |
|---|---|---|
| Prior direction | Close > open: up; close < open: down; equality: doji | Retain dojis rather than force them into up/down groups. |
| Outside prior range | New open above prior high or below prior low | Strict comparisons. |
| Wick area | Above both prior open/close but below high, or below both but above low | Check exact-level cases before wick/body cases. |
| Body area | Between prior open and close | Exact equality with any prior OHLC is its own boundary group. |
| Gap magnitude | Absolute(open − prior close); optionally divide by prior close or an independently frozen volatility scale | State units and denominator; no unseen final-day volatility. |
Original example: classify before revealing the session
Fictional prior OHLC: open 5,020; high 5,040; low 4,990; close 5,000. The next open is 5,010.
| Step | Original calculation or observation | Meaning |
|---|---|---|
| Prior direction | 5,000 < 5,020 | Prior down session. |
| Signed gap | 5,010 − 5,000 = +10 points | A fade would be short; this is not an instruction to enter. |
| Opening location | Between prior close and prior open | Inside the prior body. |
| Normalized size | 10 / 5,000 = 0.20% | Record the percentage alongside raw points. |
Keep this distinction: Location is available at the open; the eventual narrative is not.
Seasonality adds a calendar grouping, not a causal explanation. The book compares weekdays and months and warns against over-optimization. Splitting a sample by zone, direction, weekday, month, and size can quickly leave tiny groups. A calendar pattern may also reflect changing volatility or event composition.
Practice 3
- Classify a new open of 5,045 using the example’s prior values.
- How should an open exactly at 5,040 be classified in our protocol?
- Why is a ten-point threshold not comparable across all index levels?
- Why can adding more filters create more apparent edges?
Check your answers — practice 3
- Above the prior high after a prior down session. The signed gap is +45 points.
- Exact prior level. Our boundary rule prevents overlapping or inconsistent categories.
- Ten points is a different percentage and volatility-scaled distance when the price level or market regime changes.
- Many small subdivisions create more opportunities for random patterns and unstable estimates. Lock comparisons and evaluate later data.
4. Balance stops, targets, and costs
Read: pp. 16–19. Goal: calculate payoff and planned risk without confusing them with guaranteed execution.
A wider stop often increases the chance of surviving until a target, but also enlarges a full loss. A nearer target often raises the hit rate while shrinking the average gain. Andrews’ historical tables demonstrate the need to study the combination rather than maximize one percentage.
For a simple two-outcome model before costs, the break-even win rate is L / (W + L), where W and L are positive average win and loss amounts. With a fixed cost c paid on every trade, it becomes (L + c) / (W + L). Real samples with partial exits and end-of-day closes need their full observed distribution.
Original example: slippage changes a fixed-level trade
Fictional gap up: prior close 5,000; opening observation 5,010. A proposed short uses a fixed stop at 5,015 and fixed target at 5,000. The actual short fill is assumed to be 5,009.
| Step | Original calculation or observation | Meaning |
|---|---|---|
| At the opening observation | 10-point reward / 5-point distance = 2.00R | Only an initial quote-based illustration. |
| From assumed short fill | Reward = 5,009 − 5,000 = 9 points | The target is unchanged. |
| Risk from assumed fill | 5,015 − 5,009 = 6 points | Actual planned ratio is 9 / 6 = 1.50R. |
| Break-even, no costs | 6 / (9 + 6) = 40% | Applies only to the stated binary payoff model. |
| With 0.50-point cost | (6 + 0.50) / 15 ≈ 43.33% | Cost is a labeled assumption, not a measured ES average. |
Keep this distinction: Calculate reward/risk from the actual or explicitly assumed fill.
For ES dollar arithmetic, CME identifies a $50 multiplier per index point; Micro E-mini S&P 500 uses $5 per point. See CME’s contract comparison. These multipliers do not make a historical point stop suitable for current conditions.
Original example: risk budget is different from margin
Fictional account $25,000; planned risk budget 0.5% = $125; six-point stop distance; assumed total cost allowance $5 per ES contract.
| Step | Original calculation or observation | Meaning |
|---|---|---|
| One ES planned amount | 6 × $50 + $5 = $305 | Exceeds the $125 planned budget. |
| ES quantity | floor($125 / $305) = 0 | The calculation says zero contracts. |
| Illustrative MES allowance | $1 assumed per micro contract; 6 × $5 + $1 = $31 | Different cost assumption, explicitly stated. |
| MES quantity | floor($125 / $31) = 4 | Planned amount $124; gaps and execution can exceed it. |
Keep this distinction: Smaller margin requirements do not justify a larger loss budget.
Andrews describes one contract per $10,000 of equity and zone-specific stops. His historical examples include a six-point loss.
At $50 per point, six points is $300 per ES contract: 3% of $10,000 before costs. The fixed equity ratio alone cannot guarantee a small or fixed percentage loss.
The glossary’s profit-factor wording can be confusing. For this workbook, define it as total positive trade P/L divided by the absolute total negative trade P/L under a stated cost convention. Do not put overall net profit in the numerator. Review losing streaks and drawdown alongside the ratio.
Practice 4
- What is the fill-based reward/risk ratio in the short example?
- What is its binary break-even win rate with the assumed cost?
- How many ES contracts fit the $125 planned budget?
- Why should a historical seven-point stop not be adopted solely because a table favored it?
Check your answers — practice 4
- 9 / 6 = 1.50R before costs, using the fixed target and stop.
- 6.5 / 15 = 43.33%. That formula assumes only the specified win/loss outcomes and uniform cost.
- Zero. One contract’s $305 planned amount already exceeds the budget.
- The old dataset, volatility, price level, filters, costs, and execution model may differ. A historical optimum is not a current recommendation.
5. Audit the real-world examples
Read: pp. 20–38. Goal: extract decision principles without copying selected trades or filling in undisclosed rules.
The case chapter includes winning fades, a loss despite a completed fill, a stopped fade, an avoided zone, a continuation trade, and a reversal after the fill. Study the actual charts in the book. For each, make three columns: information known before entry, decisions made during the session, and explanations written afterward.
Andrews describes a 09:25 decision snapshot and market entry at 09:30. The opening price can differ from that snapshot, and a market order’s execution can differ from the opening chart print. Neither the selected case narratives nor our indicator establish that every opening print was executable.
| Book case group | Printed pages | Original study task |
|---|---|---|
| Method and Otis overview | 20–22 | List disclosed rules separately from unavailable subzone parameters. |
| Fades and partial exits, Figures 15–18 | 22–28 | Identify which decisions were fixed in advance and which changed after entry; compute weighted returns rather than adding legs. |
| Filled gap but losing extended-target trade, Figure 19 | 28–29 | Explain why reaching the prior close need not mean the chosen trade made money. |
| Other fade decisions, Figures 20–22 | 29–34 | Separate valid-signal losses, reduced sizing, and later continuation decisions. |
| Avoided below-low/prior-up-day case, Figure 23 | 34–35 | Treat the BLUD label as known location; test rather than inherit its historical ranking. |
| Go-with case, Figure 24 | 35–37 | Distinguish trading with the gap from fading it; record that a complete entry algorithm is not supplied. |
| Fade-the-fill case, Figure 25 | 37–38 | Treat the later reversal as a new setup with its own entry and risk plan. |
Original example: a filled gap can still lose
Fictional long fade: open and assumed fill 4,980, prior close 5,000, extended target 5,010, eventual end-of-session exit 4,975.
| Step | Original calculation or observation | Meaning |
|---|---|---|
| Mid-session high | 5,002 | The gap-fill reference was crossed. |
| Extended target | 5,010 not reached | A full-gap event does not satisfy this exit plan. |
| Exit outcome | 4,975 − 4,980 = −5 points | The hypothetical trade loses before costs. |
| Alternative full-fill exit | A separate protocol targeting 5,000 | Do not replace the original exit after seeing the result. |
Keep this distinction: Keep the gap event and the trade outcome in separate columns.
Original example: weight the scale-out correctly
Fictional short: 50% exits at +4 points, 30% at +7, and 20% at −3. All legs refer to the same initial position.
| Step | Original calculation or observation | Meaning |
|---|---|---|
| Weighted result | 0.50 × 4 + 0.30 × 7 − 0.20 × 3 = 3.50 points | Per initial contract-equivalent, before costs. |
| Naive addition | 4 + 7 − 3 = 8 points | Incorrect because it ignores the different position fractions. |
| Execution requirement | Actual leg quantities, prices, and costs | Small positions may not support the stated fractions. |
Keep this distinction: Scale-out averages use the original position weights.
The book sometimes explains reversals through trapped traders or short covering. Those are hypotheses about participants, not facts established by the OHLC chart alone. Likewise, the go-with example refers to shorting “up” gaps in its seasonality discussion despite describing a down-gap trade. Flag the mismatch; do not silently convert it into a verified direction-specific statistic.
Practice 5
- Why is Figure 19 especially useful to this workbook?
- Calculate the original scale-out result.
- After a failed fade, is an opposite-direction entry automatically justified?
- What would be needed to recreate Otis faithfully?
Check your answers — practice 5
- It separates a reached gap-fill level from the outcome of a trade seeking an extended target.
- 3.50 points per original position unit before costs; the leg fractions sum to one.
- No. It is a new setup requiring an independently defined entry, risk, and exit rule.
- Complete subzone boundaries, filters, stop/target choices, data/session definitions, timing rules, and a full validation dataset; the supplied book does not disclose them all.
6. Turn trading tips into decision rules
Read: pp. 39–40. Goal: retain useful process advice while testing broad claims.
The tips combine useful reminders about selectivity, position size, and payoff with strong empirical claims about the open and news. Convert each actionable claim into a recorded comparison rather than treating a memorable phrase as a universal rule.
| Source theme | Original operational response | What remains uncertain |
|---|---|---|
| Know the location | Write prior OHLC, direction, and opening band before revealing subsequent bars | Whether a specific band predicts a better net outcome today. |
| Be selective | Predeclare eligible bands, minimum size, and data-quality rejection rules | Whether fewer opportunities improve results per candidate. |
| News is noise | Log scheduled releases and unexpected events; compare predeclared event versus non-event groups | The author’s choice to ignore news does not prove execution risk or outcomes are unaffected. |
| Enter at the open | Compare a clearly defined opening-order protocol with a fixed-delay protocol on the same candidates | Delayed entries do not literally catch every loser or miss every winner. |
| Use extended targets | Define the extension distance and invalidation rules before entry | A farther target can reduce hit rate and expose unrealized gains. |
| Trade manageable size | Specify a planned loss budget, drawdown response, and pause criteria | Psychological comfort does not guarantee adequate risk control. |
“No trade” is a valid outcome. A plan can reject a day because the reference session is incomplete or the setup definition is unresolved. Distinguish that from skipping an eligible signal because of discomfort, so the journal can reveal whether the method or its execution changed.
Practice 6
- How would you evaluate the source’s news claim?
- What must be kept constant when comparing entry timing?
- Why count eligible days with no entry?
- Does moving a target farther away after a near-stop automatically improve expectancy?
Check your answers — practice 6
- Record event categories and timestamps using a predefined rule, hold the remaining protocol constant, and compare outcomes and execution sensitivity on later data.
- The candidate set, instrument, date interval, stop/target framework, session definition, and cost assumptions; only the delay should change.
- They reveal opportunity coverage and selection effects. A high per-trade score can conceal many missed candidates.
- No. That is a changed decision rule; it requires evidence and may sacrifice attainable exits. The near-stop narrative alone is not a causal test.
7. Build a research and practice plan
Read: pp. 41–50. Goal: finish with a research protocol another person could audit.
Andrews recommends selecting a market, organizing historical observations, writing a plan, practicing forward, and only then considering implementation. His caution about overfitting is central: repeatedly tuning zones, stops, and targets can make chance patterns look convincing.
The suggestion to seek at least 30 observations is a starting preference, not a statistical sufficiency test. Four wins out of five is 80%, but changing one outcome changes it by 20 percentage points. Even a larger sample may not represent new volatility conditions or rare losses.
Original example: development results need an untouched check
Fictional research design, not reported performance.
| Step | Original calculation or observation | Meaning |
|---|---|---|
| Development segment | 120 sessions used to choose a three-band classification | Document every attempted variant. |
| Evaluation segment | Next 60 sessions reserved before any outcomes are viewed | Freeze definitions, costs, and data exclusions. |
| Repeated tuning | After a weak evaluation, alter the stop using those same 60 sessions | Those sessions have now become development data. |
| Next step | Use new untouched data or report the revised result as exploratory | Do not call a retuned result independent confirmation. |
Keep this distinction: A test set stops being untouched once it influences the rule.
Use the glossary to reconcile definitions, especially win rate, profit factor, and session close. Use the bibliography as a list of leads: locate a source lawfully, verify its date and method, and compare its gap definition before combining findings. A citation in a 2008 bibliography is not independent confirmation of today’s profitability.
Practice 7
- Is 30 observations a guarantee of a reliable edge?
- What belongs in a forward-practice log?
- What happens to evaluation data after they are used to retune a rule?
- Should a losing streak automatically trigger a size increase to recover?
Check your answers — practice 7
- No. Uncertainty depends on outcome variation, dependence between observations, selection, rare events, and the question being estimated.
- Every eligible session, decision timestamp, reference values, intended action, observed action, costs or assumptions, omissions, and rule version.
- They become development data. Report that honestly and seek a fresh evaluation segment.
- No. Follow predeclared loss-budget and pause rules; recovery goals do not establish a justified position size.
Pine Script session map
Research question: where does the new session open relative to the prior session, and when does a completed bar first show a reach of the prior close?
This complete original Pine Script v6 uses indicator() only. It is a descriptive observation tool, not a recreation of Otis and not a broker simulator. Our labels use broad OHLC regions with explicit equality treatment; they contain no inherited historical win probabilities.
What This Indicator Shows
- Session definition. Standard 5-minute bars, 09:30 New York open, selectable 16:00 or 16:15 cutoff. Default 16:00 is our study convention; 16:15 is the book-comparison alternative.
- Prior reference. OHLC accumulated from consecutive completed bars in that custom window. A prior session missing any required bar or its endpoint is not accepted.
- Opening observation. After the 09:30 bar completes at 09:35, record the opening price and prior-close difference. Default qualification is an absolute gap strictly greater than one price unit, adjustable for the chosen market.
- Context label. Prior up/down/doji plus opening location outside the range, within a wick, within the body, or exactly on a prior OHLC level. No rule says that any label should be traded.
- First reach marker. The first completed bar with low at or below the prior close for a gap up, or high at or above it for a gap down. The opening bar is included; recognition still waits for its close.
- Frozen state. Prior levels and opening price remain fixed for that observation session. Only one first-reach marker occurs. The next observed session resets the state; older gaps are not tracked for later-day fills.
The script builds its custom session directly from chart bars and makes no higher-timeframe requests. Developing bars cannot create confirmed labels or alerts. On an extended-hours chart, references are hidden outside the chosen window. On a regular-hours-only chart, line segments may visually connect across the overnight interval because no intervening bars exist; do not read that connector as overnight price activity.
Use the same session and feed across the sample. TradingView’s session documentation (paid link) explains that custom sessions and exchange-defined sessions are distinct. Our New York timezone handles daylight saving, but the script does not recognize holidays, early closes, contract rolls, or a completely absent day in the dataset.
What This Indicator Does Not Show
There are no entries, stop orders, target orders, fills, returns, win rates, drawdowns, or profitability results. A bar crossing a reference is an observed threshold event, not proof that an order would have executed there. The script does not reproduce 09:25 decisions, seasonality filters, multi-day zones, private subzone parameters, or the go-with and fade-the-fill entry methods.
A partial prior observed session invalidates the next reference, so an early-close session is not silently treated as a full session. A completely absent session cannot be detected from the remaining bars; the next visible day may use the last complete observed session. Missing current bars can hide or delay a first-reach observation. Historical feed corrections or changed settings can alter earlier labels. Continuous futures adjustments and rolls require a separate data audit.
For the first loaded session, the script must collect a complete reference before it can label a later session. On ordinary 16:00 sessions that requires all 78 five-minute bars; the 16:15 alternative requires 81. A prior-close reach on the opening bar can display alongside the new-gap marker at 09:35. This does not authorize an earlier entry or establish the event’s intrabar time.
Validation status: This script has not been compiled in TradingView or run against historical data here. Static review checks the intended session state, completed-bar timing, missing-bar handling, and indicator-only structure. No chart behavior or performance result is claimed as verified.
View Pine Script Indicator Code
//@version=6
indicator("CC Understanding Gaps - Session Map", overlay=true, max_labels_count=500)
// Original descriptive session study; no orders, fills, or performance calculations.
string closeChoice = input.string("16:00", "Session cutoff (New York)", options=["16:00", "16:15"])
float minGap = input.float(1.0, "Observe gaps strictly larger than (price units)", minval=0.0, step=0.25)
bool showLabels = input.bool(true, "Label qualifying opens")
string tz = "America/New_York"
if not chart.is_standard or not (timeframe.isminutes and timeframe.multiplier == 5)
runtime.error("Use standard 5-minute bars. Audit the instrument and session cutoff manually.")
int yy = year(time, tz)
int mo = month(time, tz)
int dd = dayofmonth(time, tz)
int key = yy * 10000 + mo * 100 + dd
int start = timestamp(tz, yy, mo, dd, 9, 30)
int finish = timestamp(tz, yy, mo, dd, 16, closeChoice == "16:15" ? 15 : 0)
bool inside = time >= start and time_close <= finish
var int activeDay = na
var int nextTime = na
var bool collecting = false
var bool priorValid = false
var float so = na
var float sh = na
var float sl = na
var float sc = na
var float po = na
var float ph = na
var float pl = na
var float pc = na
var float refOpen = na
var float refHigh = na
var float refLow = na
var float refClose = na
var float todayOpen = na
var float signedGap = na
var bool eligible = false
var bool observed = false
bool newGap = false
bool firstTouch = false
string zoneText = ""
if barstate.isconfirmed and inside
if na(activeDay) or activeDay != key
activeDay := key
collecting := time == start
nextTime := start
refOpen := na
refHigh := na
refLow := na
refClose := na
todayOpen := na
signedGap := na
eligible := false
observed := false
if collecting and priorValid
refOpen := po
refHigh := ph
refLow := pl
refClose := pc
todayOpen := open
signedGap := open - pc
eligible := math.abs(signedGap) > minGap
newGap := eligible
bool boundary = open == po or open == ph or open == pl or open == pc
zoneText := boundary ? "Exact prior level" : open > ph ? "Above prior high" : open < pl ? "Below prior low" : open > math.max(po, pc) ? "Upper wick area" : open < math.min(po, pc) ? "Lower wick area" : "Prior body area"
string direction = pc > po ? "Prior up" : pc < po ? "Prior down" : "Prior doji"
if eligible and showLabels
label.new(bar_index, high, direction + " | " + zoneText + "\nGap " + str.tostring(signedGap, format.mintick), style=label.style_label_down, color=color.teal, textcolor=color.white, size=size.tiny)
// A partial current session must never leave an older reference valid.
priorValid := false
so := open
sh := high
sl := low
sc := close
if collecting
if time != nextTime
collecting := false
else
sh := math.max(sh, high)
sl := math.min(sl, low)
sc := close
nextTime := time_close
if time_close == finish
po := so
ph := sh
pl := sl
pc := sc
priorValid := true
// The opening bar is included, but recognition waits for its completion.
bool touches = eligible and not observed and (signedGap > 0 ? low <= refClose : high >= refClose)
if touches
observed := true
firstTouch := true
bool show = inside and activeDay == key
plot(show ? refOpen : na, "Prior custom-session open", color=color.new(color.gray, 50), style=plot.style_linebr)
plot(show ? refHigh : na, "Prior custom-session high", color=color.new(color.green, 30), style=plot.style_linebr)
plot(show ? refLow : na, "Prior custom-session low", color=color.new(color.red, 30), style=plot.style_linebr)
plot(show ? refClose : na, "Gap-fill reference - prior custom-session close", color=color.orange, linewidth=2, style=plot.style_linebr)
plot(show ? todayOpen : na, "Current session open", color=color.blue, style=plot.style_linebr)
plot(show ? signedGap : na, "Signed gap in price units", display=display.data_window)
plotshape(newGap, title="Qualifying open recognized at bar close", style=shape.diamond, location=location.abovebar, color=color.teal, size=size.tiny)
plotshape(firstTouch, title="First observed reach of prior close", style=shape.circle, location=location.belowbar, color=color.orange, size=size.tiny)
alertcondition(newGap, "New session gap observation", "Confirmed opening-bar gap observation. Descriptive only; not an entry or fill.")
alertcondition(firstTouch, "First prior-close reach", "A completed bar has reached or crossed the prior custom-session close. Not a verified execution.")
Replay checklist
- Compile in TradingView before using the indicator and resolve any reported errors.
- Load at least two complete sessions and compare the accumulated OHLC with independently checked intraday bars using the same cutoff.
- Advance through 09:35 and verify the frozen opening value, prior direction, and boundary classification.
- Find examples of an opening-bar reach, a later reach, no reach, exact one-unit gaps, and exact prior-level openings.
- Test missing opening bars, a missing middle bar, an absent final bar, and an early close; document which later references are suppressed.
- Reload and compare confirmed markers. Configure named alerts for once-per-bar-close delivery; treat them as observations.
Three controlled experiments
These are our proposed studies, not results supplied by the book. Keep a candidate-level ledger and preserve no-event sessions.
| Question and hypothesis | Change | Hold constant / measure | What results could mean |
|---|---|---|---|
| Does cutoff choice change the event population? Hypothesis: 16:00 and 16:15 references produce different gap sizes and reach counts. | Session cutoff only | Same instrument, raw contract series, dates, five-minute feed, and absolute gap threshold. Record gap size, opening band, qualifying count, first-reach time, and no-reach count. | Differences demonstrate definition sensitivity, not which cutoff is intrinsically better. |
| Does location add information beyond gap size? Hypothesis: some broad opening bands retain different reach frequencies after size matching. | Broad zone classification versus size-only grouping | Same cutoff, dates, direction, gap-size bins, and event deadline. Record per-bin counts and reach rates; preserve boundary/doji groups. Evaluate on later locked data. | A persistent difference may justify deeper study; small cells and regime imbalance can explain apparent effects. |
| Does target extension compensate for lower hit frequency? Hypothesis: extension trades off hit rate against payoff. | Target 0.75 / 1.00 / 1.25 of gap distance from a predefined entry reference | Same eligible candidates, explicit assumed execution, stop model, cutoff, costs, and ambiguity rule. Record target events separately from cost-aware manual P/L, adverse excursion, and coverage. | Higher hit rate can still have lower expectancy. This needs a separate execution study; the indicator supplies none of its returns. |
For return studies, predeclare order submission time, fill assumptions, stop/target activation, end-of-day handling, costs, and cases where both levels are crossed within one bar. Use finer data or mark those outcomes ambiguous; do not choose whichever sequence makes a variant look better. Do not reuse the same evaluation segment to search many thresholds.
Four reusable worksheets
Copy these into a journal. Distinguish observed values, unknowns, assumptions, and verified executions.
A. Session observation
| Field | Record |
|---|---|
| Identity | Instrument, contract, date, feed, timezone, adjustment/roll convention |
| Session | 09:30 start; chosen cutoff; complete bars? Early-close or missing-data flag |
| Prior values | Open, high, low, close; date of reference; prior direction |
| Opening values | Open; signed/absolute gap; percentage or frozen volatility normalization |
| Classification | Broad band; exact-boundary status; doji; rule version |
| Event | First reach bar and recognition time; no reach; missing data; no assumed execution |
B. Trade and risk plan
| Field | Record |
|---|---|
| Scope | Fictional, hypothetical historical, or verified live record; do not mix labels |
| Eligibility | Predeclared band, size threshold, calendar rule, and decision timestamp |
| Entry | Submission time, order type, assumed/verified fill, and reason for price difference |
| Risk | Stop distance, dollar multiplier, cost allowance, budget, integer quantity |
| Exits | Target, extensions, partial weights, time cutoff, activation times |
| Outcome | Per-leg quantities, prices, costs, ambiguity, gaps, realized P/L if actually supported |
C. Research design
| Field | Record |
|---|---|
| Question | Falsifiable hypothesis, baseline, one changed variable |
| Sample | Fixed instrument/date interval; all eligible sessions; excluded-data rules |
| Definitions | Cutoff, gap formula, zone boundaries, event versus trade outcome |
| Development | Variants attempted and selection rule; lock date |
| Evaluation | Untouched interval; counts, uncertainty, costs if P/L studied |
| Conclusion | What would refute the hypothesis? Missing evidence and next independent check |
D. Review and process audit
| Field | Record |
|---|---|
| Coverage | Eligible, taken, skipped, no-trigger, and unknown-data counts |
| Timing | Any final-day information used before available? Opening print treated as fill? |
| Execution | Deviations from plan, costs, bracket timing, and contract sizing |
| Evidence | Full-fill events separated from profitable exits; weighted partial outcomes |
| Risk response | Loss/drawdown threshold, pause rule, and documented action |
| Next revision | One justified change on development data; preserve evaluation history |
Capstone: build a 30-session gap audit
Select one instrument and 30 consecutive ordinary sessions before revealing outcomes. Thirty sessions is a manageable learning task, not proof of an edge or a minimum that guarantees reliability. Use more data for substantive inference.
- Complete the observation worksheet for all 30 sessions, retaining zero/small gaps and rejected-data days in the coverage log.
- Classify location before advancing the replay. Compare two cutoff definitions on the same data and explain any changes.
- Audit three book cases using known-before-entry / decisions / later-explanations columns. Include the filled-but-losing case and the stopped fade.
- Create two original fictional risk plans, one fade and one later setup, with positive stop distances, cost-aware quantities, and adverse-execution scenarios.
- Use one controlled experiment and distinguish descriptive reach counts from any separately modeled trade results.
- Write a short conclusion naming one supported observation, one alternative explanation, and the evidence still needed.
| Criterion | Points | Required evidence |
|---|---|---|
| Definitions | 0–2 | Correct session, gap, outcome, and boundary conventions |
| Source understanding | 0–2 | All chapter groups addressed; historical claims and missing private rules identified |
| Calculations | 0–2 | Correct expectancy, weighted exits, fill-based reward/risk, and cost-aware sizing |
| Data integrity | 0–2 | Consecutive population, missing data, no-lookahead timing, and no invented executions |
| Interpretation | 0–2 | No claim of proven profits; a locked future comparison and uncertainty stated |
Aim for at least 8/10 with no fabricated-fill or future-information errors. Revise any zero-scoring area before expanding the study. The rubric measures understanding and documentation, not readiness to trade.
Final Takeaway
Andrews’ strongest teaching point is that frequency of success, loss size, and exit distance must be evaluated together. Gap location provides a way to organize the question, while the book’s historical tables and selected cases provide hypotheses to investigate. The useful next step is a clean, timestamped study that keeps threshold events separate from executable trade outcomes.
Risk Disclosure: This material is for educational and research purposes only and is not financial or investment advice. Trading, including leveraged futures trading, can result in substantial losses. Historical research, hypothetical examples, and indicators do not establish future profitability or reproduce live execution. Commissions, spreads, slippage, liquidity, gaps, halts, contract rolls, order behavior, and market changes can materially affect results. Planned stop-risk is not a guarantee of maximum loss.
This is an independent educational companion and is not affiliated with, sponsored by, endorsed by, or authorized by Scott Andrews or the publisher.