#Indicator '************************************************************** '* TC (TC.txt) '* by Jeremy Williams '* Dec. 5,2006 '* '* Adapted from Technical Analysis of Stocks and Commodities '* February 2007 '* '* Summary: '* '* This indicator attempts to anticipate the crossover '* of two moving averages. It usually crosses the closing price '* one bar before the two moving averages cross. For more '* information see "Anticipating Moving Average Crossovers" in '* the February 2007 issue of Technical Analysis of Stocks and '* Commodities. '* '* Parameters: '* '* ShortPeriods - Specifies the number of periods used for the '* short moving average calculation. '* '* LongPeriods - Specifies the number of periods used for the '* long moving average calculation. '* '************************************************************** #Param "ShortPeriods",14 #Param "LongPeriods",21 Dim myShortPeriods As Integer Dim myLongPeriods As Integer Dim ShortMA As Single Dim LongMA As Single Dim myTC As Single ' Calculate the intermediate moving averages myShortPeriods = ShortPeriods - 1 myLongPeriods = LongPeriods -1 ShortMA = SMA(myShortPeriods) LongMA = SMA(myLongPeriods) ' Implement the calculation If LongPeriods > ShortPeriods Then myTC = (ShortPeriods*myLongPeriods*LongMA-LongPeriods*myShortPeriods*ShortMA)/(LongPeriods-ShortPeriods) Else myTC = 0 End If 'Plot the indicator and the current close in its own pane Plot("TC",myTC) Plot("Close",C) 'Return the value of the TC indicator Return myTC