OPEN-SOURCE SCRIPT
SRL Liquidity State Engine

Beyond Linear Volume: Unlocking Market Microstructure with the Square Root Law
Why 90% of traders misunderstand the relationship between Volume, Volatility, and Price—and how the "SRL Liquidity State Engine" fixes it.
1. Introduction: The Linear Fallacy
Every trader learns early on: "Volume precedes Price." We look at OBV, we look at volume bars, and we look at Moving Averages. But there is a fundamental flaw in how most indicators analyze volume: They assume the relationship is linear.
They assume that 1,000 contracts bought in a quiet market is the same as 1,000 contracts bought during a news event. But intuitively, we know this is false.
If price moves 1% on low volume, it suggests a vacuum (low liquidity). If price moves 1% on massive volume, it suggests a war (high liquidity). Standard indicators miss this context. They look at the fuel (Volume) without looking at the road conditions (Volatility).
This script, the SRL Liquidity State Engine, utilizes the Square Root Law (SRL) of market impact—specifically derived from Kyle’s (1985) market microstructure theories—to normalize volume against volatility. It answers the question: "What is the true intent of the market once we strip away the noise of volatility?"
2. The Theory: What is the Square Root Law?
In institutional trading and market microstructure theory, it is widely accepted that price impact is not linear; it is geometric.
The Formula:
The script is built on the inversion of Kyle’s Lambda. Roughly speaking:
$$ \Delta P \approx k \cdot \sigma \cdot \sqrt{\frac{Q}{V}} $$
By inverting this, we can solve for Q
Q (The True Intent or "Informed Order Flow"):
$$ Q = V \cdot \left( \frac{\Delta P}{\sigma \cdot k} \right)^2 $$
Where:
V: Observed Volume.
ΔP: Price Change from a pivot.
σ (Sigma): Volatility (using the Parkinson High-Low estimator).
k: An impact constant (liquidity scalar).
In simple English:
Imagine two cars.
Car A travels 100 miles using 5 gallons of gas on a smooth highway.
Car B travels 100 miles using 5 gallons of gas through a muddy swamp.
Car B worked much harder. The Square Root Law calculates this "work." It tells us that if volatility (the swamp) is high, we expect price to move more for the same volume. If price moves significantly despite high volatility (or lacks movement despite high volume), the SRL reveals the True Dominance (Q).
3. The Innovation: Under the Hood of the Engine
This script is not just a moving average crossover. It implements three advanced quantitative concepts:
A. Parkinson Volatility Estimator (1980)
Most volatility indicators use "Close-to-Close" data. This ignores the intraday fight between Bulls and Bears. This script uses the Parkinson Estimator, which utilizes the High and Low of the range. This provides a much more accurate "Sigma" (σ) for the SRL calculation, ensuring the script adapts instantly to expanding ranges.
B. Bulk Volume Classification (BVC)
Standard indicators treat a "green candle" as 100% buy volume. This is false. A doji with massive volume has both buying and selling. This script uses BVC (Easton, López de Prado, O'Hara 2012), which decomposes volume based on where the close is relative to the open and the intraday standard deviation. This gives us a granular look at Buy vs. Sell pressure.
C. Dual Anchor Analysis
The script doesn't just look at the current bar. It anchors to the most recent Pivot High and Pivot Low.
Bull Flow: Analyzes the buying pressure pushing up from the recent Low.
Bear Flow: Analyzes the selling pressure pushing down from the recent High.
By comparing the calculated Q (Intent) of these two flows, we get a Dominance Ratio.
4. Wyckoff State Detection
Mathematics is useless without context. The script translates these complex SRL calculations into the four classic Wyckoff Market States:
ACCUMULATION: Price is in the lower zone, but Bullish Q (Intent) is secretly rising. The "Smart Money" is buying the dip.
MARKUP: Price is rising, confirmed by Bullish Dominance. The trend is healthy.
DISTRIBUTION: Price is in the upper zone, but Bearish Q is secretly rising. "Smart Money" is selling into strength.
MARKDOWN: Price is falling, confirmed by Bearish Dominance. The trend is broken.
5. How to Use the Dashboard
The script projects a comprehensive data panel on your chart. Here is how to read it:
The Composite Score (Top Header)
A single number from -100 to +100.
> +60 (Green): Strong Buy / Markup Phase.
< -60 (Red): Strong Sell / Markdown Phase.
Yellow/Gray: Transition or Contested liquidity.
The Timeframes (Short / Medium / Long)
The engine analyzes three fractals simultaneously.
Alignment: When Short, Medium, and Long all show "BULL DOMINANT," the probability of a sustained trend is highest.
Divergence: If the Long term is Bullish, but the Short term flips to Bearish, the script identifies a potential Reversal Forming.
SRL vs. Sensitivity
The dashboard compares the actual price move (Sensitivity) vs. the calculated intent (SRL).
If Price is moving UP, but SRL says "Bearish," this is an Effort vs. Result anomaly—a classic signal that the move is a trap.
6. Practical Trading Strategies
Strategy A: The Trend Continuation (The "Markup" Trade)
Look for the Composite Score to cross above +30.
Ensure the Medium and Long panels show "BULL DOMINANT."
Wait for the State Analysis to confirm "MARKUP."
Stop Loss: Below the recent Pivot Low (displayed on the panel).
Strategy B: The Reversal (The "Accumulation" Trade)
Price is making lower lows (Bearish Trend).
Watch the Short Period Panel. Look for "BULL Q" to spike while price remains flat or drops slightly.
The Dashboard will signal "ACCUMULATION" or "BULLISH DIVERGENCE."
Enter when the Dominance Momentum turns positive.
7. Limitations & Disclaimer
Ranging Markets: Like all volatility-based tools, in extremely tight, low-volume chop, the denominator (volatility) becomes very small, which can exaggerate the Q values. The "Adaptive K" setting helps mitigate this, but caution is advised in flat markets.
Lag: While the Parkinson volatility is reactive, the State Analysis applies smoothing to prevent false signals. This means the "State" label may appear 1-3 bars after the absolute bottom/top.
8. Conclusion
The markets are a mechanism for price discovery, fueled by volume and restricted by volatility. By applying the Square Root Law, we stop guessing which volume spike matters and start measuring the mathematical energy behind the move.
The SRL Liquidity State Engine is designed to give you the institutional "X-Ray" view of this battle, blending rigorous microstructure math with practical Wyckoffian logic.
Settings:
Impact Constant (k): Adjusts the sensitivity. Higher k = More conservative.
Adaptive k: Check this to let the script auto-calibrate based on recent liquidity conditions (Recommended for Crypto).
Show Diagnostics: Enable this if you want to see the raw Sigma and Impact Ratios for manual calculation.
Assets:
Works best on assets with genuine volume data (Stocks, Futures, High-Cap Crypto). For Forex, it relies on Tick Volume, which is a proxy but still effective during active sessions.
Risk Disclaimer
DISCLAIMER: For Educational and Informational Purposes Only.
The content of this publication, including the source code, indicators, and commentary, is provided for educational and research purposes only. It does not constitute financial, investment, or trading advice.
No Investment Advice: The SRL Liquidity State Engine is a theoretical model based on market microstructure mathematics (Kyle, 1985; Parkinson, 1980). It is designed to visualize data, not to generate buy or sell signals.
High Risk Warning: Trading in financial markets (Cryptocurrency, Forex, Stocks, Futures) involves a high degree of risk and may not be suitable for all investors. You could lose some or all of your initial investment.
Past Performance: Historical results, back-testing, or case studies shown in this publication are not indicative of future performance.
Limitation of Liability: The author uses this software at their own risk. The author shall not be held liable for any direct, indirect, incidental, or consequential damages resulting from the use or inability to use this script or the data it provides.
By using this script, you acknowledge that you are solely responsible for your own trading decisions and have conducted your own due diligence.
Why 90% of traders misunderstand the relationship between Volume, Volatility, and Price—and how the "SRL Liquidity State Engine" fixes it.
1. Introduction: The Linear Fallacy
Every trader learns early on: "Volume precedes Price." We look at OBV, we look at volume bars, and we look at Moving Averages. But there is a fundamental flaw in how most indicators analyze volume: They assume the relationship is linear.
They assume that 1,000 contracts bought in a quiet market is the same as 1,000 contracts bought during a news event. But intuitively, we know this is false.
If price moves 1% on low volume, it suggests a vacuum (low liquidity). If price moves 1% on massive volume, it suggests a war (high liquidity). Standard indicators miss this context. They look at the fuel (Volume) without looking at the road conditions (Volatility).
This script, the SRL Liquidity State Engine, utilizes the Square Root Law (SRL) of market impact—specifically derived from Kyle’s (1985) market microstructure theories—to normalize volume against volatility. It answers the question: "What is the true intent of the market once we strip away the noise of volatility?"
2. The Theory: What is the Square Root Law?
In institutional trading and market microstructure theory, it is widely accepted that price impact is not linear; it is geometric.
The Formula:
The script is built on the inversion of Kyle’s Lambda. Roughly speaking:
$$ \Delta P \approx k \cdot \sigma \cdot \sqrt{\frac{Q}{V}} $$
By inverting this, we can solve for Q
Q (The True Intent or "Informed Order Flow"):
$$ Q = V \cdot \left( \frac{\Delta P}{\sigma \cdot k} \right)^2 $$
Where:
V: Observed Volume.
ΔP: Price Change from a pivot.
σ (Sigma): Volatility (using the Parkinson High-Low estimator).
k: An impact constant (liquidity scalar).
In simple English:
Imagine two cars.
Car A travels 100 miles using 5 gallons of gas on a smooth highway.
Car B travels 100 miles using 5 gallons of gas through a muddy swamp.
Car B worked much harder. The Square Root Law calculates this "work." It tells us that if volatility (the swamp) is high, we expect price to move more for the same volume. If price moves significantly despite high volatility (or lacks movement despite high volume), the SRL reveals the True Dominance (Q).
3. The Innovation: Under the Hood of the Engine
This script is not just a moving average crossover. It implements three advanced quantitative concepts:
A. Parkinson Volatility Estimator (1980)
Most volatility indicators use "Close-to-Close" data. This ignores the intraday fight between Bulls and Bears. This script uses the Parkinson Estimator, which utilizes the High and Low of the range. This provides a much more accurate "Sigma" (σ) for the SRL calculation, ensuring the script adapts instantly to expanding ranges.
B. Bulk Volume Classification (BVC)
Standard indicators treat a "green candle" as 100% buy volume. This is false. A doji with massive volume has both buying and selling. This script uses BVC (Easton, López de Prado, O'Hara 2012), which decomposes volume based on where the close is relative to the open and the intraday standard deviation. This gives us a granular look at Buy vs. Sell pressure.
C. Dual Anchor Analysis
The script doesn't just look at the current bar. It anchors to the most recent Pivot High and Pivot Low.
Bull Flow: Analyzes the buying pressure pushing up from the recent Low.
Bear Flow: Analyzes the selling pressure pushing down from the recent High.
By comparing the calculated Q (Intent) of these two flows, we get a Dominance Ratio.
4. Wyckoff State Detection
Mathematics is useless without context. The script translates these complex SRL calculations into the four classic Wyckoff Market States:
ACCUMULATION: Price is in the lower zone, but Bullish Q (Intent) is secretly rising. The "Smart Money" is buying the dip.
MARKUP: Price is rising, confirmed by Bullish Dominance. The trend is healthy.
DISTRIBUTION: Price is in the upper zone, but Bearish Q is secretly rising. "Smart Money" is selling into strength.
MARKDOWN: Price is falling, confirmed by Bearish Dominance. The trend is broken.
5. How to Use the Dashboard
The script projects a comprehensive data panel on your chart. Here is how to read it:
The Composite Score (Top Header)
A single number from -100 to +100.
> +60 (Green): Strong Buy / Markup Phase.
< -60 (Red): Strong Sell / Markdown Phase.
Yellow/Gray: Transition or Contested liquidity.
The Timeframes (Short / Medium / Long)
The engine analyzes three fractals simultaneously.
Alignment: When Short, Medium, and Long all show "BULL DOMINANT," the probability of a sustained trend is highest.
Divergence: If the Long term is Bullish, but the Short term flips to Bearish, the script identifies a potential Reversal Forming.
SRL vs. Sensitivity
The dashboard compares the actual price move (Sensitivity) vs. the calculated intent (SRL).
If Price is moving UP, but SRL says "Bearish," this is an Effort vs. Result anomaly—a classic signal that the move is a trap.
6. Practical Trading Strategies
Strategy A: The Trend Continuation (The "Markup" Trade)
Look for the Composite Score to cross above +30.
Ensure the Medium and Long panels show "BULL DOMINANT."
Wait for the State Analysis to confirm "MARKUP."
Stop Loss: Below the recent Pivot Low (displayed on the panel).
Strategy B: The Reversal (The "Accumulation" Trade)
Price is making lower lows (Bearish Trend).
Watch the Short Period Panel. Look for "BULL Q" to spike while price remains flat or drops slightly.
The Dashboard will signal "ACCUMULATION" or "BULLISH DIVERGENCE."
Enter when the Dominance Momentum turns positive.
7. Limitations & Disclaimer
Ranging Markets: Like all volatility-based tools, in extremely tight, low-volume chop, the denominator (volatility) becomes very small, which can exaggerate the Q values. The "Adaptive K" setting helps mitigate this, but caution is advised in flat markets.
Lag: While the Parkinson volatility is reactive, the State Analysis applies smoothing to prevent false signals. This means the "State" label may appear 1-3 bars after the absolute bottom/top.
8. Conclusion
The markets are a mechanism for price discovery, fueled by volume and restricted by volatility. By applying the Square Root Law, we stop guessing which volume spike matters and start measuring the mathematical energy behind the move.
The SRL Liquidity State Engine is designed to give you the institutional "X-Ray" view of this battle, blending rigorous microstructure math with practical Wyckoffian logic.
Settings:
Impact Constant (k): Adjusts the sensitivity. Higher k = More conservative.
Adaptive k: Check this to let the script auto-calibrate based on recent liquidity conditions (Recommended for Crypto).
Show Diagnostics: Enable this if you want to see the raw Sigma and Impact Ratios for manual calculation.
Assets:
Works best on assets with genuine volume data (Stocks, Futures, High-Cap Crypto). For Forex, it relies on Tick Volume, which is a proxy but still effective during active sessions.
Risk Disclaimer
DISCLAIMER: For Educational and Informational Purposes Only.
The content of this publication, including the source code, indicators, and commentary, is provided for educational and research purposes only. It does not constitute financial, investment, or trading advice.
No Investment Advice: The SRL Liquidity State Engine is a theoretical model based on market microstructure mathematics (Kyle, 1985; Parkinson, 1980). It is designed to visualize data, not to generate buy or sell signals.
High Risk Warning: Trading in financial markets (Cryptocurrency, Forex, Stocks, Futures) involves a high degree of risk and may not be suitable for all investors. You could lose some or all of your initial investment.
Past Performance: Historical results, back-testing, or case studies shown in this publication are not indicative of future performance.
Limitation of Liability: The author uses this software at their own risk. The author shall not be held liable for any direct, indirect, incidental, or consequential damages resulting from the use or inability to use this script or the data it provides.
By using this script, you acknowledge that you are solely responsible for your own trading decisions and have conducted your own due diligence.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.