Saturday, September 04, 2010

Aroon Up [ARNU]

Descripton
Summary:
This indicator script helps to determine whether the underlying symbol is trending or in a trading range.

Calculation:
The number of bars since the most recent high in an n-period window.

Range:
0 To 100

Developer:
Tushar S. Chande

Interpretation: 
1. Trending: When the indicator script reaches 70 to 100 the underlying indicator is in an upwards trend.
2. Trading Range: When the indicator script reaches 0 the underlying indicator isn't in an upwards trend. (But it could be in a downwards trend).


Variables
TypeIdentifierDescription
Integer_indicatorKeyUse for the underlying indicator key on which to calculate the Aroon Up.
Integer_periodsUse for the number of periods to include in the Aroon Up calculation.

OnInitialize
Function Parameters
TypeIdentifierDescription
IndicatorindicatorKeyUse for the underlying indicator key on which to calculate the Aroon Up.
IntegerperiodsUse for the number of periods to include in the Aroon Up calculation. [Default 10]
Implementation
	 ' Assign the parameters to script variables.
	_indicatorKey = indicatorKey 
	_periods = periods

OnValues
Function Parameters
TypeIdentifierDescription
IntegerbarIndex
Integerlength
Implementation
	 ' Get the underlying indicator values, indexed by bar index.  
	Define values() As Number = IndicatorValues(_indicatorKey, barIndex, length + _periods)
	 ' Use for the number of bars since the lowest value.
	Define barsFromHighest As Integer
	 ' Use for the highest value in the window.
	Define highest As Number
	 ' Use for the calculated Aroon Up values, indexed by bar index.
	Define results(length - 1) As Number
	 ' Calculate the Aroon Up values for the specified bar range.
	For i As Integer = length - 1 To 0 Step -1
		 ' Calculate the Aroon Up value for the current bar.
		barsFromHighest = _periods
		highest = 0
		For j As Integer = i + _periods To i Step -1
			If (values(j) >= highest) Then
				barsFromHighest = j - i
				highest = values(j)
			End If
		Next
		 ' Assign the Aroon Up value for the current bar.
		results(i) = ((_periods - barsFromHighest) / _periods) * 100
	Next
	Return results

Copyright © 2010 IQBroker, LLC. All rights reserved.