Williams Alligator (ALLIGATOR)
Summary
Bill Williams' Alligator (Trading Chaos, 1995): three smoothed moving averages of the median price. The Jaw, Teeth and Lips are each drawn a few bars ahead of the bar that computed it. When the three lines are intertwined the alligator sleeps and the market has no trend; when they fan out in order, Lips above Teeth above Jaw or the reverse, it is feeding and a trend is under way. Price crossing back into the lines is read as the trend tiring.
The Alligator is a leg of Williams' Profitunity system, alongside the Awesome Oscillator (AO) and the Accelerator/Decelerator (AC).
Chart
Chart metadata i
Drawn on the price pane over candles, with outJaw as a solid line moved 8 bars forward, outTeeth as a solid line moved 5 bars forward and outLips as a solid line moved 3 bars forward.
Metadata flags used: overlap · inPriceHL: high, low · outJaw: line, display_shift (+8) · outTeeth: line, display_shift (+5) · outLips: line, display_shift (+3)
Reference data (CSV) · Chart (SVG)
Formula
median_t = ( high_t + low_t ) / 2
Jaw_t = SMMA(median, jawPeriod)_t
Teeth_t = SMMA(median, teethPeriod)_t
Lips_t = SMMA(median, lipsPeriod)_t
SMMA is Wilder's smoothed moving average (RMA): seeded with the simple average of its first n values, then SMMA_t = SMMA_t−1 + ( x_t − SMMA_t−1 ) / n.
Notes
- Each line is
TA_RMAofTA_MEDPRICEover its own period. Williams draws the lines ahead of price; that is a display shift:TA_ALLIGATOR_DisplayShiftreports each line's shift, and it changes nothing about the values, the lookback or the returned range. Every output is written at the bar that computed it, so the lastshiftvalues of a line are the part a chart draws past the last bar. - All three lines start at the bar of the longest period, and each shorter line seeds over the bars its own lookback reaches back from there, not at the first bar of the series. A chart that seeds every line at the first bar draws different short lines until the seed has decayed; setting the
RMAunstable period closes the gap.
Inputs
inHigh— High price of each barinLow— Low price of each bar
Outputs
outJaw— Jaw: the slowest line, drawn ahead by the jaw shiftoutTeeth— Teeth: the middle line, drawn ahead by the teeth shiftoutLips— Lips: the fastest line, drawn ahead by the lips shift
Parameters
| Parameter | Type | Default | Accepted values | Description |
|---|---|---|---|---|
optInJawPeriod | integer | 13 | 1–100000 | Number of bars in the jaw's smoothed moving average. |
optInJawShift | integer | 8 | 0–100000 | Bars ahead of the computing bar at which a chart draws the jaw. |
optInTeethPeriod | integer | 8 | 1–100000 | Number of bars in the teeth's smoothed moving average. |
optInTeethShift | integer | 5 | 0–100000 | Bars ahead of the computing bar at which a chart draws the teeth. |
optInLipsPeriod | integer | 5 | 1–100000 | Number of bars in the lips' smoothed moving average. |
optInLipsShift | integer | 3 | 0–100000 | Bars ahead of the computing bar at which a chart draws the lips. |
Properties
Numerical Stability: Initial Unstable Period — Inherited from RMA, which ALLIGATOR computes internally; tunable via RMA's unstable period.
| ✅ Overlap Input i |
| ☐ Independent Y-Axis |
| ☐ Candlestick |
| ☐ Can Output NaN or ±Inf |
| ☐ Identity at Period 1 |
| ✅ Display Shift i |
| ☐ Uses Transcendental |
| ☐ Input Must Be Positive |
Example
#include <stdio.h>
#include <ta_libc.h>
int n = 252;
double high[252]; /* your data, oldest first */
double low[252]; /* your data, oldest first */
double jaw[252], teeth[252], lips[252];
int outBegIdx, outNBElement;
TA_Initialize();
TA_ALLIGATOR( 0, n - 1, high, low, 13, 8, 8, 5, 5, 3, &outBegIdx, &outNBElement, jaw, teeth, lips );
printf( "%d values from bar %d; last jaw = %f\n", outNBElement, outBegIdx, jaw[outNBElement - 1] );use ta_lib::Core;
let high = vec![0.0; 252]; // your data, oldest first
let low = vec![0.0; 252]; // your data, oldest first
let mut jaw = vec![0.0; 252];
let mut teeth = vec![0.0; 252];
let mut lips = vec![0.0; 252];
let core = Core::new();
let range = core.alligator(0, high.len() - 1, &high, &low, 13, 8, 8, 5, 5, 3,
&mut jaw, &mut teeth, &mut lips)?;
println!("{} values from bar {}; last jaw = {}", range.count, range.beg_idx, jaw[range.count - 1]);import io.github.talib.Core;
import io.github.talib.OutRange;
double[] high = new double[252]; // your data, oldest first
double[] low = new double[252]; // your data, oldest first
double[] jaw = new double[252];
double[] teeth = new double[252];
double[] lips = new double[252];
Core core = Core.DEFAULT;
OutRange r = core.alligator(0, high.length - 1, high, low, 13, 8, 8, 5, 5, 3, jaw, teeth, lips);
System.out.println(r.count() + " values from bar " + r.begIdx() + "; last jaw = " + jaw[r.count() - 1]);using System;
using TALib;
var high = new double[252]; // your data, oldest first
var low = new double[252]; // your data, oldest first
var jaw = new double[252];
var teeth = new double[252];
var lips = new double[252];
var core = Core.Default;
OutRange r = core.Alligator(0, high.Length - 1, high, low, 13, 8, 8, 5, 5, 3, jaw, teeth, lips);
Console.WriteLine($"{r.Count} values from bar {r.BegIdx}; last jaw = {jaw[r.Count - 1]}");import { alligator } from 'ta-lib';
const high = new Float64Array(252); // your data, oldest first
const low = new Float64Array(252); // your data, oldest first
const { begIdx, outJaw, outTeeth, outLips } = alligator({ high, low }, {
jawPeriod: 13,
jawShift: 8,
teethPeriod: 8,
teethShift: 5,
lipsPeriod: 5,
lipsShift: 3,
});
console.log(outJaw.length + ' values from bar ' + begIdx + '; last outJaw = ' + outJaw[outJaw.length - 1]);Implementation
Added in 0.8.4.
TA-Lib Definition: alligator.c · alligator.yaml
| Native | File |
|---|---|
| C | ta_ALLIGATOR.c |
| Rust | alligator.rs |
| Java | Core_ALLIGATOR.java |
| C# | Core_ALLIGATOR.cs |
| TypeScript | alligator.ts |
Python: talib.ALLIGATOR, see ta-lib-python.
TA-Lib is also available for R and more using a wrapper.
Aliases
williams alligator, bill williams alligator, jaw teeth lips
See Also
RMA · MEDPRICE · AO · AC · ICHIMOKU
References
- Bill Williams, Trading Chaos, 1995
- Bill Williams, New Trading Dimensions, 1998
- MetaTrader 5 — Alligator