Anchored VWAP Bands Signals
- Indicadores
-
Allan Aparece Ninal
Desenvolvo indicadores e Expert Advisors para o MetaTrader 5.
Como trabalho:
- Cada indicador é verificado quanto a repintura: os sinais são decididos apenas em barras fechadas, e um teste tick a tick confirma que não mudam depois. - Versão: 1.0
Anchored VWAP Bands Signals is a free indicator for MetaTrader 5. It draws the volume-weighted average price (VWAP) from the last confirmed swing, from the day, week or month open and from a line you drag, with a band of standard deviations around each line. Every value is written when a bar closes and never changes afterwards. Attach it to a chart, or watch it on history in the Strategy Tester's visual mode.
It draws and alerts. It does not trade. It shows where the average price paid sits since an 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, and the Volume input can use it on a symbol that reports it.
The lines show where the average price sat. They do not say that price will react there.
What you see on the chart
- 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. The VWAP from that swing starts then. A small dot marks the swing bar.
- A second line runs from the open of the day (or week, or month). It restarts at every new period.
- A third line starts at the bar where you put a dashed vertical line. Drag the line to move the anchor.
- Each line has a dotted band above and below it, 1 SD by default.
- The bar that brings a new anchor stays empty, so a new line never joins the old one.
- The name and price of each line sit at its right end, and a pill at the bottom left says which lines are running.
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 5, in the chart window |
| Draws | 3 VWAP lines (last swing, period open, drag line), 1 band pair on each, anchor dots, line labels |
| 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. |
| Alerts | Close crosses a VWAP; the bar's high or low reaches a band. Pop-up, sound, push, e-mail. Closed bars only. |
| Trades | No. It places no orders. |
| Volume | Tick volume (real volume when the symbol reports it, if you choose it) |
| 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.
- Wait for the first swing to be confirmed. The first line appears 5 bars after it.
- Choose the period for the second line: day, week or month.
- Drag the dashed vertical line to a bar you care about, such as a news candle. The third line restarts there.
- Change "Band" if you want 2 SD instead of 1 SD.
- Switch on the alerts you want in the Alerts group.
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. The first line uses the most recent swing of either side.
- Period open: the first bar whose day (from "Day starts at" hour), week (from Sunday 00:00), month differs from the bar before. The first period of the history is skipped, because its true open is not in the data.
- 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.
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.
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, or real volume if the symbol reports it. Real volume is untested. |
| Anchor 3: the drag line | true | Switch the drag line on or off. |
| Drag line time | 0 | 0 puts the line 60 bars back. Drag the line to move it. |
| Anchor 1: the last confirmed swing | true | Switch the swing line on or off. |
| Anchor 2: the open of a period | true | Switch the period line on or off. |
| Period of anchor 2 | Day open | Day, week or month open. |
| Day starts at this hour | 0 | Server-time hour at which a day (and so the day anchor) starts, 0-23. |
| Band | 1.0 | Standard deviations from the VWAP (0.5-4). |
| Draw the band | true | Draw the dotted band lines. The buffers are always filled. |
| Mark each anchor bar | true | A small dot on the anchor bar. |
| Anchors marked per line | 8 | How many of the latest anchors get a dot (1-30). |
| Name and price at the right end of each line | true | Labels. |
| Status pill | true | The line at the bottom left. |
| 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. |
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). Fifteen buffers, five per line. The forming bar stays empty. Read from shift 1.
| Buffer | Content |
|---|---|
| 0 / 1 / 2 | Swing line: VWAP, upper band, lower band |
| 3 | Swing line: the close crossed the VWAP on this bar: 1 up, -1 down |
| 4 | Swing line: the band was reached: 1 upper, 2 lower, 3 both |
| 5 - 9 | The same five values for the period line |
| 10 - 14 | The same five values for the drag line |
How it was checked
- Values: compared with an independent Python version of the rules, on broker history. 16 files (EURUSD and XAUUSD, M15 and H1, 4 input settings) held 23,594,340 buffer values and 643,282 cross and band events. There were 0 differences, within a relative 1e-9.
- Repaint: 6 Strategy Tester runs with every tick. 31,674 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: Strategy Tester runs on the 5 symbol and timeframe pairs of the Market validator (EURUSD H1, XAUUSD D1, GBPUSD M30, EURUSD M1, GBPJPY H4), with 100 and 1,000 USD deposits: 10 runs, 0 error lines, highest memory use 230 MB.
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, 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.
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 4 version? Yes, Anchored VWAP Bands Signals MT4, with the same rules.
Try it first
It is free. Attach it to a chart on a demo account, or run it in the Strategy Tester in visual mode on history. Check where each line starts against the bars.
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 | 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 | 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. |
| Character Band | Add it to the same chart. | It marks structure breaks and a trend band. Use it to see which swings the lines start from. |
Related products
- Anchored VWAP Bands Signals MT4: the same indicator for MetaTrader 4.
- 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.
