ZUP - Universal ZigZag with Pesavento Patterns. Part 2

Eugeni Neumoin | 2 August, 2007


Due to the programming language, MQL4, embedded in the MetaTrader 4 Client Terminal it is possible to create various indicators. Some of them may be sophisticated and others may be very simple. It all depends on the developer's imagination. The article describes the way of developing a sophisticated program. It describes, if I may say so, an indicator platform - the ZUP. The article also gives a brief description of graphical tools embedded in the ZUP. ZUP is permanently updated. We describe in this article graphical tools for ZUP_v63.

Pesavento Patterns ( http://www.ensignsoftware.com/tips/tradingtips35.htm#Pesavento )

On the chart below, the ZigZag breaks are joint by dotted lines. A number is given in the middle of each dotted line. These are the dotted lines with numbers near them that represent a tool named Pesavento Patterns. The tool named Pesavento Patterns must be distinguished from the market shapes named Pesavento Patterns. We will explain below what the market shape named Pesavento Patterns represents.

Let us calculate the size of rays 23 and 34 in points. The size of ray 23 = (1.3665-0.8225)*10000=5440. The size of ray 34 = (1.3665-1.1638)*10000=2027. Let us divide: 34/23 = 2027/5440=0.373. We obtain a number that differs from the Fibo 0.382 by 2.46%. You can see the value of 0.382 near the dash line between points of 2 and 4.

The Fibo levels are noticed to start "working" when the market approaches to a certain Fibo level. The market often stops or turns near a Fibo level. There is a kind of an area, within which the market behavior is rather predictable. The size of this area is expressed in percents and equals to 2*Delta.

On the chart below, you can see that a Fibo of 0.382 is near point 4. The Fibo level is below the November minimum by (1.1638-1.1557)*10000=51 points.

EURUSD has not reached Fibo 0.382 a little in November 2005 and turned up. This is how Fibo 0.382 "works". Generally, the number shown near to the dash line is equal to the size of the subsequent ray divided by the size of the preceding ray of ZigZag. In the above example, the ratio of rays is 34/23. This ratio is named retracement between points 2 and 4 of ZigZag.

So why is number 0.382 shown near the line, not 0.373? It was noticed that quite certain Fibo levels "work" on the market. It means there is a certain set of "working" Fibo levels. Different authors give different sets of Fibo levels.

Pesavento Patterns Tool Operation Algorithm

First, the retracements between ZigZag's peaks and troughs. Then the calculated values will be compared to the predefined set of Fibo levels. If the value obtained is other than that from the set of Fibo levels but no more than by Delta%, the number from the set of Fibo levels will be shown near the dash line. The number is colored as it is defined for numbers from the set of Fibo levels. (If the set of Fibo levels corresponds with the numerical table developed by Larry Pesavento, we will obtain the market shape named Pesavento Pattern.) If the obtained number differs from that in the set of Fibo levels by more than Delta%, the former will be displayed near the dash line and colored differently.

Where the tool named Pesavento Patterns is available, there is no need to calculate retracements. If the price is covered by a Fibo level, the Pesavento pattern will display the value of this Fibo level colored as predefined. The tool named Pesavento patterns will deliver one from retracements calculating routines.

The indicator's inputs to work with Pesavento patterns:

We will call tools attached to ZigZags 'tooling'.

Maximums/minimums are counted starting with zero bar.

Pesavento patterns have the same functionality as the tool named Fibo levels.

Sets of Fibo Levels for Different Symbols

In the ZUP, sets of Fibo levels are divided into a standard set and alternative sets. We will also call the alternative set of numbers Pesavento numbers.

Using parameter ExtFiboType, you can choose between the standard set of Fibo levels and an alternative set of Fibo levels:

The full list of Fibo levels (numbers) for different symbols embedded in the ZUP is given below.

This list can be modified in future.

Numbering of ZigZag Breaks and Rays

Many tolls in indicator are based on a certain ray or a certain break of ZigZag. For instance:

The chart below shows numbering of breaks in red, numbering of rays - in Teal.

If some drawings are made on the first ray or on zero (0) break, the tool will be dynamically changed together with the current price changes. If the shapes do not touch the first ray or zero break, the tool won't change and, correspondingly, this tool will be called static. All graphical tools in the ZUP are built on the first nine rays or on the first ten peaks (0-9). But Pesavento patterns can be built on all breaks, not only on the first ten ones.

Dynamic and Static Fibo Levels. Fibo Expansions

Graphical tools embedded in the ZUP can be dynamic or static. Static graphical tools are anchored to ZigZag breaks already formed, i.e., to the breaks that won't change anymore. Dynamic graphical tools are anchored on the end of the ZigZag first ray that always changes its location.

Dynamic graphical tools allow to make a quick decision. If the market turns, we will be able to see the possible trend looking at the shape of the dynamic graphical tool. As soon as the first ray of ZigZag changes, the dynamic graphical tool will be automatically rebuilt, too.

Dynamic Fibo levels are built on the first, changing ray of ZigZag:

Static Fibo levels are built on rays 2-9.

Parameters to be used for working with Fibo levels:

At that, the Fibo level value, for example, 61.8 is shown, the price for the corresponding Fibo levels and the name of timeframe, on which the Fibo levels are shown. It is important to know the timeframe when working in the DT mode. The values of dynamic Fibo levels are shown closer to the chart window border. The values of static Fibo levels are shown with an indent from the border.

When static and dynamic Fibo levels are shown simultaneously, the values of Fibo levels will be partly overlapped. This may complicate information viewing. However, MetaTrader 4 does not allow showing static Fibo levels at some distance from a chart window border. Dynamic Fibo level will be automatically changed with the first ZigZag ray changing in size or location.

Fibonacci expansions will be shown as described in Robert Fisher's book of The New Fibonacci Trader [6]. At that, the size of the ZigZag ray is considered as basis. Expansions are seeming to prolong the ray. Expansion numbers as by Robert Fisher are shown with prefix Fe.

Andrews' Pitchfork ( http://www.trading-naked.com/alan_andrews_course_1.htm )

Andrews' Pitchfork and tactics used to work with this tool were described by Patrick Mikula (http://www.mikulaforecasting.com/books/aabook.htm). Putnik has also made a detailed description of how Andrews' Pitchfork can be built, on ONIX forum at: http://onix-trade.net/forum/index.php?showtopic=8249 Building of Andrews' Pitchfork was realized in the ZUP by Putnik's request, as well.

The full list of parameters for working with Andrews' Pitchfork:

In the Figure below, an exemplary building of Andrews' Pitchfork is given.


Reaction lines are drawn using Fibo Channels. In many cases, they may be drawn with errors. The errors are insignificant, but they can accumulate on a larger time period. It is impossible to draw them without errors. Standard tool Fibonacci Channels error-free drawing is impossible in MetaTrader 4 due to Fibo Channels' specific anchoring to candlesticks. In my first article, ZUP - Universal ZigZag with Pesavento Patterns. Part 1, I wrote about this error. This is why the Reaction Lines in the current realization should be used with care. This error can only be fixed by MetaTrader 4 developers.

How to Show A Set of Pitchforks on the Selected Candlesticks

Let us select candlesticks, on which we will show the pitchfork. Let us point the mouse over these candlesticks. Then write down the date and time of the candlesticks on a separate sheet of paper and after that, call the dialog box to change the indicator's parameters. In parameters ExtDateTimePitchfork_1, ExtDateTimePitchfork_2, ExtDateTimePitchfork_3, enter date and time of candlesticks. Using ExtPitchfork_1_HighLow, decide whether we will build the first point of the pitchfork from maximum or from minimum. Set ExtPitchforkCandle = true. Using ExtPitchforkCandle, decide whether the set of pitchforks will be built on ZigZag extremums or on the extremums of the selected candlesticks.

When selecting ExtPitchforkStatic>0, the set of static pitchforks will be built on the selected candlesticks and displayed on the screen. The set of pitchforks can be saved. If the pitchfork's third point is located on zero bar, dynamic pitchfork will be displayed, which cannot be saved.
The example below shows how Andrews' Pitchfork can be built on the selected candlesticks. Candlesticks, to which the pitchfork is anchored, are default ones in the ZUP. The screenshot is made using ZUP_v63. In earlier versions, reaction lines RL*** are built in this chart with errors due to features of Fibonacci Channels in MetaTrader 4. Reaction lines are built using Fibnacci Channels.

Parameter ExtSave allows saving of the set of static pitchforks, Fibo Time, Fibo Expansions, and static Fibo levels. This parameter does not save filling of the channel of static pitchfork.

How to work with ExtSave:

  1. The set of Andrews pitchforks and all auxiliary lines should be built.
  2. Open the indicator setup panel and set ExtSave=true.
  3. Close the setup panel. The set of pitchforks will be drawn in the chart.
  4. Re-open the indicator setup panel and set ExtSave=false.
  5. Close the panel. The saved set of pitchforks will be shown in the chart. The same set of pitchforks will be displayed over the previous set, but the second set (shown over the first one) will be deleted together with the indicator while the first one will remain in the chart.

If clauses 4 and 5 are not performed, the actual set of pitchforks with its current parameters will be saved in the chart at each change of the indicator parameters. If the indicator is deleted, a number of sets of pitchforks will remain in the chart, superimposed upon each other or a bit shifted.

The tools (pitchfork, fans, etc.) should be saved on the smallest of actual timeframes. If they are saved on a larger timeframe and when you switch to a smaller timeframe, the tools saved will be drawn starting from the first candlestick of the smaller timeframe, this candlestick timely included in the larger timeframe, the timeframe where the tools have been saved. This is one of MetaTrader 4 features, too. When switching to another timeframe, the saved tools will be shown with errors.

If you don't save the tools, but just show them using ZUP, they will be built properly. In the DT mode of the ZUP, the ZigZag breaks are recalculated and breaks are built on the candlesticks where maximum or minimum really takes place when changing the timeframe. So the tools are re-anchored to more precise points. Drawing defects were not observed at that.

micmed's Channels

micmed's Channels are a new graphical tool developed by micmed, a participant of ONIX forum. It is based on Andrews' Pitchfork, but anchoring points of the pitchfork are selected in a special way.

Below are micmed's quotations from some posts on ONIX forum (translated into English by MetaQuotes Software Corp.):

...such as shown in the screenshots can also be added to the set of pitchforks, I call them "golden section". Trying VL (*), I discovered that such pitchforks retained proper channels most frequently...

This is what explains the interest in this drawing: the golden section built according to the above requirements works further as a channel, though it is built far before the borders of a classical channel are shown. And this fits completely in the harmony related to Fibonacci numbers...

...these are not pitchforks, really, it was just comfortable to build using them. As to the building, I put point 1 on a vertical line built from B. Some observations are given below:

  1. If diagonal line AB is shorter than diagonal line BC, I build at a distance of 32, 8% from vertex B
  2. If diagonal line AB is longer than diagonal line BC, then 61.8% from vertex B
  3. There are also 50%, usually at pivots, and they follow each other, 2-3 triangles
  4. If the channel is broken through, point 38.2 will change for 61.8 and vice versa (screenshots)

* - VL - Versum Levels -a new graphical tool to be described later.


Parameter ExtCM_0_1A_2B anchors all Andrews' pitchforks (see above) to other points. To draw micmed's channels, you should build Andrews' pitchforks first. Then, using parameter ExtCM_0_1A_2B, select new anchoring points for pitchforks. The value of parameter ExtCM_0_1A_2B depends on lengths of AB and BC.

Below is the author's description of how channels can be drawn:

micmed's channels in the ZUP, starting from version 55 are built using standard tool named Andrews' Pitchfork on three points, points 2 and 3 being selected on two peaks, like in classical pitchforks, whereas point 1 being selected by two parameters:

  • ExtCM_0_1A_2B (can be 0, 1, 2, 3, 4) defines vertical line, on which point 1 will be located

    respectively, if
    0 - micmed's channels are not drawn, a standard pitchfork is drawn
    1 - point 1 is selected on the vertical line from peak A along Fibo levels AB
    2 - point 1 is selected on the vertical line from peak B along Fibo levels BC
    3 - point 1 is selected on the vertical line from peak A along Fibo levels BC
    4 - point 1 is selected on the vertical line from peak B along Fibo levels calculated according the following algorithm: if AB>BC, then the value is 0.618; if AB<BC, then the value is 0.382

  • ExtCM_Fibo (may vary from 0.0 to 1.0) defines the value for Fibo level of point 1

Exemplary drawings:

  • ExtCM_0_1A_2B = 1, ExtCM_Fibo = 0.618

  • ExtCM_0_1A_2B = 2, ExtCM_Fibo = 0.618

  • ExtCM_0_1A_2B = 3, ExtCM_Fibo = 0.382

Analyzing history on EURUSD, Daily starting from year 1989 - ZUP_v54 with parameters of Extindicator=6, minBars=25 - there were 103 triangles built where

  • if AB>BC, point 1 is selected on the vertical line of peak B on the value of 0.618 (31 triangles)
  • if AB < BC, point 1 is selected on the vertical line of peak B on the value of 0.382 (31 triangles)

it was also observed that in broken channels Fibo values for point 1 change from 0.382 to 0.618 and vice versa (trend direction change), as well as value 0.5 at flats (40 triangles).

Mode 3 is useful for very fast peaks. Otherwise, the channel will be at a very acute angle...

I would like to share an important, to my point of view, observation. In channel building mode 4 (perhaps, in others, too, but this one is automated), price ALWAYS(!) reaches the price at the level of intersection of RL 161.8 with the channel median line and practically always within the range of RL 100 - 161.8.

Above are some quotations from micmed's posts. This was done to for better understanding of how the new graphical tool, micmed's Channels, works. Fibo levels are displayed in the chart in order to show the building algorithm of the Channels. The ZUP containing this graphical tools does not show Fibo levels.

Versum Levels

This graphical tool was developed by versum, the participant of forums at KBPauk and ONIX. It is quite possible that this tool has also been implemented by others. In ZUP, this tool is named Versum Levels.


This tool complements Andrews' Pitchfork and resembles Fibo Fan. Like Andrews' Pitchfork, it works around the median line. Andrews' Pitchfork median line coincides with 50-% level of VL. Below is a sample of how a dynamic VL is drawn. Fibo levels are displayed in the chart in order to show how this graphical tool is built. The ZUP containing this graphical tools does not show Fibo levels.

Below are some quotations from versum's posts (translated into English by MetaQuotes Software Corp.):

This can be considered both a fan, i.e., radiating lines, and a Fibo Fan since I use a segment that intersects these lines and is divided into parts by Fibo level (a tool being at hand and that moment)... In Fig. 1, you can see that segment BC is divided into parts using a Fibo level. Lines are drawn from the preceding peak/trough, point A, through the points of intersection of the Fibo level and segment BC. These are the expected price levels.

So what we have?

  1. levels (which is most important) that change with the time
  2. these are these variations, from which Gartley Patterns and other shapes and models develop, but they are visible "after"
  3. expected trend development.

How to use it?

If the price touches or exceeds the level of the 50-% line (that passes through the point divided by 50-% level), so we can say (though not with a 100-% probability) that the trend keeps the same direction. If it is below 50-% line, we can say that the current trend may change...


  1. I do not use the obtained levels strictly, up to 1 pip. I think this should rather be considered as an area.
  2. I do not consider Fibo levels to be a panacea either. Other ratios between parts of the segment may turn to be better.

Independent Fibo Fans

Along with Fibo Fans that work together with Andrews' Pitchfork, it is possible to enable independent Fibo Fans. These Fibo Fans are displayed on the first nine rays of ZigZag or on the first ten extremums of ZigZag. They are enabled by selecting color using parameter ExtFiboFanColor. The Fans are arranged by parameter ExtFiboFanNum.

Enhanced Mode

The market analysis is most effective when ZigZag peaks and troughs belong to the same wave level. It frequently happens that ZigZag identifies peaks and troughs being "excessive" for a wave level. It is undesirable to build tools embedded in the ZUP on those "excessive" extremums. Well, this topic needs a special research and is open to discussions...

The enhanced mode is created especially to build tools on "right" extremums. The following tools can work in the enhanced mode:

  1. Static Pitchfork
  2. Static Fibo Levels
  3. Static Fibo Expansions
  4. Independent Fibo Fans
  5. Versum Levels
  6. Micmed's Channels

The set of Andrews' pitchforks is everything concerning pitchforks. Lines of the set of pitchforks are anchored to certain points of the pitchforks. For example, control lines are drawn from the first, initial point of the pitchfork through the second and the third one. In the enhanced mode, all lines will be anchored to the corresponding points of the pitchfork wherever those points are located.

If you set parameters of all five tools that can work in the enhanced mode in the same way as before, there will not be any differences from that what you have had before.

In the enhanced mode:

  1. For static pitchforks,you will have to specify three peaks instead of only one number that showed the first peak, on which the pitchfork is built. This will look, for example, like this: ExtPitchforkStaticNum=741.

    Here, peak 7 corresponds with the first point of the pitchfork, trough 4 does with the second point of the pitchfork, peak 1 - with the third point of the pitchfork. The 50-% median line, in this case, is built from the midpoint of the segment that joins points 1 and 2 of the pitchfork ( ZigZag extremums 7 and 4), and goes through the midline of the segment joining points 2 and 3 of the pitchfork (ZigZag extremums 4 and 1). The reaction lines are anchored to points 2 and 3 of the pitchfork.

    If the last digit in parameter ExtPitchforkStaticNum is above 0, static pitchfork will be displayed. If it is 0, the pitchfork built will be dynamic. But, as soon as a new ZigZag ray appears, the pitchfork will become static. If you change any parameters of the indicator during its turning from dynamic to static, the dynamic pitchfork will be displayed again.

    Important: Digits (741) must interchange peaks and troughs. A pitchfork cannot be built if two peaks or two troughs are specified consecutively. It means odd and even numbers must alternate.

  2. For static Fibo levels in the enhanced mode, in the parameter should be specified two ZigZag extremums, on which the Fibo level will be built. For example, ExtFiboStaticNum=72.

  3. Static Fibo Expansions should be built on three ZigZag extremums in the enhanced mode. Example: ExtFiboExpansion=721.

    In the above example, Fibo Expansions will be built as they are drawn in MetaTrader 4. But, if Fibo levels are shown (tool 2) and ExtFiboCorrectionExpansion = true, the Fibo Expansions will be shown instead of Fibo levels. In this case, however, the expansions will be built on two points and correspond with those described in the Robert Fisher's book [6].

  4. Independent Fibo Fans are built on two extremums in the enhanced mode. Example: ExtFiboFanNum=74

  5. Versum Levels:

  6. Micmed's Channels:

Below is what I would like to emphasize again:

For all tools, peaks and troughs must be alternated i the enhanced mode. The tool cannot be built for two consecutive peaks or troughs. Under "consecutive" I mean two consecutive digits that define extremums in a parameter.

All tools in the enhanced mode can be both static and dynamic. If the last digit in the defined parameter is 0, the tool will change dynamically.

Fibonacci Arcs

In ZUP_v63, it becomes possible to build Fibonacci Arcs. All further parameters in the article are parameters as in ZUP_v63.


Arcs have two anchoring points.

If, for example, you set ExtArcStaticNum=3, the center will be located on break 3 of the ZigZag and 100% will be on break 2.

If you set ExtArcStaticNum=83, the center will be on break 8, and 100% - on break 3. The center and 100% can also be defined between two peaks or troughs, for example: ExtArcStaticNum=42.

Static arcs can be drawn between any two ZigZag breaks, from break 1 through break 9. Dynamic arcs are built between "break" 0 and any of the consequent 9 breaks.

If you set ExtArcDinamicNum=8, the center will be in point 0 of the ZigZag, 100% - on break 8. If you set ExtArcDinamicNum=80, the center will be on break 8, 100% - on point 0.

The arc is calibrated along the ZigZag ray, on which it was built. It is meant by ray the line that joins the central point with the 100-% point of the arc, so the points the arc is anchored to. It is calibrated automatically using parameters ExtArcDinamicScale=0 and ExtArcStaticScale=0. The calculations are automated and performed as follows: The amount of points between the central point and the 100-% point of the arc is calculated and then divided by the amount of bars between these points. The obtained number defines the scaling value when drawing arcs. Thus, the arcs are scaled.

If you write in parameters ExtArcDinamicScale and ExtArcStaticScale a number exceeding 0, then the arc will be calibrated (scaled) with this number.

Indicator's Optionality

Using ZigZag ExtIndicator = 1, ExtIndicator = 2 and ExtIndicator = 3 and parameter chHL=true, you can show acknowledge levels in the chart. The acknowledge levels display the channel. If the price breaks the opposite side of the channel, the ZigZag will draw a new ray.

Using parameter PeakDet = true, the levels of preceding ZigZag minimums and maximums are shown.

Parameters chHL and PeakDet are taken from the original Alex's ZigZag.

General Options

These three parameters work with Fibo levels, Fibo Expansions, Fibo Arcs, and FiboTime zones. Previously, basic points of these objects were joint by a red dotted line. These three parameters work with all above-listed objects simultaneously.


The article describes the main features of tools embedded in the ZUP:

  1. Pesavento Patterns;
  2. set of tools working with Andrews' Pitchfork;
  3. Fibonacci Fans;
  4. Fibonacci Levels;
  5. Fibonacci Arcs;
  6. two variations for Fibonacci Expansions.

The new tools are described: Versum Levels and micmed's channels. The full list of values Fibo levels used in various graphical tools. ZUP parameters are briefly described, as well.

I continue to enhance the functionality of ZUP. It is not impossible that in future the features of tools already available will be enhanced and some new tools will be embedded. New parameters are continuously added, as well. I also find and fix various errors. The further developments of the ZUP are performed on ONIX forum at: http://onix-trade.net/forum/index.php?showforum=54

It is very difficult task to complete the description since new features are permanently added to the ZUP. As of now, ZUP_v64 has already been issued. In this latest version, the features that allow working with micmed's channels are enhanced, it is now possible to work with custom Fibo levels, etc. Two new ZigZags have been added, too: ExtIndicator=12 - ZigZag developed by Talex, and ExtIndicator=13 - ZigZag developed by Tovaroved.

Attached to the article are ZUP_v63 and ZUP_v64. ZUP_v64 is also provided with a brief description of novelties (as a MS Word file).

List of References

  1. Larry Pesavento. Fibonacci Ratios with Pattern Recognition
  2. Larry Pesavento. Profitable Patterns for Stock Trading
  3. Bryce Gilmore. Dynamic Time and Price Analysis of Market Trends
  4. Bryce Gilmore. Geometry of Markets
  5. Bryce Gilmore. Geometry of Markets 2
  6. Robert Fisher. Novie metodi torgovli po Fibonacci (Robert Fisher. The New Fibonacci Trader, translated into Russian)