Skip to content
Open RaamTrade

BalanceOfPower — Balance of Power

Where the close finished relative to the open, scaled by the bar’s range: +1 when the bar closed at its high after opening at its low, −1 for the reverse. A candle-body gauge as a number, usually smoothed.

Signature

BalanceOfPower(period, on=<source>)
Argument Type Required Notes
period int Param or literal Yes SMA smoothing window. 1 returns the raw per-bar value. Bounds 1–200.
on= symbol No Source symbol. Defaults to the trade symbol. Reads open, high, low, close.

Formula

$$ \text{BOP}_t = \frac{C_t - O_t}{H_t - L_t} $$

0 on a bar with no range. With period > 1, the simple average of the last period values.

Warmup

period bars; partial average during the lead-in.

Reading the value

bop.value
bop > 0

Example

class BodyBias(Strategy):
"""Long while smoothed balance of power is positive."""
smooth = Param(14, min=1, max=200)
trade = Symbol()
sizing = FixedCapital()
def execute(self):
bop = BalanceOfPower(self.smooth, on=self.trade)
if bop.value > 0.1 and self.trade.is_flat:
self.buy(self.trade, reason="Buyers holding the bars")
if bop.value < 0 and self.trade.is_long:
self.sell(self.trade, self.trade.position, reason="Bias flipped")

Notes

  • Igor Livshin’s Balance of Power.
  • period=1 gives the raw, unsmoothed bar-by-bar value; a longer period averages it.