WilliamsAlligator — Williams Alligator
תוכן זה אינו זמין עדיין בשפה שלך.
Three smoothed averages of the bar midpoint — jaw (13), teeth (8) and lips (5). When they are intertwined the alligator sleeps and the market is rangebound; when they separate in order it is feeding, and there is a trend. The lines are not displaced forward; see the note.
Signature
WilliamsAlligator(jaw_period, teeth_period, lips_period, on=<source>)| Argument | Type | Required | Notes |
|---|---|---|---|
jaw_period |
int Param or literal | Yes | Slowest line. Default 13, bounds 1–400. |
teeth_period |
int Param or literal | Yes | Middle line. Default 8, bounds 1–400. |
lips_period |
int Param or literal | Yes | Fastest line. Default 5, bounds 1–400. |
on= |
symbol | No | Source symbol. Defaults to the trade symbol. Reads high and low. |
Formula
Each line is a smoothed (Wilder) moving average of the median price:
$$ L_t = L_{t-1} + \frac{(H_t + L_t)/2 - L_{t-1}}{n} $$
Warmup
The three SMMAs seed from the first median price and converge over roughly 3 × jaw_period
bars.
Reading the value
alg.jawalg.teethalg.lipsalg.lips > alg.teeth and alg.teeth > alg.jawMulti-value: cannot be chained onto or crossed.
Example
class AlligatorFeeding(Strategy): """Trade only when the three lines are separated and correctly ordered.""" trade = Symbol() sizing = FixedCapital()
def execute(self): alg = WilliamsAlligator(13, 8, 5, on=self.trade) ordered = alg.lips > alg.teeth and alg.teeth > alg.jaw if ordered and self.trade.close > alg.lips and self.trade.is_flat: self.buy(self.trade, reason="Alligator feeding") if alg.lips < alg.teeth and self.trade.is_long: self.sell(self.trade, self.trade.position, reason="Alligator sleeping")Notes
- Bill Williams, Trading Chaos (1995).
- Drawn displaced, read undisplaced. As Williams plots it, the chart draws the jaw, teeth and
lips 8, 5 and 3 bars forward (
offset=on the draw verbs). A strategy reads all three at the bar that computed them — the standard SMMAs, the values that exist now. - Proven by an assert-via-trade run on SPY daily (the jaw converged to an independent SMMA replication within 0.05; zero alarm trades).