OPEN-SOURCE SCRIPT
edgeful - supply and demand zones

edgeful — supply and demand zones
what this indicator does
this indicator automatically draws supply zones (potential resistance) and demand zones (potential support) on your chart. it uses one strict rule: a zone is only created when the market produces a measurable impulse move away from a candle. the candle that immediately precedes that impulse is preserved as the zone — the area where price was last balanced before the imbalance occurred.
there are no swing pivots, no fractals, no volume profile, no order-flow approximations, and no higher-timeframe lookups. zones come purely from how big a candle is relative to recent volatility, which makes the logic transparent and the output reproducible.
how a zone is detected
1. volatility baseline. ATR (default length 14) measures the "normal" candle size for the current market regime.
2. impulse test. each closed candle's body is compared to ATR. the candle is treated as an impulse only if its body is at least impulse strength × ATR (default 1.5× ATR). wicks are ignored here — wicks reflect rejection, not commitment.
3. origin candle. when a bullish impulse closes, the last bearish or doji candle before it becomes a demand zone. when a bearish impulse closes, the last bullish or doji candle before it becomes a supply zone.
4. zone geometry. by default the zone is the body of the origin candle (open-to-close range). toggling "zone uses candle body" off widens it to the full candle range (high-to-low) for more conservative entries with deeper stops.
5. display. each zone is drawn as a colored box that extends to the right of the chart until it gets mitigated.
mitigation — when a zone is removed
- close (default) — zone is removed only when a candle closes beyond the far edge. filters out intrabar wicks and stop-runs that don't actually break structure.
- wick — zone is removed as soon as any wick pierces the far edge. stricter, fewer surviving zones, but reacts faster to liquidity sweeps.
mitigation runs 24/7 regardless of the session filter — a zone created during one session can still be invalidated outside it.
session filter
zones can be restricted to form only during a specific session:
- daily — no restriction
- new york — default 0930–1600
- london — default 0300–1100
- asian — default 1900–0400
all session times use the timezone you select (default America/New_York, but any IANA timezone or GMT±N offset works). useful if you only trade liquidity from one session and want to ignore zones built during low-participation hours. mitigation is not session-restricted — a zone built during NY can be broken during Asia.
day-aging filter
"limit zones to N days back" removes zones whose origin candle is older than N calendar days in the selected timezone. 0 disables it. 1 keeps only today's zones. 2 keeps today + yesterday. the cutoff handles daylight-saving correctly, so it never shifts by an hour around DST transitions.
display controls
- max demand / max supply zones — independent caps (1–50 each). when exceeded, the oldest zone on that side is removed first.
- zone colors — fully configurable, transparency included.
- show zone border — toggle a darker border for readability on busy charts.
alerts
- new demand zone — fires when a fresh demand zone is plotted.
- new supply zone — fires when a fresh supply zone is plotted.
- demand zone mitigated — fires when an existing demand zone is invalidated.
- supply zone mitigated — fires when an existing supply zone is invalidated.
how to use it
- bias / context. treat unmitigated demand zones as areas where buyers previously stepped in hard enough to drive an impulse, and supply zones the same way for sellers. these are levels of interest, not automatic trade triggers.
- entry workflow. wait for price to return into a zone, then look for a lower-timeframe confirmation (engulfing candle, break of internal structure, FVG fill, etc.) before entering. the zone defines the area; your trigger defines the moment.
- stop placement. with the default body-based zone, a stop just beyond the far edge respects the same mitigation rule the indicator uses internally — if the zone is mitigated, the thesis was wrong. switch to full-range zones if you prefer wider stops.
- tuning. on instruments that move in clean impulses (index futures during NY), the default 1.5× ATR setting produces a small number of high-quality zones per session. on choppier instruments or lower timeframes, raise the multiplier (e.g. 2.0–2.5×) to keep zone count manageable.
- session focus. if you only trade the NY open, set the session filter to "new york" so overnight zones don't clutter the chart — they'll still be respected on mitigation, just not created.
what makes this implementation original
most public supply/demand scripts mix several heuristics together: pivot-based swings, multi-candle base detection, volume confirmation, breaker-block re-classification. that makes them hard to reason about and tune.
this script does the opposite — it isolates one definition: the last opposite-color candle before an ATR-scaled impulse is the zone. every other behavior (geometry, mitigation, session, aging, max counts) is a transparent filter layered on top of that one rule.
specific choices that distinguish it:
- ATR-relative impulse measurement instead of a fixed point/percentage threshold, so the same settings adapt across instruments and volatility regimes.
- body-only impulse detection with independent body-or-wick zone geometry — usually these are conflated; here you control them separately.
- close vs. wick mitigation as a first-class user input, not hardcoded.
- calendar-aware day-back aging that uses local-timezone midnight rather than fixed-millisecond subtraction, so DST changes don't shift the cutoff.
- session-scoped creation with unconditional mitigation — matches how discretionary traders actually use these zones: only build them when liquidity is real, but always respect invalidation.
- non-repainting by design — every zone is anchored to a closed historical bar, and once drawn it never moves.
what this indicator does
this indicator automatically draws supply zones (potential resistance) and demand zones (potential support) on your chart. it uses one strict rule: a zone is only created when the market produces a measurable impulse move away from a candle. the candle that immediately precedes that impulse is preserved as the zone — the area where price was last balanced before the imbalance occurred.
there are no swing pivots, no fractals, no volume profile, no order-flow approximations, and no higher-timeframe lookups. zones come purely from how big a candle is relative to recent volatility, which makes the logic transparent and the output reproducible.
how a zone is detected
1. volatility baseline. ATR (default length 14) measures the "normal" candle size for the current market regime.
2. impulse test. each closed candle's body is compared to ATR. the candle is treated as an impulse only if its body is at least impulse strength × ATR (default 1.5× ATR). wicks are ignored here — wicks reflect rejection, not commitment.
3. origin candle. when a bullish impulse closes, the last bearish or doji candle before it becomes a demand zone. when a bearish impulse closes, the last bullish or doji candle before it becomes a supply zone.
4. zone geometry. by default the zone is the body of the origin candle (open-to-close range). toggling "zone uses candle body" off widens it to the full candle range (high-to-low) for more conservative entries with deeper stops.
5. display. each zone is drawn as a colored box that extends to the right of the chart until it gets mitigated.
mitigation — when a zone is removed
- close (default) — zone is removed only when a candle closes beyond the far edge. filters out intrabar wicks and stop-runs that don't actually break structure.
- wick — zone is removed as soon as any wick pierces the far edge. stricter, fewer surviving zones, but reacts faster to liquidity sweeps.
mitigation runs 24/7 regardless of the session filter — a zone created during one session can still be invalidated outside it.
session filter
zones can be restricted to form only during a specific session:
- daily — no restriction
- new york — default 0930–1600
- london — default 0300–1100
- asian — default 1900–0400
all session times use the timezone you select (default America/New_York, but any IANA timezone or GMT±N offset works). useful if you only trade liquidity from one session and want to ignore zones built during low-participation hours. mitigation is not session-restricted — a zone built during NY can be broken during Asia.
day-aging filter
"limit zones to N days back" removes zones whose origin candle is older than N calendar days in the selected timezone. 0 disables it. 1 keeps only today's zones. 2 keeps today + yesterday. the cutoff handles daylight-saving correctly, so it never shifts by an hour around DST transitions.
display controls
- max demand / max supply zones — independent caps (1–50 each). when exceeded, the oldest zone on that side is removed first.
- zone colors — fully configurable, transparency included.
- show zone border — toggle a darker border for readability on busy charts.
alerts
- new demand zone — fires when a fresh demand zone is plotted.
- new supply zone — fires when a fresh supply zone is plotted.
- demand zone mitigated — fires when an existing demand zone is invalidated.
- supply zone mitigated — fires when an existing supply zone is invalidated.
how to use it
- bias / context. treat unmitigated demand zones as areas where buyers previously stepped in hard enough to drive an impulse, and supply zones the same way for sellers. these are levels of interest, not automatic trade triggers.
- entry workflow. wait for price to return into a zone, then look for a lower-timeframe confirmation (engulfing candle, break of internal structure, FVG fill, etc.) before entering. the zone defines the area; your trigger defines the moment.
- stop placement. with the default body-based zone, a stop just beyond the far edge respects the same mitigation rule the indicator uses internally — if the zone is mitigated, the thesis was wrong. switch to full-range zones if you prefer wider stops.
- tuning. on instruments that move in clean impulses (index futures during NY), the default 1.5× ATR setting produces a small number of high-quality zones per session. on choppier instruments or lower timeframes, raise the multiplier (e.g. 2.0–2.5×) to keep zone count manageable.
- session focus. if you only trade the NY open, set the session filter to "new york" so overnight zones don't clutter the chart — they'll still be respected on mitigation, just not created.
what makes this implementation original
most public supply/demand scripts mix several heuristics together: pivot-based swings, multi-candle base detection, volume confirmation, breaker-block re-classification. that makes them hard to reason about and tune.
this script does the opposite — it isolates one definition: the last opposite-color candle before an ATR-scaled impulse is the zone. every other behavior (geometry, mitigation, session, aging, max counts) is a transparent filter layered on top of that one rule.
specific choices that distinguish it:
- ATR-relative impulse measurement instead of a fixed point/percentage threshold, so the same settings adapt across instruments and volatility regimes.
- body-only impulse detection with independent body-or-wick zone geometry — usually these are conflated; here you control them separately.
- close vs. wick mitigation as a first-class user input, not hardcoded.
- calendar-aware day-back aging that uses local-timezone midnight rather than fixed-millisecond subtraction, so DST changes don't shift the cutoff.
- session-scoped creation with unconditional mitigation — matches how discretionary traders actually use these zones: only build them when liquidity is real, but always respect invalidation.
- non-repainting by design — every zone is anchored to a closed historical bar, and once drawn it never moves.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
45+ invite-only TradingView indicators available with your edgeful membership. sign up now for instant access.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
45+ invite-only TradingView indicators available with your edgeful membership. sign up now for instant access.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.