HighTick


Faster HighestFC and LowestFC Functions

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 an modest improvement over the built-in functions HighestFC and LowestFC because of the following:

  1. The calling of nested functions is avoided.
  2. The code is slightly more efficient, as they are single purpose, rather than utilizing a multi-purpose nested function.
  3. 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.

HighestFC and LowestFC functions with Length of 15

Fig. 1 _HighestFC and _LowestFC functions with Length = 15

MarkSanDiego

Downloads

Initial 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:

HighestFC and LowestFC.zip

Users of earlier versions of Tradestation may compile the code
from the text files included in the above *.zip file.

The code may be visualized here:

Function _HighestFC

Indicator _HighestFC

Function _LowestFC

Indicator _LowestFC

 

Bookmark and Share