How to code zig zag using mql4 in forex


How do you code a zigzag indicator?

1:0932:19Automatic Support/Resistance indicator using ZigZag – YouTubeYouTubeStart of suggested clipEnd of suggested clipFirst. So first i want the inputs to the zigzag indicator itself and these are exactly the sameMoreFirst. So first i want the inputs to the zigzag indicator itself and these are exactly the same three inputs that the zigzag indicator. Takes. So there’s a depth deviation. And a back step.

How do you draw a zigzag line in MT4?

Hotkeys: Z – turns on zigzag drawing. One press of a key turns on the function, a second press turns off the function. C – turns on zigzag display on all timeframes.

Where is the zigzag indicator in MT4?

Adding the Zigzag indicator to Metatrader is extremely easy to do. As the indicator is already built into the platform, all the trader needs to do is simply click Insert, pull down to the menu to click on Indicators, and then go to the next submenu Custom, and then simply click on Zigzag Indicator.

How do you trade zig zag?

0:296:00Never Miss Another Big Trade with the Zig Zag Indicator – YouTubeYouTubeStart of suggested clipEnd of suggested clipNow if you look at the chart on the screen you can see that. Once we have reached a certain high andMoreNow if you look at the chart on the screen you can see that. Once we have reached a certain high and the price has then retraced back by 10% the indicator changes direction.

What is zig zag formula?

The Zig Zag Indicator Formula Choose % price movement. Identify next swing high or swing low that differs from the starting point = > % price movement. Draw trendline from starting point to new point. Identify next swing high or swing low that differs from the new point = > % price movement.

What is the formula of high rate in zigzag code?

They are defined by partitioning the input data into segments of fixed size, and adding sequence of check bits to the data, where each check bit is the exclusive or of the bits in a single segment and of the previous check bit in the sequence. The code rate is high: J/(J + 1) where J is the number of bits per segment.

How does the ZigZag indicator work?

The zig zag indicator is a basic tool that analysts use to find out when a security’s trend is reversing. By determining the support and resistance areas, it helps to identify significant changes in price while filtering out short-term fluctuations, thus eliminating the noise of everyday market conditions.

What is ZigZag forex?

The Zig Zag indicator shows when a trend could be reversing, but the trader will compare that indication against other trading tools they use in order to execute their strategy. Common forex trading tools are volume indicators, buy/sell momentum indicators, and relative strength indicators, called RSIs.

What is deviation in zigzag?

The “Deviation” is the percentage once the previous maximum or minimum is formed (example: if we have a stretch of 100 points from the minimum to the maximum, and the deviation is 5, it will start to draw the bearish stretch when at least 5% of the stretch is corrected).

What is the example of zigzag line?

In a zigzag course. The definition of a zigzag is a pattern on a line with a sharp turns going in opposite directions at sharp angles. An example of a zigzag is a stitch on sewing machine.

What is the zig zag stripe pattern called?

Herringbone is a pattern made up of equal-size, rectangular pieces, arranged in a staggered zig-zag pattern. The distinct characteristic of herringbone is that one rectangle is cut precisely so that the end of one plank or tile meets to the side of the other.

How does ZigZag work?

ZigZag links highs and lows on the chart in accordance with the settings. You must keep in mind that the last line of the indicator remains incomplete until the last high or low is formed.

How many candlesticks does ZigZag use?

First, ZigZag chooses an extreme on an interval of 12 candlesticks. The number of candlesticks set by Depth in the indicator settings.

What happens after a ZigZag position opens?

After the position opens, track the price moving upwards and close the position after ZigZag forms a local high.

What is backstep in candlesticks?

Backstep is the minimal number of candlesticks that must divide two local extremes. At this interval, new highs/lows will not be drawn if they differ from the previous ones for the size of Deviation. The default setting is 3.

What is a zigzag indicator?

The ZigZag indicator is quite popular among traders, though, in essence, it simply shows the price fluctuations in a simpler way. The indicator helps see the main price movement clearer, cutting off useless market “noise”. Also, ZigZag is a good helper in identifying Elliott waves.

What is a zigzag?

ZigZag helps analyze the price movement on the chart. Traders who use Elliott waves in their strategy, often use ZigZag as well to identify waves. It helps to filter minor “noise” on the chart and to define current wave structure (motive or corrective). Also, ZigZag will help define the actual trend and draw trendlines.

What happens if the price does not reverse down?

If the price does not reverse down and growth for 5% more of the basic movement, the high will be transferred to a new peak.

The Zigzag concept

The zigzag concept is a winding line on MetaTrader platforms. This technical tool is valuable for two reasons. First, it neglects price noise that would be perturbative to chart analysis. In fact, that helps traders to stay in the trend direction by filtering minor price reactions.

How to read the zigzag line?

The zigzag line reveals the major market trend as a trendline. It’s so easy to read the Zigzag indicator on Metatrader charts. Because zigzags are simply plotted as trendlines. That is to say, it simply reveals in which direction the market is trending. Consequently, an upward zigzag suggests a booming market.

How to use the zigzag indicator?

Skilled chartists use the MT5 zigzag indicator along with trendlines on Tradingview charts. To explain, this forex trading system enables them to forecast money management targets. That is to say, stop-loss and take-profit orders. In short, these are the main uses of zigzags:

Zigzag indicator MT4

The MT4 swing zigzag indicator identifies tops and bottoms. In fact, it draws zigzags that link important market tops and bottoms in Metatrader 4 . To explain, this technical tool identifies Swing points. That is to say, swing highs during an upside movement. Contrarily, swing lows during a downward move.

Zigzag indicator MT5

The MT5 zigzag pinpoints important formations by linking swing lows and swing highs of the price action. In fact, lows and highs are connected with a line tracing the action of the price. Consequently, the winding line may look like a pattern on the MetaTrader 5 platform.

Zigzag indicator Tradingview

The ZigZag Indicator detects and links extreme swing points of the Tradingview chart as reversal opportunities. To explain, the distance between these reversal points is exceeding or equal to the percentage deviation setting. From one part, swing highs stand for the best timing to sell. Conversely, swing lows stand for the best time to buy.



General Approach

What Zigzags Are in Question

  • As it was said above, in this article, we are interested in ZigZags switching at breaking through the slowing level. What is a “slowing level”? Assume we want to write a ZigZag for which the peak is fixed when the price moves from that peak by H points.Fixing a peak means switching the direction of a ZigZag segment to an opposite one. Let us have just fixed the minimum and now …

See more on

Zigzag Model

  • Let’s now determine the variables of the ZigZag state. First of all, it will be the direction of the current segment. We will name the corresponding variable UpZ and assign it the values of true for up-segments and falsefor down-segments. Obviously, we should add to the list TempMax and TempMin introduced above. We will also add their time coordinates. Here, however, we get som…

See more on

Transition Operator

  • In the proposed approach, writing a transition operator for a ZigZag becomes a rather simple task. We have just to translate the definition of the ZigZag class we are interested in into MQL4. This is how it will appear: The transition operator is ready. Now we can refer to state variables of the indicator at any time. However, such operator has a special feature that can be perceived as an …

See more on


  • It only remains to complete the indicator to make it working. There is no need to comment on init() and deinit(), everything is pretty clear and standard there. However, we will make an important decision on function start(). We will work with complete bars only. The main reason for this is that it allows us to achieve a simple and compact code structure. There is another import…

See more on


  • A template for writing ZigZags, ZZTemplate, is attached to this article. All you have to do is to add the necessary code to function SwitchLevel(). To turn the template into the ZigZag used here as an example, you have just to find the following lines and comment on them: The final note concerns the ZigZag speed. The template implies generality. Be…

See more on

What Is Zigzag and Is It Helpful?

ZigZag is quite a popular indicator featured by many trading platforms, including MT4 and MT5. The indicator is a broken line linking lows and highs on the price chart. As long as ZigZag is drawn through the most important highs and lows, it is very easy to use for price chart analysis. ZigZag links highs and lows on the chart …

See more on

Characteristics and Settings

  • On popular trading platforms MetaTrader 4 and MetaTrader 5, ZigZag applies on the chart of an instrument via the Main menu: Insert – Indicators – User – ZigZag. A standard ZigZag has three main settings: 1. Deviationsets the minimal price change necessary for the indicator to form a high/low on the chart. It measures in %, by default set as 5. 2. D…

See more on

Trading with Zigzag

  • You can use the indicator as an independent trading system, but most often it uses with other trading instruments to make trading more efficient. Let us discuss two trading methods.

See more on

Closing Thoughts

  • The ZigZag indicator is quite popular among traders, though, in essence, it simply shows the price fluctuations in a simpler way. The indicator helps see the main price movement clearer, cutting off useless market “noise”. Also, ZigZag is a good helper in identifying Elliott waves. To my mind, ZigZag is a comfortable and accessible (available on most platforms) instrument that enhance…

See more on

Leave a Comment