Tuesday, September 07, 2010

Add Indicators [ADD]

Descripton
Summary:
This indicator script is used to add two underlying indicators.

Calculation:
The sum of the two underlying indicators.


Variables
TypeIdentifierDescription
Integer_indicatorKey1Use for the first underlying indicator to add.
Integer_indicatorKey2Use for the second underlying indicator to add.

OnInitialize
Function Parameters
TypeIdentifierDescription
IndicatorindicatorKey1Use for the first underlying indicator to add.
IndicatorindicatorKey2Use for the second underlying indicator to add.
Implementation
	 ' Assign the parameters to script variables.
	_indicatorKey1 = indicatorKey1
	_indicatorKey2 = indicatorKey2

OnValues
Function Parameters
TypeIdentifierDescription
IntegerbarIndex
Integerlength
Implementation
	 ' Get the underlying indicator values, indexed by bar index. 
	Define values1() As Number = IndicatorValues(_indicatorKey1, barIndex, length)
	 ' Get the underlying indicator values, indexed by bar index. 
	Define values2() As Number = IndicatorValues(_indicatorKey2, barIndex, length)
	 ' Use for the calculated Add Indicators values, indexed by bar index.
	Define results(length - 1) As Number
	 ' Calculate the Add Indicators values for the specified bar range.
	For i As Integer = length - 1 To 0 Step -1
		 ' Calculate and assign the Add Indicators value for the current bar.
		results(i) = values1(i) + values2(i)
	Next
	Return results

Copyright © 2010 IQBroker, LLC. All rights reserved.