Skip to content
Open RaamTrade

QStick

The average of (close − open) over N bars: have candles been closing above or below where they opened? Positive is a run of white bodies, negative a run of black ones — a candle-chart read expressed as a number.

Signature

QStick(period, on=<source>)
Argument Type Required Notes
period int Param or literal Yes Window. Default 8, bounds 1–400.
on= symbol No Source symbol. Defaults to the trade symbol. Reads open and close.

Formula

$$ \text{QStick} = \frac{1}{n}\sum_{i} (C_i - O_i) $$

Warmup

period bars; partial average during the lead-in.

Reading the value

q.value
q > 0
q.crossed_above(0)

Example

class QStickBias(Strategy):
"""Long while candle bodies are net positive."""
trade = Symbol()
sizing = FixedCapital()
def execute(self):
q = QStick(8, on=self.trade)
if q.crossed_above(0) and self.trade.is_flat:
self.buy(self.trade, reason="Bodies turned positive")
if q.crossed_below(0) and self.trade.is_long:
self.sell(self.trade, self.trade.position, reason="Bodies turned negative")

Notes

  • Tushar Chande.
  • In price units, so it is not comparable across instruments — divide by price or by ATR if you need that. BalanceOfPower is the range-normalised cousin.