'**********************************************************************
'*   Trend Trigger Indicator
'*     by Jeremy Williams
'*	   February 14, 2006
'*
'*	Adapted from Technical Analysis of Stocks and Commodities
'*    December 2004
'*
'*  Summary: 
'*
'*      This indicator measures the strength and direction of  
'*  the current trend by analysing Buy Power and Sell Power.
'*  For more information see "Trend Trigger Factor" in the 
'*  December 2004 edition of Technical Analysis of Stocks and
'*  Commodities.
'*
'*  Parameters:
'*
'*  Periods= Specifies the number of Periods used for the buy
'*             power and sell power calculations.
'*
'******************************************************************** 

#Indicator
#Param "Periods" , 14

Dim BuyPower 	As Single
Dim SellPower	As Single
Dim myHHV 		As Single
Dim myLLV 		As Single
Dim Numerator 	As Single
Dim Denominator As Single
Dim OutValue 	As Single

myHHV = HHV(Periods)
myLLV = LLV(Periods)

BuyPower = myHHV-myLLV[Periods+1]		' Calculate BuyPower and SellPower
SellPower = myHHV[Periods+1]-myLLV

Numerator = (BuyPower-SellPower)*100	' Calculation of Trend Trigger Indicator using:
Denominator = (BuyPower+SellPower)/2	' ((BuyPower-SellPower)/(.5*(BuyPower+SellPower)))*100
OutValue = Numerator/Denominator

SetScales(-200,200)						' Plot the output of the Trend Trigger Indicator
PlotLabel(100)
PlotLabel(-100)
Plot("Trigger",OutValue)

return OutValue							' Return the value of the indicator