OPEN-SOURCE SCRIPT
Liquidity Zone Harvester [JOAT]

Liquidity Zone Harvester [JOAT]
Introduction
Institutional order flow leaves footprints in market structure. When a large buyer or seller places a significant order, the execution of that order creates an imbalance between supply and demand at a specific price level — and markets frequently return to these levels to test whether the original interest remains. These price areas are commonly referred to as order blocks or liquidity zones, and they form one of the core concepts in institutional and Smart Money trading methodology.
The Liquidity Zone Harvester [JOAT] is an automated order block detection and management system that identifies these zones using statistically validated momentum signals rather than arbitrary manual placement. Instead of drawing boxes wherever a trader's eye thinks supply or demand may exist, this indicator uses Z-score cumulative impulse detection to identify when directional momentum has reached statistically significant levels — and only then marks the most recent opposing-close candle as the source order block. Volume quality gates ensure that only high-participation impulses create zones, filtering out low-conviction moves that are less likely to represent genuine institutional activity.
What sets this indicator apart from standard order block tools is what happens after zone creation. Every active zone is tracked through a dual-mechanism aging system. The Bayesian exponential decay model progressively reduces zone visual intensity over time with a configurable half-life, providing a continuous probability signal about zone freshness. Simultaneously, a Kaplan-Meier survival analysis engine — borrowed from medical statistics — estimates the probability that a given zone will survive future price tests, based on the historical survival rates of all previously observed zones in the training window. Each zone displays both its current age and its estimated survival probability directly on the chart, turning static boxes into dynamically updated probability estimates.

Core Concepts
1. Z-Score Cumulative Impulse Detection
Zone creation is triggered only when directional momentum reaches a statistically defined threshold. The system accumulates a running streak of directional closes — when consecutive bars close higher than their open, the bull accumulator grows; when consecutive bars close lower, the bear accumulator grows. The streak resets when direction reverses. This cumulative streak is then normalized against its own rolling mean and standard deviation, producing a Z-score that measures how unusual the current momentum streak is relative to recent history.
Pine Script®
When a bullEvent fires (bull Z-score crosses the threshold with volume confirmation), the system looks backward to find the most recent down-close candle — the last bar where sellers were dominant before the impulse began. This becomes the demand zone. Similarly, a bearEvent marks the most recent up-close candle as the supply zone.
2. Volume Quality Gate
Not all Z-score impulses are created equal. An impulse that occurs on abnormally low volume represents weak conviction — possibly a thin-market price drift rather than genuine institutional momentum. The volume gate applies RSI to the volume series to normalize it against its own history. Only when volume RSI exceeds the configurable threshold is the volOK condition true, enabling zone creation.
Pine Script®
This filter meaningfully reduces the number of zones created during low-participation conditions such as pre-market sessions, lunch hours, or holiday-period trading — precisely the times when order block levels are least likely to represent significant institutional interest.
3. Order Block Zone Construction
When a signal event is confirmed, the most recent opposing candle is identified using ta.valuewhen(). For a bullEvent, the system finds the most recent bar where close was less than open (a down candle) — its high and low define the demand zone boundaries. For a bearEvent, it finds the most recent up candle — its high and low define the supply zone boundaries. A box object is created spanning from that historical bar to the current bar, with height defined by the candle's actual high-low range.
Pine Script®
4. Overlap Prevention (f_no_overlap)
To avoid cluttering the chart with redundant zones that occupy the same price territory, an overlap check function evaluates whether a proposed new zone overlaps with any existing zone of the same type. The function iterates over all existing bull or bear boxes and compares the new zone's top and bottom against each existing box's top and bottom. A guard condition (nBull > 0) prevents the iteration from running on an empty array, which would cause an index -1 crash.
Pine Script®
5. Bayesian Exponential Decay
Each zone's visual transparency is driven by an exponential decay function that represents the diminishing probability of zone relevance over time. The half-life parameter (default: 75 bars) defines how quickly a zone fades. At age 0, the zone is fully opaque. At age 75 bars, the zone is at 50% opacity. At age 150 bars, 25% opacity. This continuous decay — rather than a binary active/expired switch — provides an analog probability signal directly encoded in the zone's visual intensity.
Pine Script®
6. Kaplan-Meier Survival Analysis
The Kaplan-Meier estimator is a nonparametric statistical method originally developed to measure survival probabilities in clinical trial data. In this indicator, "survival" is defined as a liquidity zone remaining unmitigated (not breached by a closing price on two separate occasions). Each time a zone is mitigated, it is recorded as a "death event" at its current age. Zones that expire by age limit without mitigation are recorded as "censored events" — incomplete observations. The KM formula multiplies survival probabilities across all observed events up to a given age.
Pine Script®
For each active zone, the indicator queries the KM estimate at the zone's current age and displays the result as a percentage label. A zone at age 40 showing "Age 40 | 72%" means that historically, 72% of zones survived to at least 40 bars without being mitigated — giving traders a quantitative assessment of how likely the zone is to hold on the next test.
Features
Input Parameters
Z-Score Settings:
Volume Gate Settings:
Zone Management Settings:
Decay Settings:
KM Settings:
Display Settings:
How to Use This Indicator
Step 1: Understand Zone Creation Conditions
Zones are not created on every bar — they are created only when a statistically significant directional impulse (Z-score above threshold) occurs on above-average volume. This selectivity is intentional. In any given trading session, you will likely see only a few zone creation events, each backed by a genuine momentum surge that suggests institutional participation. When you see a new zone appear, note the Z-score values in the dashboard and the volume RSI reading — higher values on both indicate a stronger impulse and more confident zone placement.
Step 2: Prioritize Fresh, High-Survival Zones
Not all zones on the chart are equally relevant. A fresh zone (low age, full opacity) at a KM survival rate of 80% is a far stronger candidate for price reaction than an old zone (high age, near-transparent) at 30% survival probability. Use both the visual opacity and the KM label together: as a zone ages and fades, reduce your expectation that it will provide meaningful support or resistance. When price approaches a zone that is both visually fresh and shows high KM survival probability, the statistical expectation of reaction is at its highest.
Step 3: Watch for Zone Rejection Alerts
The zone rejection alert fires when price tests a zone (enters the box boundary) and then closes back away from it without mitigating it. This is the core trade setup: price returning to the institutional order block level, briefly penetrating it, and then reversing. The rejection alert provides a timely notification for potential entries in the direction of the original impulse that created the zone, with the zone's near boundary serving as the natural stop-loss reference.
Step 4: Monitor KM Training Size for Statistical Validity
The dashboard displays the KM training sample size — the number of completed zone events (both mitigated and aged-out) available for the survival analysis. With fewer than 10 training events, the KM estimate has high variance and should be treated as rough guidance. With 30 or more training events, the estimate becomes statistically stable. On instruments or timeframes where the indicator has run for extended periods, the KM estimates become increasingly reliable as the training dataset grows.

Indicator Limitations
Originality Statement
The Liquidity Zone Harvester is a genuinely original indicator that applies statistical and mathematical frameworks from outside the trading domain to a problem common in technical analysis.
Disclaimer
The Liquidity Zone Harvester [JOAT] is provided for educational and informational purposes only. It is a technical analysis tool and does not constitute financial advice. Liquidity zones and order blocks are analytical constructs; they do not guarantee price reactions. Past zone behavior as encoded in Kaplan-Meier estimates does not predict future zone performance. All trading involves risk of loss. Users are solely responsible for their own trading decisions. Please consider your individual risk tolerance and consult a licensed financial professional before engaging in any trading activity.
-Made with passion by officialjackofalltrades
Introduction
Institutional order flow leaves footprints in market structure. When a large buyer or seller places a significant order, the execution of that order creates an imbalance between supply and demand at a specific price level — and markets frequently return to these levels to test whether the original interest remains. These price areas are commonly referred to as order blocks or liquidity zones, and they form one of the core concepts in institutional and Smart Money trading methodology.
The Liquidity Zone Harvester [JOAT] is an automated order block detection and management system that identifies these zones using statistically validated momentum signals rather than arbitrary manual placement. Instead of drawing boxes wherever a trader's eye thinks supply or demand may exist, this indicator uses Z-score cumulative impulse detection to identify when directional momentum has reached statistically significant levels — and only then marks the most recent opposing-close candle as the source order block. Volume quality gates ensure that only high-participation impulses create zones, filtering out low-conviction moves that are less likely to represent genuine institutional activity.
What sets this indicator apart from standard order block tools is what happens after zone creation. Every active zone is tracked through a dual-mechanism aging system. The Bayesian exponential decay model progressively reduces zone visual intensity over time with a configurable half-life, providing a continuous probability signal about zone freshness. Simultaneously, a Kaplan-Meier survival analysis engine — borrowed from medical statistics — estimates the probability that a given zone will survive future price tests, based on the historical survival rates of all previously observed zones in the training window. Each zone displays both its current age and its estimated survival probability directly on the chart, turning static boxes into dynamically updated probability estimates.
Core Concepts
1. Z-Score Cumulative Impulse Detection
Zone creation is triggered only when directional momentum reaches a statistically defined threshold. The system accumulates a running streak of directional closes — when consecutive bars close higher than their open, the bull accumulator grows; when consecutive bars close lower, the bear accumulator grows. The streak resets when direction reverses. This cumulative streak is then normalized against its own rolling mean and standard deviation, producing a Z-score that measures how unusual the current momentum streak is relative to recent history.
cumBull := close > open ? nz(cumBull[1]) + (close - open) : 0
cumBear := close < open ? nz(cumBear[1]) + (open - close) : 0
zBull = (cumBull - ta.sma(cumBull, zLen)) / ta.stdev(cumBull, zLen)
zBear = (cumBear - ta.sma(cumBear, zLen)) / ta.stdev(cumBear, zLen)
bullEvent = ta.crossover(zBull, zThresh) and barstate.isconfirmed and volOK
bearEvent = ta.crossover(zBear, zThresh) and barstate.isconfirmed and volOK
When a bullEvent fires (bull Z-score crosses the threshold with volume confirmation), the system looks backward to find the most recent down-close candle — the last bar where sellers were dominant before the impulse began. This becomes the demand zone. Similarly, a bearEvent marks the most recent up-close candle as the supply zone.
2. Volume Quality Gate
Not all Z-score impulses are created equal. An impulse that occurs on abnormally low volume represents weak conviction — possibly a thin-market price drift rather than genuine institutional momentum. The volume gate applies RSI to the volume series to normalize it against its own history. Only when volume RSI exceeds the configurable threshold is the volOK condition true, enabling zone creation.
volRsi = ta.rsi(volume, 14)
volOK = volRsi > volThresh
This filter meaningfully reduces the number of zones created during low-participation conditions such as pre-market sessions, lunch hours, or holiday-period trading — precisely the times when order block levels are least likely to represent significant institutional interest.
3. Order Block Zone Construction
When a signal event is confirmed, the most recent opposing candle is identified using ta.valuewhen(). For a bullEvent, the system finds the most recent bar where close was less than open (a down candle) — its high and low define the demand zone boundaries. For a bearEvent, it finds the most recent up candle — its high and low define the supply zone boundaries. A box object is created spanning from that historical bar to the current bar, with height defined by the candle's actual high-low range.
lastDnHigh = ta.valuewhen(close < open, high, 0)
lastDnLow = ta.valuewhen(close < open, low, 0)
lastDnBar = ta.valuewhen(close < open, bar_index, 0)
if bullEvent
newBox = box.new(lastDnBar, lastDnHigh, bar_index, lastDnLow, ...)
bullBoxes.push(newBox)
4. Overlap Prevention (f_no_overlap)
To avoid cluttering the chart with redundant zones that occupy the same price territory, an overlap check function evaluates whether a proposed new zone overlaps with any existing zone of the same type. The function iterates over all existing bull or bear boxes and compares the new zone's top and bottom against each existing box's top and bottom. A guard condition (nBull > 0) prevents the iteration from running on an empty array, which would cause an index -1 crash.
f_no_overlap(newTop, newBot, boxes) =>
noOverlap = true
if boxes.size() > 0
for i = 0 to boxes.size() - 1
b = boxes.get(i)
if newTop >= box.get_bottom(b) and newBot <= box.get_top(b)
noOverlap := false
noOverlap
5. Bayesian Exponential Decay
Each zone's visual transparency is driven by an exponential decay function that represents the diminishing probability of zone relevance over time. The half-life parameter (default: 75 bars) defines how quickly a zone fades. At age 0, the zone is fully opaque. At age 75 bars, the zone is at 50% opacity. At age 150 bars, 25% opacity. This continuous decay — rather than a binary active/expired switch — provides an analog probability signal directly encoded in the zone's visual intensity.
decayFactor = math.exp(-0.693 * age / halfLife)
zoneAlpha = math.round(decayFactor * 200)
box.set_bgcolor(b, color.new(zoneColor, 255 - zoneAlpha))
6. Kaplan-Meier Survival Analysis
The Kaplan-Meier estimator is a nonparametric statistical method originally developed to measure survival probabilities in clinical trial data. In this indicator, "survival" is defined as a liquidity zone remaining unmitigated (not breached by a closing price on two separate occasions). Each time a zone is mitigated, it is recorded as a "death event" at its current age. Zones that expire by age limit without mitigation are recorded as "censored events" — incomplete observations. The KM formula multiplies survival probabilities across all observed events up to a given age.
// For each completed event (death at age t_i with n_i at-risk zones):
S_t := S_t * (1.0 - d_i / n_i)
// Product over all event times <= query age
For each active zone, the indicator queries the KM estimate at the zone's current age and displays the result as a percentage label. A zone at age 40 showing "Age 40 | 72%" means that historically, 72% of zones survived to at least 40 bars without being mitigated — giving traders a quantitative assessment of how likely the zone is to hold on the next test.
Features
- Z-Score Cumulative Impulse: Statistical momentum threshold using normalized cumulative directional streaks to gate zone creation.
- Volume Quality Gate: Volume RSI filter ensures only high-participation impulses create zones.
- Precise Order Block Identification: Most recent opposing candle (last down-close for bull event, last up-close for bear event) defines zone boundaries.
- Overlap Prevention: f_no_overlap function checks all existing zones before creating a new one, preventing chart clutter from redundant levels.
- Bayesian Exponential Decay: Zone opacity decays over time with configurable half-life, encoding freshness as a visual probability signal.
- Kaplan-Meier Survival Analysis: Medical-statistics survival estimator applied to zone longevity, displayed as a percentage probability label on each active zone.
- Dynamic Zone Extension: Box right edge extends to the current bar on every update, keeping zones visually connected to the present.
- Mitigation Tracking: Zones that are closed through twice are flagged as mitigated and removed, with the event recorded for KM analysis.
- Seven-Row Dashboard: Active demand count, active supply count, bull Z, bear Z, volume RSI, KM training size, and signal status.
- Two Alert Conditions: Zone created alert and zone rejection (price tests and bounces back) alert.
Input Parameters
Z-Score Settings:
- Z Lookback: Rolling window for Z-score normalization (default: 50)
- Z Threshold: Sigma level required to trigger an impulse event (default: 2.0)
Volume Gate Settings:
- Volume RSI Period: RSI lookback for volume normalization (default: 14)
- Volume RSI Threshold: Minimum volume RSI for zone creation eligibility (default: 55)
Zone Management Settings:
- Max Zone Age: Maximum bars a zone remains active before forced removal (default: 300)
- Mitigation Count: Number of closes through a zone required for mitigation (default: 2)
- Max Active Zones Per Side: Maximum simultaneous demand or supply zones displayed (default: 5)
Decay Settings:
- Decay Half-Life: Number of bars at which zone opacity reaches 50% of initial value (default: 75)
KM Settings:
- KM Training Window: Bar lookback for Kaplan-Meier training data collection (default: 500)
- Show Survival Labels: Toggle KM probability labels on active zones (default: true)
Display Settings:
- Show Demand Zones: Toggle demand (bull) zone boxes (default: true)
- Show Supply Zones: Toggle supply (bear) zone boxes (default: true)
- Show Dashboard: Toggle the seven-row information table (default: true)
How to Use This Indicator
Step 1: Understand Zone Creation Conditions
Zones are not created on every bar — they are created only when a statistically significant directional impulse (Z-score above threshold) occurs on above-average volume. This selectivity is intentional. In any given trading session, you will likely see only a few zone creation events, each backed by a genuine momentum surge that suggests institutional participation. When you see a new zone appear, note the Z-score values in the dashboard and the volume RSI reading — higher values on both indicate a stronger impulse and more confident zone placement.
Step 2: Prioritize Fresh, High-Survival Zones
Not all zones on the chart are equally relevant. A fresh zone (low age, full opacity) at a KM survival rate of 80% is a far stronger candidate for price reaction than an old zone (high age, near-transparent) at 30% survival probability. Use both the visual opacity and the KM label together: as a zone ages and fades, reduce your expectation that it will provide meaningful support or resistance. When price approaches a zone that is both visually fresh and shows high KM survival probability, the statistical expectation of reaction is at its highest.
Step 3: Watch for Zone Rejection Alerts
The zone rejection alert fires when price tests a zone (enters the box boundary) and then closes back away from it without mitigating it. This is the core trade setup: price returning to the institutional order block level, briefly penetrating it, and then reversing. The rejection alert provides a timely notification for potential entries in the direction of the original impulse that created the zone, with the zone's near boundary serving as the natural stop-loss reference.
Step 4: Monitor KM Training Size for Statistical Validity
The dashboard displays the KM training sample size — the number of completed zone events (both mitigated and aged-out) available for the survival analysis. With fewer than 10 training events, the KM estimate has high variance and should be treated as rough guidance. With 30 or more training events, the estimate becomes statistically stable. On instruments or timeframes where the indicator has run for extended periods, the KM estimates become increasingly reliable as the training dataset grows.
Indicator Limitations
- The Z-score cumulative impulse and volume gate require sufficient chart history for the rolling normalization periods to be seeded. In the first Z-lookback bars of a new chart, zone creation signals may be less reliable as the mean and standard deviation are not yet fully established.
- Kaplan-Meier survival estimates are only as reliable as the training dataset. On instruments or timeframes that have not accumulated many completed zone events, the survival probabilities should be treated as rough estimates rather than statistically precise values.
- The mitigation definition (two closes through the zone) is a configurable approximation. In real order block theory, mitigation can be defined in several ways; this indicator's specific definition may not match every trader's conceptual framework.
- Zones are based on the most recent opposing candle at the time of the impulse event. In fast markets where multiple large candles cluster closely together, the marked candle may not represent the most significant institutional order location.
- This indicator requires volume data. On instruments where volume is unavailable or unreliable (some synthetic indices, certain forex pairs), the volume gate will not function as intended and should be disabled or its threshold lowered significantly.
- The exponential decay model assumes a constant half-life across all market conditions. In reality, zone relevance can be regime-dependent — a zone formed during a trending market may remain relevant longer than one formed during a range, or vice versa.
- Maximum active zones per side is a hard limit. If the limit is reached, new valid zone creation events will be rejected until an existing zone is mitigated or aged out.
Originality Statement
The Liquidity Zone Harvester is a genuinely original indicator that applies statistical and mathematical frameworks from outside the trading domain to a problem common in technical analysis.
- The Z-score cumulative impulse detection — using consecutive close-open accumulation normalized against rolling sma/stdev — as the primary trigger for order block marking is an original signal architecture. Most order block indicators use visual pattern matching (e.g., a large candle followed by a gap) rather than statistical significance thresholds.
- Applying the Kaplan-Meier survival estimator — a nonparametric method from biostatistics — to estimate the probability that a liquidity zone will survive future price tests is a novel application of medical statistics to market analysis. This provides a mathematically grounded probability estimate that no standard order block indicator offers.
- The Bayesian exponential decay applied to zone visual transparency — using a configurable half-life to continuously encode zone freshness as opacity — is an original visual design that treats zone relevance as a continuously diminishing probability rather than a binary active/inactive state.
- The overlap prevention function that iterates over all existing zone arrays before creating a new zone — with the index-crash guard for empty arrays — is a specific engineering solution to a concrete problem in box-based indicator design.
- The volume RSI quality gate, applied specifically to filter Z-score impulse events rather than as a standalone signal, is an original confluence filter design that specifically addresses the problem of thin-market false signals in order block detection.
Disclaimer
The Liquidity Zone Harvester [JOAT] is provided for educational and informational purposes only. It is a technical analysis tool and does not constitute financial advice. Liquidity zones and order blocks are analytical constructs; they do not guarantee price reactions. Past zone behavior as encoded in Kaplan-Meier estimates does not predict future zone performance. All trading involves risk of loss. Users are solely responsible for their own trading decisions. Please consider your individual risk tolerance and consult a licensed financial professional before engaging in any trading activity.
-Made with passion by officialjackofalltrades
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
The AI Trading Ecosystem, Built to win trades 📈
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
The AI Trading Ecosystem, Built to win trades 📈
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.