Saturday, September 04, 2010

Indicator Overbought / Oversold [IOO]

Descripton
Summary:
This heat study script generates values based on the overbought / oversold status of a single indicator.

Returns:
Overbought: - 1
Oversold : 1


Variables
TypeIdentifierDescription
IntegerArray_indicatorKeysUse for holding all of the indicator keys duplicated from the specified indicator key and indexed by symbol index.
Number_overboughtValueUse for the minimum value above which the underlying indicator is considered overbought. [Default 80]
Number_oversoldValueUse for the minimum value below which the underlying indicator is considered oversold. [Default -80]

OnInitialize
Function Parameters
TypeIdentifierDescription
IndicatorindicatorKeyUse for the indicator key.
NumberoverboughtValueUse for the minimum value above which the underlying indicator is considered overbought. [Default 80]
NumberoversoldValueUse for the minimum value below which the underlying indicator is considered oversold. [Default -80]
Implementation
	 ' Assign the script parameters to script variables.
	_overboughtValue = overboughtValue
	_oversoldValue = oversoldValue
	
	 ' Use for holding indicator keys based on the specified indicator key, indexed by symbol index.
	Redefine _indicatorKeys(SymbolCount() - 1)
	 ' Iterate over all of the symbols.
	For i As Integer = 0 To SymbolCount() - 1
		 ' Create an indicator for each symbol, based on the specified indicator.
		_indicatorKeys(i) = IndicatorCopy(indicatorKey, i)
	Next

OnValue
Function Parameters
TypeIdentifierDescription
IntegersymbolIndex
Implementation
 ' Get the indicator value, indexed by bar index.
	Define value As Number = IndicatorValue(_indicatorKeys(symbolIndex))
	
	 ' Oversold.
	If (value < _oversoldValue) Then
		Return 1
	 ' Overbought.
	ElseIf (value > _overboughtValue) Then
		Return -1
	End If
	Return 0

Copyright © 2010 IQBroker, LLC. All rights reserved.