'*********************************************************************** '* Compound Moving Average Stop '* by Jeremy Williams '* February 22,2006 '* '* Summary: '* '* This stop sends an exit signal when a crossover occurs '* between a moving average and a moving average of the first '* moving average. '* '* Parameters: '* '* Periods: the number of Periods used in the first moving average '* '* ComPeriods: the number of Periods used in the compound moving average '* '*********************************************************************** #Stop #Param "Periods", 14 #Param "ComPeriods",5 Dim myMA As Single Dim myCMA As Single myMA = SMA(Periods) ' Find the first MA, and EMA may be substituted myCMA = SMA(myMA,ComPeriods) ' Find the compound MA ' If in a long position and first MA crosses CMA to the bearish ' side, then send an exit signal If Signal = LongSignal and myMA < myCMA and myMA[1] > myCMA[1] then Signal = ExitSignal ' If in a short position and first MA crosses CMA to bullish ' side, then send an exit signal Else If Signal = ShortSignal and myMA > myCMA and myMA[1] < myCMA[1] then Signal = ExitSignal End If