#Indicator
'**************************************************************
'*   Relative Spread Strength (RelativeSpreadStrength.txt)
'*     by Jeremy Williams
'*	   September 19,2006
'*
'*	Adapted from Technical Analysis of Stocks and Commodities
'*     October 2006
'*
'*  Summary: 
'*
'*      This indicator returns and plots the Relative Spread Strength  
'*  Indicator, as seen in "Forex Focus: Relative Spread Strenght As
'*  A Long Term Cyclic Tool" in the October 2006 edition of Technical
'*  Analysis of Stocks and Commodities.
'*
'*  Parameters:
'*
'*  ShortPeriods     = Specifies the number of periods to use in the 
'*                         short EMA calculation.
'*
'*	LongPeriods      = Specifies the number of periods to use in the 
'*                         long EMA calculation.
'*
'*  RSPeriods        = Specifies the number of periods to use in the 
'*                         Relative Strength calculation.
'*
'*  SmoothingPeriods = Specifies the number of periods to use in the 
'*                         smoothing EMA calculation on the RSI.
'*
'************************************************************** 

#Param "ShortPeriods" , 10
#Param "LongPeriods" , 40
#Param "RSPeriods" , 5
#Param "SmoothingPeriods" , 5

Dim ShortEMA 	As Single
Dim LongEMA 	As Single
Dim Spread		As Single
Dim myRSI		As Single
Dim SmoothRSI	As Single

' Calculate the EMA's
ShortEMA = EMA(ShortPeriods)
LongEMA = EMA(LongPeriods)
' Determine the Spread
Spread = ShortEMA-LongEMA

' Calculate and Smooth the RSI of the Spread
myRSI = RSI(Spread,RSPeriods)
SmoothRSI = EMA(myRSI,SmoothingPeriods)

' Plot the Indicator and significant levels
SetScales(0,100)
Plot("RSS",SmoothRSI)
PlotLabel(70)
PlotLabel(30)

' Return the value calculated by the indicator
Return SmoothRSI