◆ New — Strategy Validator, Code Fixer & Prop Compliance Checker are live. Try one free →
Home / Indicators / Williams Alligator
Trend indicator

Williams Alligator

Three forward-shifted smoothed moving averages — the Jaw, Teeth, and Lips — used to visualize when a market is trending versus 'sleeping'.

Illustrative diagram — not live market data.

What it is

The Williams Alligator is a trend-visualization tool developed by Bill Williams and popularized as a default indicator in MetaTrader 4 and 5. It plots three smoothed moving averages (SMMAs) of the median price (high plus low, divided by two) directly on the price chart: the Jaw (13-period, shifted 8 bars into the future), the Teeth (8-period, shifted 5 bars forward), and the Lips (5-period, shifted 3 bars forward). Williams framed the tool with a metaphor — when the three lines are intertwined the alligator is 'sleeping' (a range), and when they fan apart in order it is 'eating' (a trend). Strip away the metaphor and it is three moving averages of different lengths, each displaced to the right. That forward displacement is the detail most explanations skip: the line drawn under today's bar was actually calculated several bars ago, so the 'current' Alligator partly describes the past. The Alligator is descriptive, not predictive — it summarizes recent price behaviour and cannot forecast what comes next. This is educational material only, not financial advice, and all trading carries risk of loss.

How it works

Each line is a smoothed moving average — Wilder-style smoothing, the same running average that powers RSI and ATR, equivalent to ta.rma in Pine Script — applied to the median price (high + low) / 2. The Jaw averages 13 bars, the Teeth 8 bars, and the Lips 5 bars, so the Lips reacts fastest and the Jaw slowest. Each line is then plotted with a forward offset: the Jaw 8 bars ahead, the Teeth 5, the Lips 3. This shift is purely visual — it moves already-computed values to the right on the chart; it does not compute anything about future bars. The practical consequence matters for anyone coding or backtesting it: the Alligator value displayed under the bar you are looking at was calculated from data ending 3 to 8 bars earlier. A naive backtest that reads the plotted (shifted) line as if it were known on that bar is comparing today's price against an average that, in live trading, would have been sitting several bars to the left. When the three averages are close together, recent price has been directionless; when the Lips pulls away from the Teeth and the Teeth from the Jaw, shorter-term averages are separating from longer-term ones — the standard signature of a directional move that has already begun, since every moving average lags by construction.

How traders read it

Common settings

The standard configuration is Jaw = 13-period SMMA shifted 8 bars forward, Teeth = 8-period SMMA shifted 5 bars forward, and Lips = 5-period SMMA shifted 3 bars forward, all applied to median price (hl2). These are Bill Williams' original values and the MT4/MT5 defaults; they are conventions rather than optimized numbers. Some traders lengthen all three on higher timeframes for smoothness. Note that some platforms substitute an EMA or SMA for the SMMA, which produces visibly different lines from MetaTrader's — worth checking before comparing values across platforms.

Strengths

Pitfalls to watch

Pine v6 example

//@version=6
indicator("Williams Alligator Example", overlay = true)

jawLen   = input.int(13, "Jaw Length",   minval = 1)
teethLen = input.int(8,  "Teeth Length", minval = 1)
lipsLen  = input.int(5,  "Lips Length",  minval = 1)
jawOff   = input.int(8,  "Jaw Offset",   minval = 0)
teethOff = input.int(5,  "Teeth Offset", minval = 0)
lipsOff  = input.int(3,  "Lips Offset",  minval = 0)
src      = input.source(hl2, "Source")

// SMMA (Wilder smoothing) is ta.rma in Pine v6
jaw   = ta.rma(src, jawLen)
teeth = ta.rma(src, teethLen)
lips  = ta.rma(src, lipsLen)

// offset shifts the plot visually; the values are NOT known that early
plot(jaw,   "Jaw",   color = color.blue,  offset = jawOff)
plot(teeth, "Teeth", color = color.red,   offset = teethOff)
plot(lips,  "Lips",  color = color.green, offset = lipsOff)

Pro tip: When translating Alligator rules into code, drop the visual offsets and work with the unshifted ta.rma values — that is what would actually have been known on each bar. If a backtest of an Alligator idea looks dramatically better when the shifted lines are used, that improvement is lookahead, not edge. This is educational information only, not financial advice; no indicator predicts price, and all trading carries risk of loss.

Built an indicator from this? Run it through the Validator to catch look-ahead bias and repainting, or convert a strategy to Pine Script.

Educational only — not financial advice, not a recommendation to trade. No indicator is predictive; trading involves substantial risk of loss.

Catch the bug that compiles.Run auditGet Pro