Loading…

Mark Swing Highs And Lows

Manually marking swing points for structure analysis - higher highs, lower lows, the last significant pivot - is repetitive and error prone across any real stretch of history. This script applies the classic fractal definition (a bar whose high, or low, is more extreme than a chosen number of bars on both sides) across the loaded history in one pass and labels every result with its exact price and date. The naive version of a fractal marker checks the most recent bars too, and those markers move or vanish as new bars form, because a swing that close to the current bar has not actually been confirmed yet. This script deliberately skips that window entirely: a swing is only ever marked once enough newer bars exist on both sides of it to genuinely confirm it, so what gets drawn does not repaint as the chart updates. Swing highs and lows are colour coded separately and placed with a small price offset scaled in points, so the label text clears the arrow marker without needing to be dragged by hand. Notes and limitations - This is a one-off scan, not a running indicator - it does not update automatically as new bars form. Re-run the script to pick up newly confirmed swings. - Because confirmation requires InpWingBars newer bars on both sides, the most recent InpWingBars bars can never show a swing yet, by design - that is what keeps the markers from repainting. - The fractal definition used here is the plain, unfiltered classic form; it does not merge nearby swings or filter out minor ones the way a zig-zag style algorithm would.

Script · MT5 · v1.0 · Free

About Mark Swing Highs And Lows

Mark Swing Highs And Lows is a script for MetaTrader 5. It draws buy and sell arrows on the chart and can alert you with a pop-up, sound, email or push message. It has 7 settings, such as Wing bars, Lookback bars and Color high. MQL source code included.

Files in the download: MarkSwingHighsAndLows.ex5, MarkSwingHighsAndLows.mq5, MarkSwingHighsAndLows.txt.

Settings

SettingDefaultWhat it does
Wing bars2Bars required lower/higher on each side to confirm a swing
Lookback bars500How many confirmed bars back to scan
Color highclrRedSwing high marker colour
Color lowclrLimeGreenSwing low marker colour
Arrow size1Arrow object width
Label offset points100Clearance between the bar and its price/date label, in points
Cleanup firsttrueDelete this script's previous markers first

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 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: Pivot Points · Fractals · Buy/Sell Arrows · Alerts · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria