Anchored VWAP Bands Scanner MT4
- Indicatori
-
Allan Aparece Ninal
Sviluppo indicatori ed Expert Advisor per MetaTrader 5.
Come lavoro:
- Ogni indicatore viene controllato contro il repainting: i segnali vengono decisi solo su barre chiuse, e un test su ogni tick conferma che non cambiano in seguito. - Versione: 1.0
- Attivazioni: 10
Anchored VWAP Bands Scanner MT4 is a paid indicator for MetaTrader 4. It draws the volume-weighted average price (VWAP) from up to nine anchors at once: the last swing high and low, the day to year open, the last structure break, the last swing of a higher timeframe and up to four lines you drag. Each line has bands at 1, 2 and 3 standard deviations. It adds pinch and confluence detection, a stretch-and-return alert, a dashboard, and a scanner of other symbols against the VWAP of their last swing. Run the free demo in the Strategy Tester on your own symbol before you decide.
It draws, marks and alerts. It does not trade. It shows where the average price paid sits since each anchor. It is not a signal system and it promises no profit. The section How it was checked shows what was tested and what was not.
Standalone: everything is built in. You do not need to buy or install any other product named on this page.
In plain words
The VWAP is the average price of a period, weighted by volume. A bar with more volume pulls the average toward its price more than a quiet bar does. An anchored VWAP starts the average at a bar you choose and keeps going from there.
Why anchor it? The average then answers a clear question: where is the average price paid since that bar? A swing high or low, the open of a day and a structure break are common starting points, because many traders watch them.
Around the line the indicator draws bands. A band is a number of standard deviations (SD) above and below the VWAP. The SD is the volume-weighted spread of the prices since the anchor, so the bands widen when price has moved a lot since it.
Forex has no central volume. The indicator uses tick volume: the number of price changes in each bar. It is a proxy for activity, not a count of traded contracts. Real volume exists only on exchange symbols.
The lines show where the average price sat. They do not say that price will react there.
What you see on the chart
- Up to nine anchors can run at the same time, each in its own colour: swing high, swing low, the open of a day (week, month, quarter or year), the last structure break, the last swing of a higher timeframe, and up to four manual lines. Four run by default (swing high, swing low, day open, one drag line), so a new chart stays quiet.
- A swing is confirmed when the bars on each side of it are lower (high) or higher (low). With the default size of 5 it is known 5 bars after it, and the line starts then. A small dot marks the swing bar.
- A structure break is a close beyond the last unbroken swing. The anchor is the swing that was broken, or the bar that broke it. You can use breaks with the trend (BOS), against it (CHoCH), or both.
- A manual line is a dashed vertical line you drag. The VWAP restarts at the bar it sits on. Moving it recalculates that one line, by your hand.
- The higher-timeframe line anchors at the last swing of candles of another timeframe (H4 by default). The candles are built from this chart's own bars, so no other timeframe is read.
- Each line has dotted bands at 1 SD and dashed bands at 2 SD. The 3 SD bands are off by default. A depth fill tints the area inside the bands of one line, darker near the VWAP.
- At the right end of each line a label shows its price, the distance in points, the distance in SD and the age of the anchor in bars. The newest anchor of each line gets a dot, a dashed stem and an age label. Older anchors are paler.
- Dashboard rows at the bottom left show the bias (how many lines are below and above price), the nearest line, the pinch state and the confluence.
- The pinch is the space between the swing-high and swing-low lines when price sits between them and the gap is narrowing. It is a place to watch for a decision, not a direction. It resolves on a close beyond one of the two lines.
- A confluence box marks where two or more lines sit within half an ATR(14) of each other.
- The bar that brings a new anchor stays empty, so a new line never joins the old one.
- A scanner panel lists other symbols and timeframes with the close in SD units from the VWAP of their last swing.
Worked example
EURUSD H1, default inputs, taken from the test dump of this indicator (broker history, server time). A swing low is confirmed on 2018-11-05 19:00 and anchors the first line at 2018-11-05 14:00. On the closed bar 2018-11-05 20:00 the VWAP is 1.13898 and 1 SD is 0.00151. The band lines are therefore 1.14049 and 1.13747. The bar closed at 1.14216.
Key facts
| Item | Detail |
|---|---|
| Type | Indicator for MetaTrader 4, in the chart window |
| Draws | Up to 9 VWAP lines, bands at 1, 2 and 3 SD, depth fill, labels with price, distance, SD and age, anchor markers, dashboard rows, confluence box, a scanner panel |
| Formula | VWAP = sum(price x volume) / sum(volume) from the anchor bar. Price is the typical price (high + low + close) / 3 by default. |
| When a value is final | When its bar has closed. The forming bar is always empty. |
| Swing delay | A swing is known "Swing size" bars after it (5 by default). The line starts then and is never moved back. |
| After a reload or timeframe change | The same closed bars give the same values. Old crossings send no alerts. The manual line stays where you left it. |
| Alerts | Close crosses a VWAP; the bar's high or low reaches a band; stretch and return (a close beyond a band, then back inside); the pinch resolves; a close crosses the VWAP in the scanner. Pop-up, sound, push, e-mail. Closed bars only. |
| Trades | No. It places no orders. |
| Volume | Tick volume |
| Other products needed | None |
| Tested on | EURUSD and XAUUSD, M15 and H1 (plus the validator pairs) |
Quick start
- Attach the indicator to any chart. The defaults work without optimising.
- Four lines run at first: swing high, swing low, the day open and one drag line. Switch on the structure-break and higher-timeframe lines in the Anchors group if you want them.
- Set "Drag lines" (0 to 4) and drag each dashed line to a bar you care about, such as a news candle. The line restarts there.
- Switch on the 3 SD bands if you want them, and choose which band raises the touch alert.
- Open the scanner list: Market Watch or your own symbols and timeframes. Click a cell to open that chart.
Who it is for
Traders who use an average price as a reference: intraday traders who watch the day open, swing traders who anchor to a turning point, and anyone who wants to see how far price has moved from the average. It is a drawing tool. It is not for someone who wants an automatic buy and sell signal.
How it works under the hood
The VWAP and the bands
From the anchor bar to the last closed bar, the indicator keeps a running volume-weighted mean (the VWAP) and a running weighted sum of squares. The update is the stable weighted form: W += v; d = p - m; m += d x v / W; M2 += v x d x (p - m). The SD is the square root of M2 / W. It is the volume-weighted population SD of the price. A bar with no volume adds nothing. The bands are the VWAP plus and minus k x SD.
The price p is the typical price by default. You can choose the close, the median (high + low) / 2, or (open + high + low + close) / 4.
Anchors
- Swing: bar p is a swing high if each of the "Swing size" bars on its left has a lower high and each on its right a high not above it. A swing low is the mirror. It is known at bar p + size. Swing high and swing low have a line each.
- Period open: the first bar whose day (from "Day starts at" hour), week (from Sunday 00:00), month, quarter or year differs from the bar before. The first period of the history is skipped, because its true open is not in the data.
- Structure break: a close beyond the newest unbroken swing high (up) or low (down). It is a CHoCH when the break before it went the other way, otherwise a BOS. The engine is the structure engine of Character Band, unchanged. The anchor is the broken swing's bar or the break bar.
- Higher timeframe: candles of the chosen timeframe are built from the chart's closed bars. A candle is complete on the bar whose next bar opens in another candle. A swing of "Higher-timeframe swing size" candles is known that many candles later, and the anchor is the first chart bar that made the candle's extreme. The first candle of the history is partial and is skipped. The chart timeframe must be below the chosen one.
- Drag line: the bar that holds the time of the dashed vertical line (the last bar whose open time is not after it). Before that bar closes, the line has no value. Pro has up to four.
One empty bar
A line shows a value on the bar that brings a new anchor only if it had no value on the bar before. Otherwise that one bar stays empty. This stops the new line from being joined to the old one by a slanted stroke. It also means a new swing line starts one bar after the swing is known.
Events
Cross: the close of a bar is above the VWAP and the close before was at or below it (or the mirror). Both bars must show a value. Equal to within 1e-9 counts as at the line. Band reached: the bar's high is at or above the upper band, or its low at or below the lower band, and the bar before did not already reach it. A band of 0 SD (one bar of data) gives no event.
Stretch and return, pinch, confluence
Stretch and return: a close beyond the stretch band (2 SD by default) is a stretch. The first later close back inside the band raises the event: 1 after a stretch above, -1 after a stretch below. A new line starts with no memory.
Pinch: both swing lines show a value, the close is between them, and their gap is smaller than on the bar before. It resolves on the first close beyond the upper line (1) or the lower line (-1) after a bar where it was active.
Confluence: the largest group of lines whose values lie within 0.5 x ATR(14) of each other, at least two. When groups tie, the one nearest the close wins. The buffers hold the number of lines, the low and the high of the group.
Options
The band multipliers are editable, with a Fibonacci preset (1.618, 3.236, 4.854). Equal weight ignores volume, so every bar counts the same: use it where tick volume is poor. The real-volume option reads the symbol's real volume where the broker reports it. It is untested, because the broker data used for the tests has none.
Scanner
For each symbol and timeframe the scanner reads the last "Closed bars the scan reads" bars (1,000 by default), finds the last confirmed swing of either side and computes the VWAP from it. The cell shows (close - VWAP) / SD of the last closed bar, for example +1.4 SD. A cell is tinted green when the close is above the upper band, red when it is below the lower band, and grey in between. An x marks a close that crossed the VWAP on the last bar. The scanner uses band 1 for the tint.
Inputs
| Input | Default | What it does |
|---|---|---|
| Swing size | 5 | Bars on each side of a swing high or low (1-50). |
| Price | Typical | Typical, close, median or average (OHLC/4). |
| Volume | Tick volume | Tick volume only in this version. |
| Equal weight | false | Ignore volume: every bar counts the same. |
| Anchor: swing high / swing low | true / true | Two switches. |
| Anchor: the open of a period | true | Switch the period line on or off. |
| Period | Day open | Day, week, month, quarter or year open. |
| Day starts at this hour | 0 | Server-time hour at which a day (and so the day anchor) starts, 0-23. |
| Anchor: the last structure break | false | Switch the line on or off. |
| Structure breaks that anchor | BOS and CHoCH | Both, CHoCH only, or BOS only. |
| Anchor bar of a break | The broken swing | The swing that was broken, or the bar that broke it. |
| Anchor: the last swing of a higher timeframe | false | Switch the line on or off. |
| Higher timeframe | H4 | Must be above the chart timeframe. |
| Higher-timeframe swing size | 3 | Candles on each side (1-20). |
| Drag lines | 1 | 0 to 4 dashed vertical lines, each with its own VWAP. |
| Drag line 1 / 2 / 3 / 4 time | 0 | 0 puts line k at 60 x k bars back. Drag a line to move it. |
| Multipliers | My multipliers | Or the Fibonacci preset 1.618 / 3.236 / 4.854. |
| Band 1 / 2 / 3 | 1 / 2 / 3 | Standard deviations (0.5-6). |
| Draw band 1 / 2 / 3 | true / true / false | Which bands are drawn. The buffers are always filled. |
| Band used by the touch alert | 1 | 1, 2 or 3: which band raises the alert and fills the touch buffer. |
| Band used by the stretch-and-return alert | 2 | 1, 2 or 3. |
| Mark each anchor bar | true | A dot on each anchor bar; the newest also gets a dashed stem and an age label. |
| Anchors marked per line | 6 | How many of the latest anchors get a dot (1-30). |
| Name and price at the right end of each line | true | Labels with price, distance in points, distance in SD and anchor age. |
| Dashboard rows | true | Bias, nearest line, pinch, confluence, status. |
| Depth fill of one line | The most recent swing line | Off, or choose the line. Drawn for the last bars only. |
| Bars the fill covers | 100 | 20-300. Each bar is one small rectangle, so keep it moderate. |
| Older anchors paler | true | Fades the dots of older anchors. The lines keep their colours. |
| Colour-blind safe colours | false | Changes the green/red of the scanner rows and status pills to blue/orange. |
| Scanner: show, symbols, list, suffix, most symbols | true, Market Watch, 5 names, none, 10 | Which symbols appear (1-60). A broker suffix is found automatically. |
| Scanner timeframes | M15,H1 | Comma separated. |
| Closed bars the scan reads | 1000 | 200-5000 per cell. |
| Scanner corner, distances, font, click opens, template, colours | top left, 10, 24, 9, true | Layout and colours of the panel. |
| Debug log for bug reports | false | See Found a problem? |
| Pop-up alert | true | Alert window in the terminal. |
| Play a sound | false | Plays the sound file below. |
| Sound file | alert.wav | File from the terminal Sounds folder. |
| Push notification | true | Needs your MetaQuotes ID. |
| false | Needs e-mail set up in the terminal options. | |
| Alert: close crosses a VWAP | true | Switch. |
| Alert: the bar reaches the band | true | Switch. |
| Alert: stretch and return | true | Switch. |
| Alert: the pinch resolves | true | Switch. |
| Alert: a close crosses the VWAP in the scanner | true | Switch. |
Alerts and Expert Advisor use
Alerts. One alert per closed bar, sent when the next bar opens. The message names the line and the price, for example close 1.09130 crossed up through the Swing AVWAP 1.09100. Nothing is sent while the history loads, twice for the same bar, or in the Strategy Tester.
Buffers for Expert Advisors (iCustom). 95 buffers: 10 per anchor, anchor s from 0 to 8, base = 10 x s, then 5 shared. The forming bar stays empty. Read from shift 1.
| Buffer | Content |
|---|---|
| base + 0 | VWAP |
| base + 1 / 2 | Upper / lower band 1 |
| base + 3 / 4 | Upper / lower band 2 |
| base + 5 / 6 | Upper / lower band 3 |
| base + 7 | The close crossed the VWAP on this bar: 1 up, -1 down |
| base + 8 | The touch band was reached: 1 upper, 2 lower, 3 both |
| base + 9 | Stretch and return: 1 back inside after a close above the stretch band, -1 after a close below it |
| s = 0 to 8 | 0 swing high, 1 swing low, 2 period, 3 structure break, 4 higher-timeframe swing, 5 to 8 drag lines 1 to 4 |
| 90 / 91 | Pinch active (1) / pinch resolved (1 up, -1 down) |
| 92 / 93 / 94 | Confluence: lines in the group / group low / group high |
How it was checked
- Values: compared with an independent Python version of the rules, on broker history. 20 files (EURUSD and XAUUSD, M15 and H1, 3 input settings) held 51,595,925 buffer values and 526,147 cross and band events. There were 0 differences, within a relative 1e-9.
- Scanner cells: 0 cells computed in the terminal were compared with the same rules in Python: 0 differences.
- Repaint: 20 Strategy Tester runs with open prices only. 532,105 closed bars were compared with the values read when they closed. 0 changed after the close, and 0 values appeared on the forming bar.
- Error check: mt4 tester log lines 1035, finished runs 115, error lines 0. Same indicator source as the MT5 edition, compiled with the MT4 compiler.
Trading-rule test: I have not tested these lines as a trading rule, and I make no claim that price reacts at them. The VWAP and its bands describe where price traded. They do not predict where it goes.
Not tested: alerts on a live chart (the tester is silent for alerts), real volume on a symbol that reports it, dragging the manual line on a live chart, and the MQL5 Market validator itself.
Limits
- Forex volume is tick volume. It counts price changes, not traded contracts, and it differs between brokers. Real volume exists only on exchange symbols.
- A swing is known only after the swing size has passed, so a swing line starts late by design. It is never moved back.
- The first period of the history and the first higher-timeframe candle are skipped, because their true start is not in the data.
- The period line needs a chart timeframe below the period. On D1 a day anchor shows nothing, and the pill says so.
- Day, week and month edges follow server time. Another broker's server time gives other anchors and other lines.
- It gives no stop loss, target or lot size.
- The history is read in full when the chart loads. On a very long history the first calculation takes a moment.
- Alerts need the terminal to be running with the chart open.
FAQ
Does it repaint? No value changes after its bar has closed. A new swing starts a new line from the bar after it is known; it does not redraw an old line. Dragging the manual line recalculates that one line, because you moved its anchor.
What happens if I change the timeframe or reload the chart? The indicator reads the closed bars again and gives the same values for the same history and inputs. On another timeframe the bars differ, so the lines differ.
Why does a line start a few bars after the swing? The swing is only known once the bars on its right side have closed. The dot sits on the swing bar, and the line starts when the swing is known.
Why is the first bar of a new line empty? So that a new line is never joined to the old one. See One empty bar.
Is it real volume? Not on forex. It is tick volume, a proxy.
Why do my lines differ from another tool? The anchor, the price type, the volume source and the SD rule change the result. This page states each rule so you can compare.
Can an Expert Advisor read it? Yes. Read the buffers listed under Alerts and Expert Advisor use, from shift 1.
Is there a MetaTrader 5 version? Yes, Anchored VWAP Bands Scanner, with the same rules.
Try it first
Run the free demo in the Strategy Tester in visual mode on your own symbol and timeframe. Check the anchors, the bands and the empty bar against the candles before you buy. The scanner works on live symbols, not in the tester.
Works well with
These are workflow suggestions. I have not found that any pair gives better trading results. You do not need any of them.
| Product | How to use them together | Why |
|---|---|---|
| Session Levels MT4 | Add it to the same chart. | It draws session boxes and the previous day and week levels. Compare them with the day VWAP. |
| Session Value Area Profile MT4 | Add it to the same chart. | It shows where volume sat by price in each session. The VWAP shows the average of the same volume. |
Related products
- Anchored VWAP Bands Scanner: the same indicator for MetaTrader 5.
- Anchored VWAP Bands Signals MT4: the free edition (two anchors, one band, no scanner).
- All my products on MQL5
Custom work
Want an EA that trades this indicator, a custom version of it, several of my indicators or EAs combined into one, an EA that trades another indicator you use (mine or another developer's), or a new indicator or EA of your own? Order it through MQL5 Freelance and choose me as the developer: order through Freelance. Send your requirements, rules and the flow or algorithm you want. The whole order, payment and delivery stay inside MQL5 Freelance.
Found a problem?
- In the inputs, set "Debug log for bug reports" to true.
- Repeat what went wrong.
- Open the Experts tab in the Toolbox. Copy the lines that start with "DBG" and paste them in a comment on this page, with the symbol and timeframe.
- Set the debug log back to false.
The debug lines never contain your account number, name, server, balance or equity.
If you find it useful, a short review on this page helps other traders find it.
Questions: use the comments on this page or send me a message on MQL5.
Trading involves risk of loss. Backtest results do not predict future results.
