Saturday, September 04, 2010

Indicator Subtraction [IS]

Descripton
Summary:
This heat study script generates values based on the subtraction of two indicators.

Returns:
first indicator value - second indicator value


Variables
TypeIdentifierDescription
IntegerArray_indicatorKeys1Use for holding all of the first indicator keys duplicated from the specified indicator key and indexed by symbol index.
IntegerArray_indicatorKeys2Use for holding all of the second indicator keys duplicated from the specified indicator key and indexed by symbol index.

OnInitialize
Function Parameters
TypeIdentifierDescription
IndicatorindicatorKey1Use for the minuend indicator key
IndicatorindicatorKey2Use for the subtrahend indicator key.
Implementation
	 ' Use for holding indicator keys based on the first specified indicator key, indexed by symbol index.
	Redefine _indicatorKeys1(SymbolCount() - 1)
	 ' Use for holding indicator keys based on the second specified indicator key, indexed by symbol index.
	Redefine _indicatorKeys2(SymbolCount() - 1)
	 ' Iterate over all of the account symbols.
	For i As Integer = 0 To SymbolCount() - 1
		 ' Create an indicator for each symbol, based on the first specified indicator.
		_indicatorKeys1(i) = IndicatorCopy(indicatorKey1, i)
		 ' Create an indicator for each symbol, based on the second specified indicator.
		_indicatorKeys2(i) = IndicatorCopy(indicatorKey2, i)
	Next

OnValue
Function Parameters
TypeIdentifierDescription
IntegersymbolIndex
Implementation
	 ' Get the first indicator value, of the last bar index.
	Define values1 As Number = IndicatorValue(_indicatorKeys1(symbolIndex))
	 ' Get the second indicator value, of the last bar index.
	Define values2 As Number = IndicatorValue(_indicatorKeys2(symbolIndex))
	
	Return values1 - values2

Copyright © 2010 IQBroker, LLC. All rights reserved.