Loading…

Volume Profile From Bars

MetaTrader 4 does not have a built-in volume profile, and MT4 history does not carry true per-price tick data to build a perfect one from - only each bar's total tick volume and its high/low. This script builds the standard approximation every bar-based profile tool uses: each bar's volume is spread across every price bin its range touches, weighted by how much of the bar's own range falls inside each bin, rather than being dumped entirely into one bin at the close. The result is drawn as a row of horizontal bars projected to the right of the chart, each one's width proportional to its share of the busiest bin's volume - the familiar profile shape, without needing a second indicator window. The point of control (the single busiest price bin) is marked in its own colour, and the value area - the tightest band of bins around the point of control that together hold a chosen percentage of the total volume, 70% by default - is shaded separately from everything outside it, using the standard construction: expand out from the point of control one bin at a time, always taking whichever neighbouring bin has more volume, until the target percentage is claimed. Every count here is TICK volume, the number of price changes MT4 actually recorded, not real traded volume - no MT4 broker feed carries real volume, and calling it anything else would overstate what the data actually is. Notes and limitations - Volume is TICK volume, not real traded volume - no MT4/MT5 broker feed used here carries real traded volume. - The within-bar volume distribution is an approximation (uniform across the bar's own high/low range), not a reconstruction of the true intrabar trade sequence, which MT4's bar history cannot provide. - The profile is drawn as chart objects projected into empty time to the right of the last bar; it does not update live and does not move with new bars - re-run the script to refresh it. - A very short lookback with a high bin count can leave many bins with zero volume and no bar drawn for them, which is expected rather than a fault in the calculation.

Script · MT4 · v1.0 · Free

About Volume Profile From Bars

Volume Profile From Bars is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 12 settings, such as Symbol, Timeframe and Lookback bars. MQL source code included.

Files in the download: VolumeProfileFromBars.ex4, VolumeProfileFromBars.mq4, VolumeProfileFromBars.txt.

Settings

SettingDefaultWhat it does
SymbolSymbol to profile, blank = this chart's symbol
TimeframePERIOD_CURRENTTimeframe the bars are read from
Lookback bars200Most recent bars included in the profile
Number of bins30Number of price bins the range is split into
Value area percent70.0Percent of volume the value area must cover
Max profile width bars30Width, in bars, of the largest histogram bin
Show poc linetrueDraw a horizontal line at the point of control
Show value area linestrueDraw horizontal lines at the value area edges
Show labelstrueLabel the POC and value area lines
Poc colorclrRedPoint of control colour
Value area colorC'70,110,160'Value area bin colour
Outside value colorC'90,90,90'Outside-value-area bin colour

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Volume · Alerts · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria