Balance of Power

Technical Analysis Indicator: bop

Fork me on GitHub

Function Prototype

/* Balance of Power */
/* Type: indicator */
/* Input arrays: 4    Options: 0    Output arrays: 1 */
/* Inputs: open, high, low, close */
/* Options: none */
/* Outputs: bop */
int ti_bop_start(TI_REAL const *options);
int ti_bop(int size,
      TI_REAL const *const *inputs,
      TI_REAL const *options,
      TI_REAL *const *outputs);

Description

This documentation is still a work in progress. It has omissions, and it probably has errors too. If you see any issues, or have any general feedback, please get in touch.

Balance of Power compares the strength of buyers and sellers.

It is calculated as follows:

$$bop_{t} = \frac{close_{t}-open_{t}}{high_{t}-low_{t}}$$

References

Example Usage

Calling From C

/* Example usage of Balance of Power */
/* Assuming that 'open', 'high', 'low', and 'close' are pre-loaded arrays of size 'in_size'. */
TI_REAL *inputs[] = {open, high, low, close};
TI_REAL options[] = {}; /* No options */
TI_REAL *outputs[1]; /* bop */

/* Determine how large the output size is for our options. */
const int out_size = in_size - ti_bop_start(options);

/* Allocate memory for output. */
outputs[0] = malloc(sizeof(TI_REAL) * out_size); assert(outputs[0] != 0); /* bop */

/* Run the actual calculation. */
const int ret = ti_bop(in_size, inputs, options, outputs);
assert(ret == TI_OKAY);

Calling From Lua (with Tulip Chart bindings)

-- Example usage of Balance of Power
bop = ti.bop(open, high, low, close)

Example Calculation

dateopenhighlowclosebop
2005-11-0181.8582.1581.2981.59-0.30
2005-11-0281.2081.8980.6481.06-0.11
2005-11-0381.5583.0381.3182.870.77
2005-11-0482.9183.3082.6583.000.14
2005-11-0783.1083.8583.0783.610.65
2005-11-0883.4183.9083.1183.15-0.33
2005-11-0982.7183.3382.4982.840.16
2005-11-1082.7084.3082.3083.990.65
2005-11-1184.2084.8484.1584.550.51
2005-11-1484.2585.0084.1184.360.12
2005-11-1584.0385.9084.0385.530.80
2005-11-1685.4586.5885.3986.540.92
2005-11-1786.1886.9885.7686.890.58
2005-11-1888.0088.0087.1787.77-0.28
2005-11-2187.6087.8787.0187.29-0.36

Chart

 

Other Indicators

Previous indicator: Bollinger Bands

Next indicator: Commodity Channel Index

Random indicator: Crossover