Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

Metatrader 5 Indicator | Auto Fibonacci Retracement Swing Levels | Free Download

Fresh MQL5 code release – perfect for enhancing your MT4/MT5 strategies.

Fibonacci retracement on Gold (XAUUSD), forex and any symbol, drawn by the indicator on the last completed leg. It looks for confirmed swings, a high or a low with a set number of lower or higher bars on each side, and takes the two most recent ones as the leg.

When the low came first the leg is up and the levels are measured down from the high. When the high came first the leg is down and they are measured up from the low. You get 23.6, 38.2, 50, 61.8 and 78.6, the 61.8 in its own colour, and the price of each level next to the line. The 127.2 and 161.8 extensions are optional.

A swing needs closed bars on its right side before it counts, so the leg changes only when a new swing is confirmed. The levels are a map, not a signal, and the indicator does not trade.

Reduce lag and improve accuracy with the NonLagMA Expert Advisor for MT4/MT5. Discover it.

Image for Auto Fibonacci Retracement Swing Levels

Settings

Swings

  • Swing length (10): bars on each side of the swing candle. Lower values follow small legs, higher values keep only the big ones.
  • Bars to analyze from the right (600).
  • Use the last completed leg (true): off, it draws from the highest high to the lowest low of those bars.

Levels

  • Show 23.6, 38.2, 50.0, 61.8 and 78.6 (true).
  • Show the 127.2 extension and Show the 161.8 extension (false).

Display

  • Colour when the leg goes up, Colour when the leg goes down and Colour of the 61.8 level.
  • Line width (1), Line style (dot) and Extend the levels to the right (20 bars).
  • Show the price of each level (true), Font and Font size (8).

Alerts

  • Alert when price touches the 61.8 level (false), with Pop-up alert and Sound alert. It fires once per bar at most.

Indicator settings

  • Object prefix (XP_FIB_): change it to run two copies, for example swing 5 and swing 20 on the same chart.

What it needs

  • MetaTrader 5, any symbol and any timeframe.
  • It recalculates the leg once per new bar. The alert check runs on every tick.
  • Three hidden buffers for EAs: swing high (0), swing low (1) and direction (2, 1 up and -1 down), filled on the last bar. Read them with iCustom and CopyBuffer.

Make it yours

Put it on XAUUSD, EURUSD, GBPUSD, US30 and NAS100 from M15 to H4 and compare swing 5 against swing 20: the same chart gives two very different legs. The 61.8 and 78.6 zone is where many traders wait for a pullback entry, so it pairs well with support and resistance or with a Smart Money Concepts order block. In an EA, read the direction buffer and the swing high and low, then build your own entry on the retracement. For structure breaks, add my Smart Money Concepts BOS CHoCH.

About this code

Open source. Use it as it is, adapt it, build your own version on top of it.

New versions and new tools are announced first on my MQL5 channel: https://www.mql5.com/en/channels/xander

Questions, suggestions and your own backtests are welcome in the Xander Lab group: https://www.mql5.com/en/messages/02eec85e4364dd01

More tools on my profile: https://www.mql5.com/en/users/09151993a

Provided as is, use at your own risk.

Related

  • Smart Money Concepts BOS CHoCH
  • Supply Demand Zones
  • Forex Session Boxes

Changelog

  • v1.0 - 2026-10-25 - Initial release

Thanks for reading. Discover premium MetaTrader solutions at RobotFX.

79228

Best MetaTrader Indicators + Profitable Expert Advisors