MetaStock Highest Since Bars Ago Function

Provided By www.meta-formula.com

The Highest Since Bars Ago function is a variation on the Highest Since function. The difference being that instead of returning the highest value of the selected `data array' since the `N'th most recent occurrence of a defined expression occurred, it will return the number of periods have passed since this last high was achieved. In other words, this function returns the number of periods that have passed since the highestsince() function returned its value.

SYNTAX HighestSinceBars(Nth, Expression, Data Array)

Nth _ Is the number of occurrences, of the `expression', you wish to refer back to when obtaining the highest value of the selected data array.

Expression _ The technical condition that you are referring back to.

Data Array _ The highest value of this data array is returned from the period that the `expression' was true `Nth' number of times ago.

EXAMPLE

The following formula identifies when the closing price last crossed a 34 period weighted moving average, and from that period onwards, it has found the highest value that the close has reached. However, rather than returning this value, it has counted the number of periods that have passed since this high was achieved:

HighestSinceBars(1,Cross(C,Mov(C,34,W)),C)

In the formula above:

Nth = 1

Expression = Cross(C,Mov(C,34,W))

Data Array = C

APPLICATION

A more useful application of this example could be:

HighestSinceBars(1,Cross(C,Mov(C,34,W)),C)<8

This formula, after identifying when the closing price last crossed a 34 period weighted moving average, has found the highest value the close has reached since then. The formula then stipulates that the number of periods that have passed, must be less than 8 periods (denoted by `<8'). 

Looking at Figure 3.11 we can see this example applied to the chart as an indicator.

 

Figure 3.11 _ Highest Since Bars Ago

EXERCISES

Construct formulas for the following:

1. Return the number of periods that have passed since the highest volume figure was achieved, after the last time the volume was greater than 300000:

__________________________________________________

2. Return the number of periods that have passed since the highest closing price was achieved after the last time the closing price was 2% higher than the previous period's open (hint: you will need to use the Reference function referred to on page 75):

__________________________________________________

This article is a snippet from the
MetaStock Programming Study Guide...

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

Click Here To Find For More About
The MetaStock Programming Study Guide

copyright 2007 www.meta-formula.com