ZigZag Channel Indicator

Do you like the ZigZag indicator? I like it so much because it's the easiest way I can use to draw the trends.
As you see in Figure 1 the trends are drawn for the last two highs and the last two lows of the ZigZag indicator (The ZigZag indicator is in Red and the two bands are in Red and Blue).

zigzag channel indicator

How to use MetaTrader to draw the trends (The hard way)?

To use ZigZag first you have to go to the navigator window and choose it from the custom indicator (figure 2).
Now to draw the upper trend line you have to choose the trend line from the lines toolbar (figure 3) then draw a line connecting the most near two highs of the ZigZag indicator.
For the lower trend line you will do the same steps but in this case you will draw a line connecting the most near two lows of the ZigZag indicator.

zigzag

zigzag

Traders voice:

I don't talk about trading a lot (because I'm a good coder not trader) but the traders use the breakout of the upper and lower trend lines to sell and buy:
When the price break up the upper trend line it's a long signal.
When the price break down the lower trend line it's a short signal (figure 4).
The upper and lower trends used as resistance and support lines.

zigzag

How to draw the trends using MQL4 (The easy way)?

I modified the ZigZag indicator to automatically draws the upper and lower trends lines for you. Just drop it on the chart and it will do all the job.

These are the settings you can play with:

ExtDepth, ExtDeviation and ExtBacksep:
These are he normal parameters of the ZigZag indicator, set them to the values you used to use or keep the defaults.

BreakPips:
The number of pips below/above the trend to show the alert.

UpperBandColor:
The color of the upper trend line.

LowerBandColor:
The color of the lower trend line.

back:
If you want to draw the trend for previous highs and lows (in the case you want to test the system of trend break out for previous periods or for any other reasons) you can set the back to the number of the highs and lows back in history to draw the upper and lower trend lines.
For example in figure 5 "back" was set to 1.

AlertOn:
Set the alert on/off.

zigzag

I hope you enjoyed the ZigZag Channel indicator, and I hope you give the code a look and ask me if you find anything not understood.

Cya!
Coders' Guru

Last Update: 2011.09.20