Home
Blog
What Is the ZigZag Indicator? A Practical Guide for MetaTrader 5

Content table

What Is the ZigZag Indicator? A Practical Guide for MetaTrader 5

8 hours ago

9 Minutes read

Written by Greenup24

What Is the ZigZag Indicator? A Practical Guide for MetaTrader 5

Gold pulls back several times during a rally. Which pullback matters to the broader move? The ZigZag indicator makes that question easier to answer by connecting selected highs and lows. The tricky part is the right edge of the chart. A turning point you see now may move after a few more candles.

This Greenup24 guide explains how ZigZag selects swings, what its MetaTrader 5 settings actually do, and how to test an idea without using information that would have been unavailable at the time.

What does the ZigZag indicator show?

ZigZag is a price-chart overlay that connects alternating swing highs and lows. The segment between two points is called a leg. Which price moves get a leg of their own depends on the price action and the sensitivity of the indicator.

Suppose price rises from 100 to 110, dips to 108, then climbs to 113. If the pullback from 110 to 108 fails to meet the indicator's rules for a separate swing, ZigZag may show the whole move from 100 to 113 as one rising line. The candles still show what happened within that move.

How does ZigZag calculate swings in MT5?

ZigZag checks candle highs and lows within a lookback window. In the MT5 example, Depth sets the size of that window, and Backstep helps remove weaker candidates of the same type from nearby earlier candles. The indicator connects selected highs and lows in alternating order. If a more extreme point of the same type qualifies, it can replace the endpoint of the latest leg.

A hypothetical gold example

Suppose ZigZag on the hourly XAU/USD chart connects a $2,400 low to a $2,420 high. The next segment depends on what the candles do and how the indicator is configured.

What happens on the chartHow ZigZag may respond
Gold pulls back to $2,415.If the indicator does not select a new swing low there, it draws no separate down leg.
A new qualifying high forms at $2,428.The latest rising leg can shift its endpoint from $2,420 to $2,428.
Gold drops to $2,408 and the low meets the selection rules.ZigZag can draw a down leg from $2,428 to $2,408.

The prices illustrate how the line can change. Whether the indicator selects the $2,408 low depends on the surrounding candles and the ZigZag settings.

Why does ZigZag repaint?

Repainting means fresh market data changes a point or line that the indicator already displayed. For example, a new high can move the endpoint of a rising leg to a higher price and a later candle. The last point on the MT5 ZigZag can still change after it appears on the chart.

Confirmation lag is a separate issue. A pivot may first appear several candles after the price extreme, even though the indicator draws it on the earlier candle. If a high occurred at 10:00 and only became identifiable at 10:25, a backtest that uses it for an entry at 10:00 is looking ahead. Record when the high occurred and when your rules could first use it.

ZigZag settings in MetaTrader 5

A common MT5 ZigZag example uses three inputs with values of 12, 5 and 3. These are starting values for learning how the indicator behaves. Custom versions can use different inputs or interpret them differently.

InputExample valueWhat it controls
Depth12The size of the lookback window, in candles, used to search for local extremes. A larger window generally filters out more small swings.
Deviation5A price-distance input expressed in symbol points (_Point) and used when filtering candidate extremes. This implementation does not use it as a 5% reversal threshold or as a guaranteed distance between all plotted pivots.
Backstep3The number of prior candles checked for weaker candidates of the same type. A higher high, for instance, can remove a weaker high candidate within that window.

How many points does Deviation represent in MT5?

If the XAU/USD point size is 0.01 in MetaTrader 5, a Deviation input of 5 corresponds to 0.05 price units in the sample's filtering calculation. Check the point size for the exact symbol you use. The final swing layout also depends on how the indicator selects highs and lows and on its other inputs.

How to choose a useful sensitivity

Decide what you need to see for the symbol and timeframe you trade. Mapping the broad structure of gold on H4 calls for larger swings than studying pullbacks on M15. To learn what Depth does in MT5, compare 12 and 18 over the same stretch of candles while keeping both other inputs fixed. Check which swings disappear and whether any of them matter to your analysis.

Repeat the exercise in trending and ranging conditions. If you keep changing inputs to fit each new stretch of price history, test the same values on a period you did not use to choose them.

How to add ZigZag to MetaTrader 5

  1. On MT5 desktop, open Navigator → Indicators. If ZigZag appears in Examples or elsewhere in the indicator list, drag it onto your chart.
  2. If the indicator is missing and you have the zigzag.mq5 file, use File → Open Data Folder in MT5 and place the file in MQL5/Indicators.
  3. Press F4 to open MetaEditor, open the file, and press F7 to compile it. Refresh the indicator list in Navigator, then attach ZigZag to your chart.

Three practical uses for ZigZag

1. Read trend structure

Compare swing highs with previous highs and swing lows with previous lows. Higher highs and higher lows describe a rising structure. Lower highs and lower lows describe a falling one. Repeated turns near two price areas may indicate a range. In an uptrend, a close below the last important swing low gives you a reason to review the structure. A subsequent lower high can provide more evidence that the trend is changing.

2. Map support and resistance and assess breakouts

When several swing highs cluster near the same price, mark the area as potential resistance. A cluster of lows can mark potential support. If price breaks out, watch where the candle closes and how the market behaves if it retests the boundary. A wick through the zone followed by a close back inside can be an early sign of a failed breakout.

3. Select Fibonacci anchors and inspect chart patterns

To measure a pullback in an upswing, draw Fibonacci retracement from the swing low to the swing high. Reverse the direction for a downswing. Levels such as 38.2% and 61.8% give you areas to watch for a price reaction. If your newest anchor moves, the retracement levels move with it. ZigZag can also help you select the points of a possible double top or triangle. Assess the pattern separately by watching price at the neckline or boundary.

A hypothetical EUR/USD setup, from structure to risk

Suppose the H4 chart is making higher highs and higher lows. On H1, EUR/USD breaks through resistance near 1.0850, retests it, and closes back above the zone. In this example, that close is the condition for considering an entry.

Setup detailHypothetical value
Entry1.0855
Stop below the retest low1.0825
Target near the next resistance1.0915
Entry-to-stop distance30 pips
Entry-to-target distance60 pips

The planned reward-to-risk ratio is 2:1 before costs. When testing a setup, use executable entry and exit prices and account for spread, commissions and possible slippage. Position size depends on the risk budget, stop distance and pip value. The prices here illustrate the method.

How to test ZigZag without look-ahead bias

  1. Advance one candle at a time. Use chart replay or a test feed that exposes only the data available at each step.
  2. Log the timestamps separately. Record the candle that made the high or low, when the pivot first appeared, and when the independent entry condition was met.
  3. Keep a record of changes. If the latest pivot moves or disappears, preserve the original log so you can reconstruct what you saw when you made the decision.
  4. Specify how orders are filled. If your rule waits for a candle close, use an execution assumption consistent with the first price available after confirmation.
  5. Test on fresh data. After comparing inputs on one period, keep them fixed on a second period you left out of the selection process. Review signal frequency, confirmation lag, revisions and results after costs.

Frequently asked questions

What are the best ZigZag settings?

Useful settings depend on the symbol, timeframe and purpose. For the MT5 example, start with 12, 5 and 3 and change one input at a time. For XAU/USD, check the point size of your symbol before interpreting Deviation.

Does ZigZag always repaint?

Common versions can revise the newest section. Some versions marketed as non-repainting publish points later so those points can remain fixed once displayed. Check the behavior of the version you use in replay, especially if its output feeds an Expert Advisor.

Can you use ZigZag for scalping?

It can organize short-term highs and lows. On short timeframes, confirmation lag, revisions to the newest leg and the gap between bid and ask can matter more. Test its usefulness using the prices you could have traded on your chosen timeframe.

How does the Elliott Wave zigzag differ from the indicator?

In Elliott Wave theory, a zigzag is a corrective pattern labeled A–B–C. The ZigZag indicator plots price swings that can help you choose points to examine. A valid wave count depends on Elliott Wave rules.

The takeaway

ZigZag makes the sequence of highs and lows easier to read. Check what the settings measure on your platform and give the most recent leg room to change. In your tests, record the price action that triggered the decision, the level that would invalidate the setup, and when the necessary information became available.

Great Experience with our Investors

Get Started