Gator Oscillator
Gator Oscillator, Bill Williams' — the absolute gaps between the Alligator's lines, drawn as two histograms above and below zero.
It measures how far apart the three averages are, which is the Alligator's shape reduced to two numbers. Readings: both histograms growing, and both shrinking; the bar colours encode only growth against the previous bar.
01The study, live
Computed by Bentrix’s own code over the same synthetic bars on every page — an illustration of how the study behaves, not a market.
What this figure shows
The figure is computed over 300 sample bars. Gator Oscillator has no value on the first 16 — the bars it needs before it can answer — and its first value stands on bar 17. Its bars run between 2.5e-05 and 0.0029 on these bars, and the last value is 0.00072. Counting the conditions the study declares on these bars: turns up 31 times; turns down 31 times. Press a condition under the figure to see each place marked. As states rather than moments: is rising on 140 bars; is falling on 143 bars.
02Its parts, named
03What you see
Two histograms in their own pane, one above zero and one below. The upper is the distance between the Alligator's jaw and teeth; the lower, drawn downward, the distance between its teeth and lips. Each bar is coloured by whether it grew or shrank from the bar before.
04Where it comes from
Bill Williams introduced the Alligator — three smoothed, shifted averages — and the Gator Oscillator that restates it in New Trading Dimensions (1998). He described the market in the Alligator's terms: sleeping when the lines are intertwined, waking as they part, eating while they spread, and sated as they come together again.
05The formula
With the Alligator's jaw (13, shifted 8), teeth (8, shifted 5) and lips (5, shifted 3):
Upperₜ = | Jawₜ − Teethₜ |, Lowerₜ = −| Teethₜ − Lipsₜ |
06A worked example
The Gator draws the gaps between the Alligator's three lines as two histograms. Suppose that under some bar the three lines, as drawn (after their shifts), read Jaw 100.40, Teeth 100.90 and Lips 101.20.
- the upper bar is the gap between Jaw and Teeth: |100.40 − 100.90| = 0.50, drawn above zero
- the lower bar is the gap between Teeth and Lips: |100.90 − 101.20| = 0.30, drawn below zero as −0.30
On the bar before the gaps were 0.42 and 0.33. The upper bar grew (0.42 → 0.50): it is drawn in the growing colour. The lower shrank in size (0.33 → 0.30): the other colour.
No direction survives the absolute values. The same picture appears whether the lines are fanned upward or downward.
On real bars: take eight with highs 21, 22, 24, 24, 25, 26, 26, 27 and lows 18, 19, 20, 21, 21, 23, 23, 23, with periods of 4, 3 and 2 and no shifts. On the last bar the three lines read 23.40, 23.88 and 24.48, so the upper bar is 0.48 and the lower −0.60.
07Built in Assay
The same study written in Assay, Bentrix’s script language, and drawn by Bentrix itself as the script’s graph: each block is one step of the formula. On the ladder the steps stand in the script’s order, one a row; on the board each wire carries a value from the block that gives it to the block that reads it, left to right. The script computes exactly what the study computes — Bentrix checks the two against each other, candle by candle.
//@version=6 indicator("Bill Williams' Gator Oscillator") // The Alligator's three lines: smoothed averages of the bar's middle price. jaws = ta.rma(hl2, 13) teeth = ta.rma(hl2, 8) lips = ta.rma(hl2, 5) // The gap between the jaws and the teeth, and between the teeth and the lips, as the // Alligator draws them (jaws 8 bars forward, teeth 5, lips 3). upper = bar_index >= 16 ? math.abs(jaws[3] - teeth) : na lower = bar_index >= 10 ? -math.abs(teeth[2] - lips) : na plot(upper, "Upper", style = plot.style_histogram) plot(lower, "Lower", style = plot.style_histogram)
Paste it into the Assay IDE to put it on a chart, or to change it. Looking at the graph is free in every package; editing it as blocks is Plus.
08Readings — what traders look for
Both sides growing. Read as the three lines spreading apart — Williams' eating phase, a market moving away from its averages.
Both sides shrinking. Read as the lines converging — the sated and sleeping phases.
One side growing, the other shrinking. Read as a transition: the faster lines turning while the slower have not.
How the four phases fail. Williams named the colour combinations — sleeping, awakening, eating, sated. They describe how the gaps between three lagging averages are changing; each phase is recognised only after it has begun, and short moves pass through all four in a few bars.
09In different markets and timeframes
The Gator draws the gaps between the Alligator's lines; its phases are recognised only after they begin, and short moves pass through all of them in a few bars.
Its windows are the Alligator's 13, 8 and 5 with shifts of 8, 5 and 3, so it speaks about the last two to three weeks of daily bars. A trend has to last several times that for all four phases to be seen in order; a move of ten bars passes from sleeping to sated before the bars have grown. In a range both sides stay short and change colour constantly. Williams used it on daily bars; on M1 the three averages are within a few points of each other most of the time and the histogram's size is mostly spread and noise.
10With other studies
Read under the Alligator it is made from.
11What it does not tell you
It is the Alligator's three lines restated as two distances, so it carries their lag. It has no direction: a spreading Alligator in a fall draws the same bars as one in a rise.
12Inputs and defaults
- 1Jaw period — 13The Alligator's slowest line (13).
- 2Jaw shift — 8The Jaw's forward shift (8).
- 3Lips period — 5Its fastest line (5).
- 4Lips shift — 3The Lips' forward shift (3).
- 5Teeth period — 8Its middle line (8).
- 6Teeth shift — 5The Teeth's forward shift (5).
- 7Average — The study's ownThe kind of moving average inside the study. Left at the study's own, it is the one the study's calculation uses by itself.
- 8Price — The study's ownThe price the study reads. Left at the study's own, it is the one the study was designed on.
- 9Timeframe — ChartThe chart's own by default; any higher one, read on the last closed candle. A finer one is never offered.
- 10Wait for the candle to close — OnThe value of a higher timeframe is taken only from a candle that has finished.
What each input changes
- AverageThe kind of average the three lines are: smoothed (the default, Williams' own), simple, exponential or linear-weighted.
- PriceThe price the three lines are computed from. Left at the study's own it is the median price, (High + Low) / 2, which is what Williams used.
- In useThe Alligator's own numbers: 13/8/5 and 8/5/3.
13Limits and common misreadings
The shifts. The lines are shifted forward in time; the histograms describe averages of prices already past.
Colours are only bar-to-bar. A colour change is one bar's difference, not a change of phase.
14Conditions an alert or a strategy can watch
an event happens on one bar a state holds on every bar while it lasts
These are the conditions the study itself declares — the same rules the alert editor and the strategy engine read, and the ones the figure's chips show.
15Practise it in the laboratory
Attach the Alligator and the Gator together. Step through one long move and mark where both histograms first grew together and where they first both shrank; compare those bars with where price itself turned.
Open the laboratory17In Bentrix
- From the menu: a chart's Indicators button › Bill Williams › Gator Oscillator, or type Gator Oscillator in its search.
- Its settings: the settings card opens when it is added; its legend's name opens it again.
18From an agent or a program
Two tools reach it. study_values computes it over a workbench’s candles up to the clock — no chart needed — and study_attach puts it on a chart, where it is drawn and saved with the chart ({"chart": "<chart uri>", "kind": "gator"}).
The study, as a chart files it
This is a new Gator Oscillator’s entry — its kind, its calculation, the price it reads and its settings. Change a setting here to read it with other inputs.
{
"applied": "close",
"convention": "mt5",
"kind": "gator",
"settings": {
"jaw": 13,
"jaw_shift": 8,
"lips": 5,
"lips_shift": 3,
"shape": "alligator",
"teeth": 8,
"teeth_shift": 5
}
}An agent
An agent calls the MCP tool with it:
{
"name": "study_values",
"arguments": {
"bench": "bentrix://lab/\u2026/bench/\u2026",
"symbol": "EURUSD",
"timeframe": "H1",
"limit": 5,
"study": {
"applied": "close",
"convention": "mt5",
"kind": "gator",
"settings": {
"jaw": 13,
"jaw_shift": 8,
"lips": 5,
"lips_shift": 3,
"shape": "alligator",
"teeth": 8,
"teeth_shift": 5
}
}
}
}A program
A program does the same in its language — bench and market as in the built-in indicators guide:
Python
values = client.study.values(bench, market, "H1", {"applied": "close", "convention": "mt5", "kind": "gator", "settings": {"jaw": 13, "jaw_shift": 8, "lips": 5, "lips_shift": 3, "shape": "alligator", "teeth": 8, "teeth_shift": 5}}, limit=5)
print("times:", values["times"])
for line in values["lines"]:
print("line:", line["line"])
print(" newest values:", line["values"])JavaScript
const values = await client.study.values({ bench, symbol: market, timeframe: "H1", study: { "applied": "close", "convention": "mt5", "kind": "gator", "settings": { "jaw": 13, "jaw_shift": 8, "lips": 5, "lips_shift": 3, "shape": "alligator", "teeth": 8, "teeth_shift": 5 } }, limit: 5 });
console.log("times:", values.times);
for (const line of values.lines) {
console.log("line:", line.line);
console.log(" newest values:", line.values);
}C#
var values = await client.Study.Values(bench, market, "H1", new Dictionary<string, object?> { ["applied"] = "close", ["convention"] = "mt5", ["kind"] = "gator", ["settings"] = new Dictionary<string, object?> { ["jaw"] = 13, ["jaw_shift"] = 8, ["lips"] = 5, ["lips_shift"] = 3, ["shape"] = "alligator", ["teeth"] = 8, ["teeth_shift"] = 5 } }, limit: 5);
Console.WriteLine($"times: {values!["times"]!}");
foreach (var line in values!["lines"]!.AsArray())
{
Console.WriteLine($"line: {line!["line"]!}");
Console.WriteLine($" newest values: {line!["values"]!}");
}Go
values := must(client.Study.Values(ctx, mcp.StudyValuesArgs{Bench: bench, Symbol: market, Timeframe: "H1", Study: map[string]any{"applied": "close", "convention": "mt5", "kind": "gator", "settings": map[string]any{"jaw": 13, "jaw_shift": 8, "lips": 5, "lips_shift": 3, "shape": "alligator", "teeth": 8, "teeth_shift": 5}}, Limit: mcp.Ptr[int64](5)}))
fmt.Println("times:", at(values, "times"))
for _, line := range at(values, "lines").([]any) {
fmt.Println("line:", at(line, "line"))
fmt.Println(" newest values:", at(line, "values"))
}Java
Object values = client.study.values(new Bentrix.StudyApi.ValuesArgs(bench, market, "H1", obj("applied", "close", "convention", "mt5", "kind", "gator", "settings", obj("jaw", 13, "jaw_shift", 8, "lips", 5, "lips_shift", 3, "shape", "alligator", "teeth", 8, "teeth_shift", 5))).limit(5L));
System.out.println("times:" + " " + at(values, "times"));
for (Object line : (List<Object>) at(values, "lines")) {
System.out.println("line:" + " " + at(line, "line"));
System.out.println(" newest values:" + " " + at(line, "values"));
}C++
auto values = client.study.values_(StudyApi::ValuesArgs(bench, market, "H1", Json::Object{{"applied", "close"}, {"convention", "mt5"}, {"kind", "gator"}, {"settings", Json::Object{{"jaw", 13}, {"jaw_shift", 8}, {"lips", 5}, {"lips_shift", 3}, {"shape", "alligator"}, {"teeth", 8}, {"teeth_shift", 5}}}}).limit(5));
std::cout << "times:" << " " << values["times"].dump() << std::endl;
for (const Json &line : values["lines"].arr()) {
std::cout << "line:" << " " << line["line"].dump() << std::endl;
std::cout << " newest values:" << " " << line["values"].dump() << std::endl;
}Julia
values = client.study.values(bench, market, "H1", Dict{String,Any}("applied" => "close", "convention" => "mt5", "kind" => "gator", "settings" => Dict{String,Any}("jaw" => 13, "jaw_shift" => 8, "lips" => 5, "lips_shift" => 3, "shape" => "alligator", "teeth" => 8, "teeth_shift" => 5)); limit = 5)
println("times:", " ", values["times"])
for line in values["lines"]
println("line:", " ", line["line"])
println(" newest values:", " ", line["values"])
endR
values <- client$study$values(bench, market, "H1", list(applied = "close", convention = "mt5", kind = "gator", settings = list(jaw = 13, jaw_shift = 8, lips = 5, lips_shift = 3, shape = "alligator", teeth = 8, teeth_shift = 5)), limit = 5)
cat("times:", format(values$times), "\n")
for (line in values$lines) {
cat("line:", format(line$line), "\n")
cat(" newest values:", format(line$values), "\n")
}Rust
let values = client.study().values(mcp::StudyValuesArgs::new(bench.clone(), market.clone(), "H1", serde_json::json!({"applied": "close", "convention": "mt5", "kind": "gator", "settings": {"jaw": 13, "jaw_shift": 8, "lips": 5, "lips_shift": 3, "shape": "alligator", "teeth": 8, "teeth_shift": 5}})).limit(5))?;
println!("times: {}", values["times"]);
for line in values["lines"].as_array().into_iter().flatten() {
println!("line: {}", line["line"]);
println!(" newest values: {}", line["values"]);
}Reading the answer
times— the candles’ open times, in milliseconds since 1970 (UTC), oldest first.lines— one entry per line, in this order, each with itslinename and itsvalues;values[i]belongs to the candle attimes[i].- The last value is the candle at the clock’s, which may still be forming: it changes until that candle closes, as on the chart. Nothing after the clock is ever computed.
nullis a candle with no value yet — the warm-up, about 1 × the period at the start of the history.- Its fixed levels, drawn on the chart:
[0.0].
line | What it is |
|---|---|
Main | the indicator's own value |
MinusDi | the directional movement down (−DI) |
In a strategy
Filed under a key of your choice in a strategy document’s studies — here gator: {"gator": {"applied": "close", "convention": "mt5", "kind": "gator", "settings": {"jaw": 13, "jaw_shift": 8, "lips": 5, "lips_shift": 3, "shape": "alligator", "teeth": 8, "teeth_shift": 5}}} — its rules can name:
| Write | What it is |
|---|---|
gator | its main line, as a value in a compare |
gator.minus_di | this line, as a value in a compare |
{"cond": "gator:line.turns_up"} | a condition it declares itself |
{"cond": "gator:line.turns_down"} | a condition it declares itself |
{"cond": "gator:line.rising"} | a condition it declares itself |
{"cond": "gator:line.falling"} | a condition it declares itself |
19Sources
- Williams, Bill. New Trading Dimensions. Wiley, 1998.
Bentrix 0.1.382Every number, name and default on these pages is read from the application itself.What is comingWhat changed