Skip to content
Open RaamTrade

HighLowMAChannel: High/Low MA Channel

A simple average of the highs over a simple average of the lows, with their midline. Smoother than a Donchian channel: it tracks the typical extreme rather than the single worst one, so a one-bar spike does not widen it for n bars.

Signature

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

Formula

$$ \text{upper} = \text{SMA}(H, n), \quad \text{lower} = \text{SMA}(L, n), \quad \text{mid} = \frac{\text{upper}+\text{lower}}{2} $$

Warmup

period bars; partial averages during the lead-in.

Reading the value

ch.upper
ch.mid
ch.lower

Multi-value: cannot be chained onto or crossed.

Example

class ChannelRide(Strategy):
"""Buy strength above the average high, exit below the midline."""
trade = Symbol()
sizing = FixedCapital()
def execute(self):
ch = HighLowMAChannel(20, on=self.trade)
if self.trade.close > ch.upper and self.trade.is_flat:
self.buy(self.trade, reason="Above the channel")
if self.trade.close < ch.mid and self.trade.is_long:
self.sell(self.trade, self.trade.position, reason="Below midline")

Notes

  • The classic high/low moving-average band.
  • Proven by an assert-via-trade run on SPY daily (all three outputs matched a strategy-side reference to 1e-3 on every bar; zero alarm trades).
  • Compare PriceChannel when you want the true extremes rather than their average.