Tick Delta Estimator
Order flow delta - how much of recent volume was buyer-initiated versus seller-initiated - is a genuinely useful signal, and it is also something retail Forex feeds cannot give you directly. Exchange-grade order flow needs every trade tagged with the side that crossed the spread. Both platforms give you a bid stream and a TICK count, never real traded lots or contracts, and there is no side flag anywhere in the data. This header uses the best available substitute: the tick rule from Lee and Ready's 1991 paper on inferring trade direction from quote data. An uptick is scored as buyer-initiated, a downtick as seller-initiated. The detail most naive implementations get wrong is what happens on an unchanged price - the textbook-correct answer is to inherit the PREVIOUS tick's sign, not to score it as neutral, because a flat print immediately after a strong move is far more likely to be a continuation than a genuine pause. Each classified tick or bar is then weighted by its tick volume as an activity proxy, giving a cumulative delta that tracks accumulating one-sided pressure over time even though no individual value is a certified trade side. Two ways to use it are provided. TickDeltaBarSeries runs the tick rule over a chunk of bar history in one call, comparing each bar's close to the prior bar's close and weighting by that bar's tick volume - useful for a quick historical read or for feeding a study. TickDeltaUpdate maintains a small running state one price/volume observation at a time, meant to be called from OnTick so an EA or indicator can track delta live without rescanning history on every tick. The demo runs both over the same data and shows their cumulative totals agree, because both are the same tick rule walked in the same chronological order - the incremental form exists purely for live use, not as a separate estimate. Every function in this header is pure computation over caller-supplied doubles and longs - no order, position or price-series API is called anywhere in it - so the MQL5 port is the identical algorithm on both platforms; only what a caller passes in for "tick volume" differs, covered below. Notes and limitations - This is an APPROXIMATION built from bid-side price direction and tick counts, not real trade-by-trade order flow. Two different retail brokers feeding the same symbol can and will produce different tick streams and therefore different delta values - this is a directional proxy for your own feed, not a comparable market-wide statistic. - Tick volume (Volume[] on MQL4, CopyTickVolume() on MQL5) is a tick count, not traded lots or contracts on either platform. Weighting by it approximates activity, not the actual size that changed hands. - The bar-series function classifies once per bar using close-to-close direction, not every tick inside the bar. It is intentionally a coarser, fast historical read; use the incremental API on live ticks for finer resolution. - The very first observation fed to a fresh state (or the oldest bar in a batch series) has nothing to compare against and contributes zero. - Pure computation, no chart or trade calls - safe to call from a script, indicator or expert with no side effects, on either platform. - Identical limitations on both platforms.
Script · MT5 · v1.0 · Free
About Tick Delta Estimator
Tick Delta Estimator is a script for MetaTrader 5. It has 2 settings, such as Bars to use and Bars to print. MQL source code included.
Files in the download: TickDeltaEstimator.mq5.mqh, TickDeltaEstimator.txt, TickDeltaEstimatorDemo.ex5, TickDeltaEstimatorDemo.mq5.
Settings
| Setting | Default | What it does |
|---|---|---|
| Bars to use | 200 | how many bars of history to analyse |
| Bars to print | 10 | most recent bars to print in the table |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Volume · Buy/Sell Arrows · MT5 Script · MQL5 Source Code