Watch how to download trading robots for free
Find us on Telegram!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Indicators

Auto Fibonacci Retracement Swing Levels - indicator for MetaTrader 5

Cristhian Alexander Gaibor Cuasquer
Cristhian Alexander Gaibor Cuasquer
  • Founder & Systems Engineer at  Xander Pro
  • Ecuador
  • 7440
4.9 (36)
Trader and MQL5 member since 2017.
Views:
84
Published:
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

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.

Auto Fibonacci Retracement drawing the levels of the last completed swing leg with the 61.8 level highlighted on a MetaTrader 5 chart

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

Changelog

  • v1.0 - 2026-10-25 - Initial release
Forex Session Boxes London New York Asia Forex Session Boxes London New York Asia

Forex session boxes for Gold (XAUUSD), forex and any symbol: draws the Asian, London and New York sessions with their high and low extended to the right and the range in points, in your broker server time. Open source code.

JAFX Advanced SMC (Smart Money Concepts) JAFX Advanced SMC (Smart Money Concepts)

An all-in-one Smart Money Concepts (SMC) indicator that automatically identifies Swing & Internal Market Structure (BOS/CHoCH), Order Blocks, Premium/Discount zones, and Equal Highs/Lows. It features a real-time multi-timeframe bias dashboard to help traders make informed decisions.

Accelerator Oscillator (AC) Accelerator Oscillator (AC)

The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.

MACD Signals MACD Signals

Indicator edition for new platform.