ZigZag With Percentage Labels
Reading swing size off a plain zigzag line means eyeballing distances on the chart, which is slow and imprecise across a busy session. This version does that arithmetic for you and writes it next to each leg: pips, percent move, and how many bars the leg took to form. The one design decision worth stating plainly: the most recent swing point - the forming leg - is deliberately left unlabelled. The classic zigzag algorithm can still relocate that point as new bars arrive; the low it currently sits on might not be the eventual low of that swing. Labelling a number that can silently change later would be worse than showing no number at all, so the line still extends to that point but no pips/percent text is drawn until a later swing confirms it is done moving. Because the algorithm is a full backward-looking recompute rather than an incrementally patchable one - a new extreme can retroactively erase several recent swings - it recalculates the whole visible history once per closed bar rather than trying to patch state forward. That cost is fine at this frequency; it does not run per tick. Notes and limitations - The forming (most recent) swing point is intentionally never labelled - see the full description. It can still move as new bars arrive; treat its position as provisional until a later, labelled leg appears past it. - Recalculation happens once per closed bar, not per tick, so intrabar price action does not shift the zigzag until the bar closes. - Needs at least InpDepth * 2 bars of history before it produces anything. - At least three confirmed swing points are required before the first leg gets labelled - the very last leg into the newest swing is always the forming one and stays unlabelled by design. - No alerts - this is a charting and measurement tool only.
Indicator · MT4 · v1.0 · Free
About ZigZag With Percentage Labels
ZigZag With Percentage Labels is an indicator for MetaTrader 4. It has 6 settings, such as Depth, Deviation and Backstep. MQL source code included.
Files in the download: ZigZagLabels.ex4, ZigZagLabels.mq4, ZigZagLabels.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Depth | 12 | Depth: bars to look back for a swing |
| Deviation | 5 | Deviation, points: minimum reversal size |
| Backstep | 3 | Backstep: minimum bars between swing points |
| Show labels | true | Show pips / percent / bar-count label per leg |
| Label color | clrDimGray | Label text colour |
| Label font size | 8 | Label font size |
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: ZigZag · Trading Sessions · MT4 Indicator · MQL4 Source Code