OPEN-SOURCE SCRIPT
Actualizado ZigZag MT5

ZigZag MT5 — 1:1 Port
A faithful port of the MetaTrader 5 standard ZigZag indicator to Pine Script v6. Same algorithm, same parameters, same output — just on TradingView.
Parameters (MT5 defaults):
Depth (12) — minimum bars between extrema; the lookback window for the Lowest/Highest scan
Deviation (5) — minimum price deviation in points (uses syminfo.mintick) before a new extremum is accepted
Backstep (3) — minimum bars between adjacent pivots; cleans up clustered extrema
How it works:
Mirrors MT5's two-buffer approach (ExtHighBuffer / ExtLowBuffer). For each bar it runs the Lowest/Highest scan, applies the deviation filter, removes weaker neighboring pivots within the backstep window, and finally alternates highs and lows in a second pass — including outside-bar handling.
Note: Like every ZigZag, the last segment repaints until a new opposing pivot is confirmed. By design.
Useful as a drop-in replacement if you're migrating strategies from MT5 to TradingView and need pivot points that match exactly.
A faithful port of the MetaTrader 5 standard ZigZag indicator to Pine Script v6. Same algorithm, same parameters, same output — just on TradingView.
Parameters (MT5 defaults):
Depth (12) — minimum bars between extrema; the lookback window for the Lowest/Highest scan
Deviation (5) — minimum price deviation in points (uses syminfo.mintick) before a new extremum is accepted
Backstep (3) — minimum bars between adjacent pivots; cleans up clustered extrema
How it works:
Mirrors MT5's two-buffer approach (ExtHighBuffer / ExtLowBuffer). For each bar it runs the Lowest/Highest scan, applies the deviation filter, removes weaker neighboring pivots within the backstep window, and finally alternates highs and lows in a second pass — including outside-bar handling.
Note: Like every ZigZag, the last segment repaints until a new opposing pivot is confirmed. By design.
Useful as a drop-in replacement if you're migrating strategies from MT5 to TradingView and need pivot points that match exactly.
Notas de prensa
- fine tune to match exact algo in mt5Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.