Anchored TWAP From Clicked Bar
Most "anchored VWAP" indicators on forex charts are quietly weighting by tick count, not traded volume, because MetaTrader 4 never receives a consolidated volume tape from a forex broker - there is no single exchange tape to consolidate. Calling that a VWAP is misleading. This indicator does the honest version instead: a time-weighted average price, where every bar between the anchor and the current bar contributes equally, because on a single timeframe every bar covers the same wall-clock duration. The anchor point is set by dragging a dashed vertical line, the same interaction as a standard anchored VWAP tool - click a swing low, a news candle, a session open, wherever the trader wants the average to start from. Dragging a chart object does not generate a new price tick, so the recalc is triggered explicitly from OnChartEvent() on the drag (and the object edit-end event some builds send instead), then ChartRedraw() forces an immediate update rather than waiting for the next tick. The recalculation only ever walks from the anchor bar to the current bar, never the whole chart history, and only clears the specific range of bars vacated when the anchor moves forward - both bounded by how far back the anchor sits, which is the right cost for a tool whose entire purpose is a trader-chosen window. Notes and limitations - Deliberately time-weighted, not volume-weighted. If a genuine VWAP is needed on an instrument where the broker's tick volume is a reasonable proxy for activity (indices, some CFDs), that is a different tool - this one exists specifically for the honest case where it is not. - The anchor is stored only as a chart object, so it resets to the default position whenever the indicator is removed, the timeframe changes, or the terminal restarts. It is a charting aid for the current session, not a saved setting. - If the anchor line is deleted, it is recreated automatically at the default position the next time the indicator recalculates. - Assumes roughly constant bar duration between the anchor and the current bar. Weekend and session gaps mean the true elapsed wall-clock time is not perfectly uniform, but the per-bar weighting is the standard, honest approximation given no better time resolution is available per bar.
Indicator · MT4 · v1.0 · Free
About Anchored TWAP From Clicked Bar
Anchored TWAP From Clicked Bar is an indicator for MetaTrader 4. It has 1 setting, such as Default bars back. MQL source code included.
Files in the download: AnchoredTwap.ex4, AnchoredTwap.mq4, AnchoredTwap.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Default bars back | 50 | Bars back from the current bar for the initial anchor position |
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: VWAP · Volume · MT4 Indicator · MQL4 Source Code