OPEN-SOURCE SCRIPT

Citadel Microstructure Edge [JOAT]

622
CITADEL MICROSTRUCTURE EDGE [JOAT]

A tribute to the high-frequency / market-making style of microstructure-edge extraction. Builds three orthogonal microstructure signals — tick imbalance (which side is aggressively crossing the tape), spread tightness (how thin the bid-ask is relative to its baseline), and micro momentum (the EMA-pair spread on the fastest timeframe) — then composes them into a single decaying edge value with an exponential half-life. When the edge crosses a configurable threshold and has sustained for N bars same-sign, a directional signal fires. Cooldown plus asymmetric lockout keep the signal stream institutional.

快照

Three orthogonal components

Each component is computed independently and Z-normalised (optional for tick imbalance) for stationarity:

  • Tick Imbalance — LTF-reconstructed buy/sell tick classification. Output is the rolling imbalance bounded in [−1, +1]; optionally Z-normalised over a configurable window (default 60 bars) for cross-asset stationarity. The dominant input for fast / scalping reads.
  • Spread Tightness — (H − L) / C against its own EMA-smoothed baseline, Z-scored. Tight spread (low relative range) is constructive for whichever side momentum favours. The sign is borrowed from the micro-momentum factor.
  • Micro Momentum — EMA-fast minus EMA-slow on the tick-reconstructed flow, Z-scored. The directional engine.


Default weights (0.45 / 0.25 / 0.45) bias the read toward the two most-actionable components (tick imbalance + momentum), with spread tightness as confirmation. Optional auto-normalisation to sum=1.

Decaying edge with half-life ~ 3 bars

Microstructure edges decay quickly. The script does not just sum the three components per bar — it accumulates with decay:

edge_t = decay × edge_{t−1} + contribution_t

The default decay (0.78) gives the edge a half-life of approximately 3 bars — the standard market-making decay window. Older contributions fade out automatically; new contributions get incorporated immediately. This is the institutional way to track a fast signal without re-introducing flicker.

Sustained-edge signal logic

  • Edge Threshold (default 0.75) — minimum |edge| magnitude required to fire.
  • Sustained Edge (default 5 bars same sign) — the edge must have held its sign for N consecutive bars before a signal fires. This is the script's most important false-positive filter.
  • Cooldown (default 7 bars) — minimum bars between signals.
  • Asymmetric lockout (default ON) — an opposite-side signal CAN fire during cooldown. This means a quick flip from buy to sell remains responsive while consecutive same-side signals are suppressed.


Visual system

  • Edge histogram — projected at the top of the chart at a configurable percent of price (default 2% of price, 1.2% top padding). Histogram columns are coloured by edge sign with magnitude-proportional intensity. At a glance you see the edge's recent trajectory.
  • Buy / Sell labels with optional Unicode lightning glyph (toggleable to plain ">").
  • Slope-tinted micro ribbon — the micro fast / slow EMAs plotted with a translucent fill coloured by spread sign. Toggleable.
  • Subtle background shade by edge sign (off by default).


A locked Crimson Pulse palette: electric blue buy edge / lime-yellow sell edge / muted neutral on a deep crimson-black ground — the institutional HFT aesthetic.

Dashboard

9-row monospaced table positionable to any of nine corners. Surfaces:

  • Edge value with status (BUY / SELL / FLAT).
  • Tick imbalance value.
  • Spread tightness Z.
  • Micro momentum Z.
  • Sustained-edge counter (how many consecutive same-sign bars).
  • Last signal direction with bars-ago.
  • Decay setting and effective half-life.
  • Cooldown remaining.
  • Configuration: LTF, weights, threshold.


Alerts

Three alert conditions, each independently controllable:

  • Edge Buy
  • Edge Sell
  • Sustained Edge (N bars same sign) — the script's headline alert; fires before the signal does, useful as an early-warning notification.


{image]快照

How to read it

Three reads, in order of conviction:

  1. Sustained edge into a structural level — the highest-conviction read. The microstructure has been one-sided for N+ bars AND price is at a known S/R; the next move into the level usually breaks it.
  2. Edge buy / sell with all three components agreeing — fast directional commitment. The dashboard's per-component rows tell you whether the read is dominated by tick imbalance (aggressive tape) or by micro momentum (sustained direction) or by spread tightness (regime-aware confirmation).
  3. Edge above threshold but not sustained — early-warning state. Edge has crossed threshold but the sustained counter has not yet reached N. Watch the counter — if it ticks up bar-by-bar, the signal is forming; if it drops, the edge is decaying.


Suggested settings

Defaults (1m LTF, spread EMA 14 / Z 60, micro EMA 3/8 / Z 60, weights 0.45/0.25/0.45, edge threshold 0.75, sustain 5 bars, decay 0.78, cooldown 7 bars) are tuned for 5m–15m charts on liquid futures and crypto where microstructure has meaningful presence. For 1m scalping drop LTF to 15s (Premium required) and sustain to 3 bars. For HTF the script is not the right tool — microstructure edges decay too quickly to be meaningful on 1H+ timeframes.

Originality

The implementation — the three-component microstructure pipeline (tick imbalance + spread tightness + micro momentum), the LTF tick-rule reconstruction with optional Z-normalisation, the weighted-sum composition with auto-normalisation, the exponential-decay edge accumulator with configurable half-life, the sustained-edge counter and asymmetric-lockout signal logic, the price-anchored histogram render at the top of the chart, the slope-tinted micro ribbon, and the Crimson Pulse palette — is JOAT-original. No third-party code reused. The script is a tribute to Citadel-style market-making microstructure-edge extraction, not a direct replication of any proprietary Citadel code.

Limitations

Reconstructed tick direction is an inference — the tick rule is the accepted public-market proxy but is not a direct read of bid/ask. Sub-minute LTFs require a TradingView Premium or Ultimate plan. Microstructure edges decay fast by design; on 1H+ timeframes the engine produces few signals — that is correct behaviour, not a bug.



-made with passion by jackofalltrades

免責聲明

這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。