Version 18 · Decision engine
Secari Square
Secari Decision Engine
Order flow probability layer
Non-overlay oscillator for TradingView — six order-flow analytics fused into one kernel-weighted directional probability engine. No Level II required.
© 2026 Secari Square. TradingView® and Pine Script™ are trademarks of their respective owners.
Module reference
Secari Decision Engine
Multi-factor order flow inference engine that converts microstructure signals into probabilistic directional bias.
Last updated April 2026 · Technical spec v18
Overview · Decision Engine v18
Secari Decision Engine v18 is a non-overlay oscillator for TradingView (Pine Script v6) that fuses six order-flow analytics into one KNN-driven directional probability engine. It estimates institutional-style activity through volume delta, absorption, imbalance, divergence, exhaustion, and a binned volume profile — without Level II or tick data.
Design philosophy
- Signal over noise — configurable cooldown gates cut clustering and false repetition.
- Probabilistic thinking — directional probabilities P(Up) and P(Down) plus confidence, not binary arrows.
- Zero repainting — computations use barstate.isconfirmed; pivot divergences confirm with fixed lag; no request.security or lookahead branching.
Engine modules
Order-flow mathematics
Without true bid/ask tape, the engine estimates buying vs. selling from candle geometry: range R, upper/lower wicks, and close location beta. A ±15% wick adjustment shifts beta when long lower wicks suggest buy-side absorption at lows (and the converse at highs).
Delta & cumulative delta
Per-bar delta is buy volume minus sell volume. Cumulative delta (CD) sums deltas. A Z-score of raw delta vs. its SMA and standard deviation flags extremes (beyond about ±2 is statistically notable). SCD is a 5-bar CD momentum smoothed over 10 bars.
Absorption scoring
Absorption score A blends volume spike vs. average, normalized range vs. ATR14, and how balanced delta is vs. total volume. Detection fires when A > 65.
Imbalance scoring
Imbalance I rewards volume spikes, wide range vs. ATR, and extreme Z-delta. Threshold I > 70 with delta sign yields bull vs. bear imbalance. Consecutive same-direction imbalances increment a stack counter; k ≥ 2 suggests sustained aggression.
Divergence & exhaustion
Swing pivots (N = 7 bars) compare price pivots to CD pivots with a 0.5×ATR minimum gap to avoid noise. Bullish divergence: price lower low, CD higher low; bearish: price higher high, CD lower high. Exhaustion requires simultaneous volume Z > 2.5, delta Z beyond ±2.5, and range above 1.0×ATR.
Volume profile
Over L bars the engine bins mid-prices into 20 levels between period high and low, finds POC (max volume bin), then expands a 70% value area from POC upward and downward. Distance to POC is normalized by ATR14 for feature use.
KNN probability engine
Instead of a fixed K and majority vote, the engine uses kernel-weighted similarity over a depth of historical bars — closer past states dominate; distant ones fade out (Nadaraya–Watson style).
Six-dimensional feature vector
Similarity & probabilities
Log-distance d = Σ ln(1 + |fi,t − fi,t−ℓ|) dampens outlier dimensions. Weight w = 1/(1+d). For each lag ℓ, forward return over F bars (default 5) votes up or down. Raw P(Up) and P(Dn) are kernel-weighted fractions, then smoothed with a 3-bar EMA. Confidence = |P(Up) − 0.5| × 200 (0–100).
Composite bias, visuals & dashboard
Composite bias B on [-100, +100] clamps and combines Z-delta, probability skew (P(Up)−0.5), and small contributions from imbalance (+/−10), absorption (+/−5 by close vs. open), and divergence (+/−10).
Cooldown system
Each signal family keeps its own bar counter. A raw signal only passes if τ ≥ τcd (default 10 bars, range about 3–50). Separate counters cover absorption, bull/bear imbalance, divergences, and exhaustion.
Display modes
Signal shapes anchor in tiers (e.g. absorption/imbalance near ±5% of pane range; divergence/exhaustion near ±12%). Histogram bar alpha scales with delta extremity so weak flow looks transparent and extreme flow reads solid.
Dashboard rows (abridged)
Parameter reference (defaults)
Order flow engine
Probability engine
Display & theme
Toggles control absorption diamonds, imbalance arrows, DIV labels, exhaustion crosses, and background zones. Theme pickers assign bullish (#00E676), bearish (#FF1744), warning (#FFAB00), accent (#448AFF), and neutral (#787B86) roles across UI elements.
Alerts & usage
Built-in alerts fire on cooldown-gated conditions (abbreviated):
Quick start
- Add the indicator in its own pane.
- Pick a display mode (delta, cumulative delta, or probability).
- Read bias and dashboard for a fast directional read.
- Watch tier-anchored shapes at the pane edges.
- Attach alerts to the conditions that match your playbook.
Confluence ideas
- Bullish: B > +50 with P(Up) > 60% and confidence > 60%, plus bull imbalance or stack ≥ 2, price near/below VAL, CD slope positive.
- Bearish: mirror with P(Dn), bear imbalance, price near/above VAH, CD slope negative.
- Caution: exhaustion with your trend, absorption against you, divergence against you, or confidence under ~30%.
Technical properties
- KNN and profile: gated on confirmed bars only.
- Divergences: pivot confirmation introduces a fixed lag (7 bars).
- No external requests — no request.security().
- No realtime-only branches that repaint intrabar conclusions.
- Designed to be backtest-safe at historical resolution.
Rough per-bar cost scales with KNN depth D and profile length L (on the order of D + L operations at defaults — tractable on TradingView).
Limitations & disclaimers
- Delta is estimated — without Level II, classification is approximate.
- Binned profile (20 levels) summarizes structure; not tick-precision.
- KNN is backward-looking — regime breaks can invalidate historical analogs.
- Tooling is a confluence layer — pair with price action and risk rules.
- Volume quality varies (e.g. forex tick volume vs. centralized venues).
Platforms & installation
This specification describes the TradingView Pine Script v6 build. A NinjaTrader 8 port may follow the same conceptual stack where platform APIs allow; check your delivery materials for the exact build you received.
After purchase (when sales are open), use the license email to add the script, validate loads in the editor, then paper-test before live use.
Want in on the build? Hit the team.