Skip to content
Open RaamTrade

DonchianHighTrue — Donchian High (True)

The rolling maximum of the true highs over the window — the upper line of the textbook Donchian channel. The seeded DonchianHigh uses closes; this is the form the Turtle rules and the breakout literature mean.

Signature

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

Formula

$$ \text{DH}t = \max(H{t-n+1} \ldots H_t) $$

Warmup

period bars. During the lead-in it returns the maximum of the bars seen so far (an honest partial channel), not a sentinel.

Reading the value

dh.value
dh.value_at(1)
self.trade.close >= dh.value_at(1) # breakout above yesterday's channel

Example

class ChannelBreakout(Strategy):
"""Classic Donchian breakout: buy a close above the prior 20-bar high."""
period = Param(20, min=1, max=400)
trade = Symbol()
sizing = FixedCapital()
def execute(self):
dh = DonchianHighTrue(self.period, on=self.trade)
dl = DonchianLowTrue(self.period, on=self.trade)
if self.trade.close >= dh.value_at(1) and self.trade.is_flat:
self.buy(self.trade, reason="20-bar high broken")
if self.trade.close <= dl.value_at(1) and self.trade.is_long:
self.sell(self.trade, self.trade.position, reason="20-bar low broken")

Notes

  • Richard Donchian’s channel, on true highs.
  • Proven by an assert-via-trade run on SPY daily (matched a strategy-side rolling max on every bar; zero alarm trades).
  • Compare against value_at(1) for breakout logic — the current bar’s high is already inside today’s channel, so close >= dh.value can never be strictly above.