The MetaStock reference function is one of the most widely used functions, as it allows us to refer to the value of any expression, or the selected ‘data array’, any number of periods backwards, or subsequent periods into the future.

It’s important to note that if you’re using the reference function to refer to a period in the future, it’s obviously dynamic, meaning it can change. Therefore, be careful when using it within system tests, as it can produce deceptively good results.

MetaStock Syntax: Ref(Data Array, Periods)

Data Array = The data array value to be returned from ‘x’ number of periods ago.

Periods = This dictates how many periods forward or backward to reference the data array value. A negative number will refer to a value in the past, while a positive number will refer to a value in the future.

This is how it would look in an example. The following formula refers to yesterday’s closing price:

Reference(C,-1)

In the MetaStock formula above:

data matrix = C

periods = -1

This is how you would use the formula in a more useful application of this example:

C>Ref(C,-1) AND Ref(C,-1)> Ref(C,-2)

This MetaStock formula specifies that the current period’s closing price must be above the previous period’s closing price; and the closing price of the previous period must be higher than the closing price of the previous period. In this example, we have used the closing price as the data matrix; however, you can use almost any function or indicator.

Another common application of the datum function is to accurately describe peaks and valleys, without using the peak and valley functions within MetaStock. A simple definition of a peak is a bar that has had 2 periods earlier with lower highs and 2 periods later with lower highs. Using the reference function, we can precisely encode this as follows:

H>Ref(H,-1) AND Ref(H,-1)>Ref(H,-2) YH>Ref(H,1) AND Ref(H,1)>Ref(H,2)

Note that since we are using a positive map of the reference function (indicated by ‘H>REF(H,1)’), a signal will only appear after the event has passed. In other words, you only know that a spike has occurred after it has occurred.

If you’re new to the MetaStock formula, this may seem complex or confusing, but once you “understand” it, you’ll understand why it’s used by so many professional traders.

RELATED ARTICLES

What Is Rogers PCB?

Rogers PCB Rogers PCB is a company that is into the manufacturing of laminate materials which are used to build circuit boards. This type of material is very popular in the electronics industry and is used to create high-end electronic equipment. It is known for…

Leave a Reply

Your email address will not be published. Required fields are marked *