# MetaStock Peak Bars Ago Function

Provided By www.meta-formula.com

The Peak Bars Ago function returns the number of bars that have passed since a specified peak occurred. This function is actually based on the `peak' function. Technically speaking, a peak is the highest point reached between a short term up trend and a short term down trend. The identification of a peak using this function however, is based on the selected `data array' moving down a set percentage from its most recent high.

SYNTAX PeakBars(Nth, Data Array, %Minimum Change)

Nth _ The number of the peak you wish to use as the reference point when counting how many bars have passed since then. For example, N = 1 would count the number of bars back to the most recent peak in the data array, and N = 2 would count the number of bars back to the second most recent peak.

Data Array _ The data array searched to identify where the peak occurred; this is normally the closing price.

% Minimum Change _ The minimum percentage required for a data array to move away from a high before it is classed as a peak.

EXAMPLE

The following formula returns the number of bars that have passed since the most recent occurrence of the closing price having fallen 4% from its high.

PeakBars(1,C,4)

In the formula above:

Nth = 1

Data Array = C

% Minimum Change = 4

APPLICATION

A more useful application of this example could be:

PeakBars(1,C,4)<5

This formula will count the number of bars that have passed since the most recent occasion that the closing price moved down 4% from the high. Additionally, it also checks whether this value is less than 5. This identifies securities that have peaked recently.

Looking at Figure 3.18 we can see the first example applied to the chart as an indicator

Figure 3.18 _ Peak Bars Ago

EXERCISES

Construct the formula for the following:

1. Return the number of bars that have passed since the second last time that there was a peak in the closing price where there was a 4% change in price:

__________________________________________________

MetaStock Programming Study Guide...

"Discover The Simple Secret to Make Metastock Easy & Identify Profitable Trades"