OPEN-SOURCE SCRIPT

APEX Contra Flow | ProjectSyndicate

3 266
APEX Contra Flow rebuilds the order flow hidden inside every candle and reads it as an auction — then scores, bar by bar, whether that auction has finished and is ready to reverse. It drills into each bar with a lower-timeframe scan, distributes the intrabar volume across price by true overlap, splits it into graded buy/sell pressure, and renders it as a footprint anchored by POC, Delta POC, intrabar VWAP and the Value Area. On top of that it runs one idea from auction theory that conventional profile tools ignore: a market doesn't turn where volume is heavy — it turns where the auction runs out of business. The Contrarian Engine finds the bars where aggression achieved nothing, grades them 0–10, and fades them back toward value.

Most footprint tools describe. This one takes a side.

🌊 Intrabar Footprint Engine — the core. A lower-timeframe scan breaks each chart bar into its internal prints and rebuilds the auction that produced it. Granularity is adjustable (1 Tick / 1S / 5S / 15S / 1M / 5M) or Auto-scaled to your chart, with an automatic fallback resolution — if your plan or symbol won't serve the resolution you asked for, the engine silently drops to one that works instead of drawing a blank chart.

🧮 Overlap-Proportional Allocation — the accuracy differentiator. Conventional intrabar profiles smear each print's volume equally across every row it touches, which fattens the profile and drags the POC toward wide bars. APEX Contra Flow weights every row by the exact price overlap between the intrabar's range and that row. The shape you read is the shape that traded.

⚖️ Graded Buy/Sell Classification — not close >= open. On tick data the engine classifies against bid/ask (at-or-above ask = buy, at-or-below bid = sell, interpolated between). Off tick data it uses a tunable blend of close-location-in-range and body direction. Delta becomes a gradient, not a coin flip — so a bar that closed flat but was bought all the way up no longer reads as neutral.

🎯 POC · Delta POC · Intrabar VWAP — three separate reads on one candle. The Volume POC is where trade concentrated. The Delta POC is where the largest one-sided delta sits — the two diverging is a tell in itself. The intrabar VWAP marks the candle's true average traded price.

🧲 Value Area (VA) — computed by true value-area expansion outward from the POC at your chosen percentage, drawn as a clean outline with everything outside it dimmed back. Fair value framed; the rest fades.

🔺 Diagonal Imbalances & Stacked Runs — every row is tested diagonally: buy at a level against sell one level below, sell against buy one level above. Rows clearing your ratio are marked ◆ and coloured by side. Consecutive runs are counted — stacked imbalance sitting at the extreme is exhaustion evidence, not strength.

🕯️ Excess vs Unfinished Auction — the read almost nothing else surfaces. Thin single prints at a bar's extreme (·) are excess: the auction rejected that price and finished. Heavy volume parked at the extreme is unfinished business — an untested magnet price will likely come back for. One says reversal, the other says return.

🔠 Auction Shape Classification — P / b / D / B — real market-profile logic, applied per candle.
▪️ P — POC in the upper third, thin below: the rally was short covering, not fresh buying. Weak. Fade it.
▪️ b — POC in the lower third, thin above: long liquidation / capitulation. Fade it.
▪️ D — balanced auction, POC mid-range. Rotation back to the middle.
▪️ B — double distribution (two volume clusters split by a thin gap). This is a trending auction — and it vetoes the fade outright. The single most valuable filter in the tool is the one that tells you to stand down.

🏆 0–10 Contrarian Conviction Score — the power-ranking. Each fade candidate earns a live grade from seven weighted, principled factors, every one with a fixed directional sign:
▪️ Effort without result — heavy relative volume and delta that produced no body.
▪️ Trapped delta — delta pushing one way while the candle closes the other. Someone is offside.
▪️ Wick rejection — how violently the extreme was defended.
▪️ Excess — thin tail at the extreme being faded (finished auction).
▪️ Auction shape — P against a high, b against a low.
▪️ CVD divergence — a new price extreme that cumulative delta refused to confirm.
▪️ Stacked imbalance at the extreme — aggression stacking into a wall.
Resolved to a tier: WK → MOD → STRONG → V.STRONG → EXTREME.

🚪 Context Gates — why the signals stay rare. A score alone fires nothing. The bar must also print a new N-bar extreme, stretch a configurable ATR distance beyond its mean, clear a cooldown, and survive the B-shape veto. Fading strength in a trend is how contrarians die; these gates exist to stop it.

🎯 Fade Signals, Targets & Invalidation — one clean FADE ▲ / FADE ▼ label carrying the score. A dotted magnet line projects to the target: the nearest naked POC in the fade direction, or the candle's own POC if none is standing. A tick marks the invalidation extreme. Hover the label for the full read — score, tier, auction shape, value migration, delta, relative volume, POC, VWAP and the LTF actually used.

📍 Naked POC Magnets — high-conviction candles leave their POC extended to the right until price trades back through it, then it's removed. Untested POCs are unfinished business — and they double as the fade target.

📖 Legend Key — a static, self-adapting key (bottom-right by default). It lists only the glyphs you have switched on, and reads your live settings — your imbalance ratio, your VA %, your score threshold — so it can never drift out of sync with the chart.

🎨 Nine Dark-Native Themes — Obsidian (default), Institutional, Aurora, Neon, Phantom, Solar, Ice, Plasma and Mono — every one tuned to read on a black background, plus full custom buy/sell/POC overrides.

🧹 Clean-Chart Discipline — no dashboard, by design. No panel, no stat block, no clutter competing with price. The profile is the interface; the score lives inside the candle that earned it, the reasoning lives in the tooltip. Bar delta, CVD, contrarian score and bar volume stream to the Data Window for anyone who wants the raw series.

🔒 Honest & Non-Repainting Core — fade signals fire on confirmed bars only and never repaint away once printed. No signal is ever hidden, deleted or de-rated to flatter the chart. The footprint of the live, forming candle naturally refreshes as it builds — that is inherent to reconstructing order flow in real time, not a defect — and every closed bar is fixed. The 0–10 score is a descriptive auction framework for ranking attention, not a backtested edge.

🔔 Native Alerts — Fade Long, Fade Short, and Any Fade.

🔧 Fully Customizable — profile basis (Volume / Delta), granularity, rows, bar length, classification method and blend weight, VA %, POC / Delta-POC / VWAP / imbalance / excess toggles, imbalance ratio, min score, extreme lookback, mean length and ATR extension, CVD divergence lookback, cooldown, target length, naked-POC threshold and cap, theme, out-of-value transparency, legend position and size.

🎯 Why this is different — profile tools show you where volume is and leave the conclusion to you. Footprint tools show you delta and leave the conclusion to you. APEX Contra Flow classifies the auction, tells you whether it finished or is still trending, refuses to fade the ones that are trending, and puts a graded 0–10 case for the reversal inside the candle that made it. You read where the auction broke, why it's exhausted, and where it should rotate back to — at a glance.

🚀 Apply to Gold (XAUUSD), Silver, Forex, Crypto, Indices and Futures on any intraday timeframe (volume-bearing symbols).

💡 Cleanest setup: an indicator cannot hide the chart's own candles — right-click the chart → Settings → Symbol → uncheck Body / Borders / Wick to let the footprint stand alone.

🎯 How To Trade It — Two Approaches

Everything hinges on one question the tool answers: has this auction finished, or is it still trending? Finished auctions rotate. Trending auctions run you over.

◾ 1) Fade the finished auction → rotate to value (the core thesis)

Use on STRONG / V.STRONG / EXTREME scores (≥7) where the grade is built on excess, trapped delta and CVD divergence — and the shape is P at a high or b at a low.

▪️ Wait for the FADE ▼ / FADE ▲ to print on the confirmed bar — the gates have already checked the new extreme, the ATR extension and the shape veto.
▪️ Entry: on the signal close, or on a shallow re-test of the faded extreme that fails to make a new one.
▪️ Stop: beyond the invalidation tick at the wick extreme. If price closes decisively through and accepts there, the auction wasn't finished — stand aside or flip to Approach 2.
▪️ Targets: the dotted magnet line — the nearest naked POC, else the candle's POC. The opposite Value-Area edge if rotation extends.

⚖️ The cleanest version: price spikes to a new 10-bar high, stretches beyond its mean, prints a long upper wick on heavy volume with positive delta but closes in the lower half (trapped buyers), the top rows are thin (excess), the POC sits high (P — short covering), and CVD refuses to confirm the new high. Score prints 8.4 EXT. That confluence is the exact move this tool was built to frame.

◾ 2) Stand down — and trade the other side

The tool tells you when not to fade, which is worth as much as the signal.

▪️ Shape = B (double distribution) — the auction is trending and building a second distribution. The veto fires. Do not fade; look for continuation on the pullback into the lower distribution instead.
▪️ No excess, heavy volume at the extreme — unfinished business. Price is likely to return to that price rather than reverse from it.
▪️ Signals fire and immediately fail, repeatedly — one-sided flow is expanding. Trade with it into the next naked POC.

Rule of thumb: ⭐ High score + excess + P/b shape + CVD divergence → expect rotation, fade toward the POC. ⭐ B shape, no excess, or price accepting beyond the level → expect follow-through, trade the break toward the next naked POC.

⚠️ IMPORTANT NOTICE: APEX Contra Flow reconstructs estimated order flow from lower-timeframe data. Intrabar delta, absorption and buy/sell classification are an approximation of true tape, not exchange order-book data — off tick resolution the buy/sell split is inferred from price behaviour, not observed aggression. The 0–10 contrarian score is a descriptive auction framework — NOT a backtested signal and NOT a standalone trade trigger. Fading extremes is inherently a counter-trend activity and carries real risk of repeated stop-outs in a trending market; the shape veto reduces this but cannot eliminate it. The indicator requires a volume-bearing symbol. Always combine it with your own strategy, price-action analysis and risk management. Past behaviour does not guarantee future results.

Wyłączenie odpowiedzialności

Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.