Tradestation built-in functions Highest and Lowest loop through the most recent Length bars to obtain the highest and lowest prices, respectively. These functions, in turn, call a nested function, Extremes, to perform the calculation. In these functions, the Length may vary with subsequent calls.
Tradestation built-in functions HighestFast and LowestFast are slightly more efficient as they perform the calculation without using a nested function, Extremes. However, they do loop through Length bars each time they are called. In these functions, the Length may vary with subsequent calls.
Tradestation built-in functions HighestFC and LowestFC compare the current price to the last calculated highest or lowest value and the offset of the last highest or lowest value to determine if it is necessary to loop through the most recent Length bars to perform the calculation. In many cases, the looping can be avoided making these functions more efficient. These functions call nested function ExtremesFC to perform the calculation. In these functions, the Length may NOT vary with subsequent calls.
The functions presented here, _HighestFC and _LowestFC, also avoid unnecessary looping as does the function ExtremesFC. Nevertheless, they represent a modest improvement over the built-in functions HighestFC and LowestFC because of the following:
- The calling of nested functions is avoided.
- The code is slightly more efficient, as they are single purpose, rather than utilizing a multi-purpose nested function.
- Unlike functions HighestFC and LowestFC, the Length may vary in _HighestFC and _LowestFC.This is useful when the program must dynmically vary the look-back period, Length. For example, these functions could be used to calculate the value of a trailing stop. This stop can be tighened, when necessary, by dynamically shortening the look-back period, Length.
Initially posted version: 04/24/10
Latest Update: 04/25/10
*.ELD files are compiled for TS 8.7
All ELD and code text files packaged here:
Users of earlier versions fo TradeStation may compile the code
from the text files included in the above *.zip file.
The code may be visualized here: