Price Impact Lambda Estimator
Kyle's lambda is a classic market-microstructure measure of price impact: how much price moves for a given amount of signed order flow. It is estimated as the slope of a linear regression of price change on net signed volume over a series of observation windows - a steeper slope means the same amount of one-sided flow pushes price further, i.e. the market absorbs size poorly. The original model needs signed trade volume: which side (buyer- or seller-initiated) each trade belongs to. MetaTrader 4 has no trade- level data at all, let alone signed volume, so this indicator builds a standard tick-rule proxy instead: each bar's tick volume is signed by that bar's own close-to-close direction (an up bar contributes +tick volume to the flow sum, a down bar contributes -tick volume). Summed across a short window (InpFlowWindow bars), this becomes one "signed flow" observation; the price change across the same window is its paired "price change" observation. The indicator then fits an ordinary least-squares line through the last InpRegressionCount such paired observations and plots the slope - lambda - each time a new bar closes. This is a genuine OLS regression of the real Kyle-lambda form, using an honest tick-rule substitute for signed trade volume rather than real trade-level data that MetaTrader 4 simply does not provide. A rising lambda means the symbol is currently absorbing directional flow with more price movement per unit of flow than before - a thinning-liquidity signal in the same spirit as the Amihud measure, but derived from a regression rather than a plain ratio. Notes and limitations - Signed flow is a tick-rule proxy (bar direction times tick volume), not real signed trade volume - stated above, not hidden. Lambda values are only meaningful relative to their own recent history on the same symbol, never as an absolute cross-symbol comparison. - If signed flow has near-zero variance across the fit window (a perfectly balanced tape), the regression is undefined for that bar and the line gaps rather than showing a meaningless spike. - Needs InpFlowWindow * (InpRegressionCount + 1) + 1 bars of history before it starts plotting - a large InpRegressionCount on a high timeframe can need a long chart history. - This is a diagnostic read of impact, not a trade signal generator - it does not predict direction, only how expensive flow currently is.
Indicator · MT4 · v1.0 · Free
About Price Impact Lambda Estimator
Price Impact Lambda Estimator is an indicator for MetaTrader 4. It has 3 settings, such as Flow window, Regression count and Scale. MQL source code included.
Files in the download: PriceImpactLambda.mq4, PriceImpactLambda.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Flow window | 5 | Bars per single flow/price-change observation |
| Regression count | 40 | Number of trailing observations the OLS slope is fit over |
| Scale | 100000 | Multiplier so lambda prints in a readable range |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the indicator from the Navigator onto a chart and adjust the settings.
Tags: Volume · Trailing Stop & Break-even · MT4 Indicator · MQL4 Source Code