'***********************************************************************
'*   Advanced Inactivity Stop
'*     by Jeremy Williams
'*	   February 21,2006
'*
'*  Summary: 
'*
'*		This stop sends an exit signal when price movement over
'*  a set lookback period is less than a predetermined threshold. 
'*
'*  Parameters:
'*
'*      Duration: The number of lookback periods used to determine
'*					activity of the stock.
'*
'*		Activity_Level: The number of ATRs the stock must move within
'*							the duration
'*
'*		ATR_Period: Number of periods used in the calculation of ATR
'*
'***********************************************************************

#Stop
#Param "Duration",10
#Param "Activity_Level",2
#Param "ATR_Period",20

dim myHigh 	as single
dim myLow 	as single
dim myATRs 	as Single

myATRs = Activity_Level * ATR(ATR_Period)		' Get net activity, highest highs, and lowest lows
myHigh = HHV(Duration)
myLow = LLV(Duration)

If myHigh - myLow < myATRs then				' If activity level is less than specified send exit
	Signal = ExitSignal
end if