DYO: Trend Trigger Factor


Recently a trader asked if Ensign Windows could plot the 'Trend Trigger Factor' by M.H. Pee.   The trader provided the eSignal EFS code so the mathematics of the TTF could be understood.   The EFS example contained approximately 70 lines of code.  Essentially, the core of the indicator script is a loop which finds the Buy Power High, Buy Power Low, Sell Power High and Sell Power Low.

Imagine that there are two equal sized groups of bars adjacent to each other.   The Buy Power High is the highest high in the set on the right, and the Buy Power Low is the lowest low in the set on the left.   The Sell Power Low is the lowest low in the set on the right, and the Sell Power High is the highest high in the set on the left.  These four values can be calculated using Ensign's powerful Design Your Own study.

Line A finds the Highest High is the set of the last 8 bars.   The Number field is the set size.  This Buy Power High value is saved in Global Variable [10] for use in a later calculation.

Line B finds the Lowest Low in a set of bars, but the set is offset leftward by 8 bars.  This is the Buy Power Low and it is saved in Global Variable [11].  

Line C calculates the spread between these two values.   GV [10] is read and GV [11] is subtracted.   The result is saved back in GV [10].  This spread is the Buy Power.

The process is repeated to find the Sell Power High (Line D) in the left side set.  Note again the Bar Offset is -8 so the set used for the calculation is shifted leftward by 8 bars.   The Sell Power High is saved in Global Variable [11].

Line E calculates the Sell Power Low from the right side set of 8 bars, and saves the result in GV [12].   

Line F calculates the spread between the Sell Power High and Sell Power Low.   GV [11] is read, and GV [12] is subtracted.  The result is saved back in GV [11].  This spread is the Sell Power.  

The formula for the Trend Trigger Factor is:   TTF = 200 * (BuyPower - SellPower) / (BuyPower + SellPower)

Line G calculates the numerator portion of this formula.  Buy Power is read from GV [10] and the Sell Power in GV [11] is subtracted.  The spread is multiplied by the value in the Number field, which is 200.  The result is stored in GV [9].

Line H calculates the denominator.   Buy Power is read from GV [10], and Sell Power from GV [11] is added.  The sum is saved back in GV [10].

Line I performs the final division of the numerator and denominator.   The numerator from GV [9] is divided by the denominator saved in [10].   Line I is the TTF value, which is plotted as a curve in Sub Window 2 using a thick Blue line style.

The example chart shows the TTF line plotted in Blue in the same sub-window as the Commodity Channel Index plotted in Red.  More work needs to be done to understand how to best use the TTF to analyze the markets.  Possibly there is merit in using the CCI and TTF studies together to generate Buy and Sell signals when they cross.  

This article has demonstrated how the powerful Design Your Own study in Ensign Windows can be used to implement fairly complex mathematical calculations.  This example is available as the TrendTriggerFactor template which can be downloaded from the Ensign web site using the Internet Services form.


Last modified 8/8/08 1:40 PM