OPEN-SOURCE SCRIPT
Smart Money Liquidity Detector [PickMyTrade]

Smart Money Liquidity Detector [PickMyTrade]
This indicator measures market microstructure — the structural signals that institutional activity leaves behind in price and volume data. It combines four academically grounded models into a single Microstructure Stress Score (MSS) ranging from 0 to 100.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
MODELS USED
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
► Roll (1984)
Synthetic bid-ask spread estimated from the serial covariance of price changes. High Roll spread indicates wider market-maker quotes — historically associated with periods of elevated volatility.
► Corwin-Schultz (2012)
High-low range spread estimator. Uses the relationship between single-period and two-period high-low ranges to back out the effective spread without requiring tick data.
► Amihud (2002)
Illiquidity ratio measuring price move per unit of volume. High Amihud values mean large price impact per dollar traded — a sign of thin order books.
► Kyle Lambda (1985)
Price impact of signed order flow. Derived from the regression of price changes on volume direction. Estimates how aggressively informed participants are moving the market.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
MICROSTRUCTURE STRESS SCORE (MSS)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Each model is z-scored over a rolling window, normalised to [0,1], then averaged and scaled to 0–100.
MSS = (Roll + Corwin-Schultz + Amihud + Kyle Lambda) / 4 × 100
- MSS > 70 → High stress. Spreads wide, illiquidity elevated, price impact high. Consistent with institutional order flow.
- MSS 30–70 → Normal range. No structural signal.
- MSS < 30 → Low stress. Tight spreads, liquid conditions, quiet tape.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ANOMALY DETECTION
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Any individual model z-score crossing ±2σ triggers an anomaly flag. Anomaly bars are highlighted in orange on the chart. Roll and Corwin-Schultz anomalies are marked with coloured circles directly on the MSS line.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
INPUTS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
- Spread window (default 20) — lookback for Roll and Corwin-Schultz estimation
- Z-score window (default 60) — rolling window for z-scoring all models
- Impact window (default 20) — lookback for Amihud and Kyle Lambda
- MSS normalise window (default 100) — window for [0,1] normalisation before scoring
- Toggle each model's z-score plot individually
- Highlight anomaly bars on/off
- Info table on/off
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
INFO TABLE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Top-right table displays live values and z-scores for all four models, the current MSS reading, and anomaly status on the last closed bar.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
NOTES
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
- Works on any liquid instrument and any timeframe. Most effective on futures, forex, and equity indices where volume data is reliable.
- This indicator does not generate buy or sell signals. It is a market structure diagnostic tool.
- Powered by PickMyTradeLib — PickMyTrade's open quantitative library.
This script is published for educational and informational purposes only. It does not constitute financial advice. Use at your own risk. Past microstructure behaviour does not guarantee future price outcomes.
This indicator measures market microstructure — the structural signals that institutional activity leaves behind in price and volume data. It combines four academically grounded models into a single Microstructure Stress Score (MSS) ranging from 0 to 100.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
MODELS USED
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
► Roll (1984)
Synthetic bid-ask spread estimated from the serial covariance of price changes. High Roll spread indicates wider market-maker quotes — historically associated with periods of elevated volatility.
► Corwin-Schultz (2012)
High-low range spread estimator. Uses the relationship between single-period and two-period high-low ranges to back out the effective spread without requiring tick data.
► Amihud (2002)
Illiquidity ratio measuring price move per unit of volume. High Amihud values mean large price impact per dollar traded — a sign of thin order books.
► Kyle Lambda (1985)
Price impact of signed order flow. Derived from the regression of price changes on volume direction. Estimates how aggressively informed participants are moving the market.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
MICROSTRUCTURE STRESS SCORE (MSS)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Each model is z-scored over a rolling window, normalised to [0,1], then averaged and scaled to 0–100.
MSS = (Roll + Corwin-Schultz + Amihud + Kyle Lambda) / 4 × 100
- MSS > 70 → High stress. Spreads wide, illiquidity elevated, price impact high. Consistent with institutional order flow.
- MSS 30–70 → Normal range. No structural signal.
- MSS < 30 → Low stress. Tight spreads, liquid conditions, quiet tape.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ANOMALY DETECTION
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Any individual model z-score crossing ±2σ triggers an anomaly flag. Anomaly bars are highlighted in orange on the chart. Roll and Corwin-Schultz anomalies are marked with coloured circles directly on the MSS line.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
INPUTS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
- Spread window (default 20) — lookback for Roll and Corwin-Schultz estimation
- Z-score window (default 60) — rolling window for z-scoring all models
- Impact window (default 20) — lookback for Amihud and Kyle Lambda
- MSS normalise window (default 100) — window for [0,1] normalisation before scoring
- Toggle each model's z-score plot individually
- Highlight anomaly bars on/off
- Info table on/off
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
INFO TABLE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Top-right table displays live values and z-scores for all four models, the current MSS reading, and anomaly status on the last closed bar.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
NOTES
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
- Works on any liquid instrument and any timeframe. Most effective on futures, forex, and equity indices where volume data is reliable.
- This indicator does not generate buy or sell signals. It is a market structure diagnostic tool.
- Powered by PickMyTradeLib — PickMyTrade's open quantitative library.
This script is published for educational and informational purposes only. It does not constitute financial advice. Use at your own risk. Past microstructure behaviour does not guarantee future price outcomes.
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.
Automate TradingView alerts to brokers no coding needed. Trade futures, forex, or crypto, copy trades across unlimited accounts, & control risk with ease.
For Tradovate: bit.ly/4a1KBrY
For all other supported brokers: bit.ly/4qEbU2G
For Tradovate: bit.ly/4a1KBrY
For all other supported brokers: bit.ly/4qEbU2G
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.
Automate TradingView alerts to brokers no coding needed. Trade futures, forex, or crypto, copy trades across unlimited accounts, & control risk with ease.
For Tradovate: bit.ly/4a1KBrY
For all other supported brokers: bit.ly/4qEbU2G
For Tradovate: bit.ly/4a1KBrY
For all other supported brokers: bit.ly/4qEbU2G
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.