Thursday, September 09, 2010

Balance of Power [BOP]

Descripton
Summary:
This indicator script measures the balance between the bulls and the bears by assessing the ability of each to push price to an extreme level.

Calculation:
The closing price minus the opening price divided by the high price minus the low price.

Developer:
Igor Livshin

Interpretation: 
1. Upwards Trend: When the indicator script is moving upwards, the underlying symbol is in an upwards trend.
2. Downwards Trend: When the indicator script is moving downwards, the underlying symbol is in a downwards trend.
3. Positive Divergence:  When the underlying symbol is moving downwards, but the indicator script is moving upwards, the underlying symbol is likely to reverse direction and move upwards.
4. Negative Divergence:  When the underlying symbol is moving upwards, but the indicator script is moving downwards, the underlying symbol is likely to reverse direction and move downwards.
5. Overbought:  When the underlying symbol is moving upwards, but the indicator script is approaching its upper bound, the underlying symbol is likely to reverse direction and move downwards.
6. Oversold: When the underlying symbol is moving downwards, but the indicator script is approaching its lower bound, the underlying symbol is likely to reverse direction and move upwards.


Variables
TypeIdentifierDescription
Integer_symbolIndexUse for the underlying symbol index on which to calculate the Balance of Power.

OnInitialize
Function Parameters
TypeIdentifierDescription
SymbolsymbolIndexUse for the underlying symbol index on which to calculate the Balance of Power.
Implementation
	_symbolIndex = symbolIndex

OnValues
Function Parameters
TypeIdentifierDescription
IntegerbarIndex
Integerlength
Implementation
	 ' Get the opening prices of the symbol bars, indexed by bar index.
	Define open() As Number = BarOpen(_symbolIndex, barIndex, length)
	 ' Get the highest prices of the symbol bars, indexed by bar index.
	Define high() As Number = BarHigh(_symbolIndex, barIndex, length)
	 ' Get the lowest prices of the symbol bars, indexed by bar index.
	Define low() As Number = BarLow(_symbolIndex, barIndex, length)
	 ' Get the closing prices of the symbol bars, indexed by bar index.
	Define close() As Number = BarClose(_symbolIndex, barIndex, length)
	 ' Use for the calculated Balance of Power.
	Define results(length - 1) As Number
	 ' Calculate the Balance of Power values for the specified bar range.
	For i As Integer = length - 1 To 0 Step -1
		 ' Calculate and assign the Balance of Power value for the current bar.
		results(i) = (close(i) - open(i)) /  (high(i) - low(i))
	Next
	Return results

Copyright © 2010 IQBroker, LLC. All rights reserved.