Category

Multi-Bar Functions

Description

Value of the nth most recent peak of a series of prices or other values

Syntax

Peak(expr, pctChg, nth {1})

Parameters

expr - data series formula

pctChg - percent change required to delimit peaks and troughs

nth - which peak to locate (1, i.e., most recent if omitted)

Notes

The definition of a Peak is the highest value which is then followed by one or more values that are at least n% below that most recent high.

Most technical analysis software (which is designed primarily for charting purposes) attaches Peak and Trough values to the bars on which they occur. RealTest (being designed for realistic backtesting) does not commit this look-ahead error.

Instead, the most recent peak is only returned starting with the subsequent bar that completes the n% drop following that peak. This makes it completely safe and legitimate to use these functions in backtesting.

The SPY chart below shows how this works. The bar marked by the pink vertical line is the first bar for which 417.39 is returned, even though that peak happened six bars earlier (as reflected in the PeakBars calculation).

The same rules apply to the Trough and TroughBars functions.

 

 

 

 

Copyright © 2020-2022 Systematic Solutions, LLC