Bill Williams indicators
Bill Williams' six indicators: the Alligator, the Gator, Fractals, the Awesome and Accelerator Oscillators and the Market Facilitation Index.
The six Bill Williams indicators. What every indicator shares is on Indicators: reading a line and its position, lines drawn forward or back, the first value, colour lines, volume and what is refused. Each entry below states what is particular to the indicator.
Accelerator Oscillator
AC in the strategy text · a histogram and its colour, in its own pane
Bill Williams' acceleration of momentum: the Awesome Oscillator (the 5-bar simple average of the median price,
(high + low) ÷ 2, less the 34-bar one) less its own 5-bar simple average. Around zero and unbounded, in price units:
above zero the momentum is gaining on its recent average. The text is AC(): no parameters. It reads no volume.
| Line (number, name) | What it is | Drawn | First value on bar |
|---|---|---|---|
0 ac, AC | the oscillator | on its own bar | 37 |
1 color, Colour | 0 when ac rose from the previous bar, 1 when it fell, the previous colour when it did not move; 0 on its first value, which a run never reads (one more bar of warm-up) | read, never drawn as a line | 37 |
- The bars before the first value have no value, on both lines.
No parameters.
Reading it in a rule.
- With
let accel = AC() on EURUSD H1and a constantparam zero = 0,accel.ac[0] > zeroin a candle-close rule (accel.ac[1] > zeroin an On Tick rule) is "the last closed bar above zero", andaccel.color[0] == zero([1]in an On Tick rule) is "the last closed bar was green". - The colour says whether the oscillator rose or fell, not whether it is above zero. An unchanged value keeps the
colour, so
color == zeromeans "the last change was a rise". - In an On Tick rule
[0]is the bar in progress: the oscillator with the median price so far, and its colour against the last closed bar.
Verified value by value against an independent reference (the record).
Alligator
Alligator in the strategy text · three lines over the candles
Three moving averages of the applied price (the median price, (high + low) ÷ 2, by default), all by the same method (smoothed by default; simple, exponential or linear-weighted), each over its own period and drawn forward by its own shift. Lines apart and in order mark a trend; entwined lines, a range ("the Alligator sleeps"). It reads volume only when the applied price is Volume.
| Line (number, name) | What it is | Drawn | First value on bar |
|---|---|---|---|
0 jaw, Jaw | the average over the Jaw Period | Jaw Shift bars forward | Jaw Period − 1 + Jaw Shift |
1 teeth, Teeth | the average over the Teeth Period | Teeth Shift bars forward | Teeth Period − 1 + Teeth Shift |
2 lips, Lips | the average over the Lips Period | Lips Shift bars forward | Lips Period − 1 + Lips Shift |
- The text is
Alligator(jawPeriod, jawShift, teethPeriod, teethShift, lipsPeriod, lipsShift, method, appliedPrice); the method issma,ema,smmaorlwma. - With the exponential method, each line has no value until its period is consumed; its average starts from the first price.
| Field | In the text | Default | Values | Can be swept |
|---|---|---|---|---|
| Jaw Period | jawPeriod, 1st | 13 bars | 1 – 2,500 bars | Yes |
| Jaw Shift | jawShift, 2nd | 8 bars | 0 – 1,000 bars | No |
| Teeth Period | teethPeriod, 3rd | 8 bars | 1 – 2,500 bars | Yes |
| Teeth Shift | teethShift, 4th | 5 bars | 0 – 1,000 bars | No |
| Lips Period | lipsPeriod, 5th | 5 bars | 1 – 2,500 bars | Yes |
| Lips Shift | lipsShift, 6th | 3 bars | 0 – 1,000 bars | No |
| Method | method, 7th | Smma | Sma, Ema, Smma, Lwma | No |
| Applied Price | appliedPrice, 8th | Median | Close, Open, High, Low, Median, Typical, Weighted, Volume | No |
Each period is 1 to 2,500 bars and each shift 0 to 1,000; the lines need not be in Bill Williams' order.
Reading it in a rule.
- A read returns a line as it is drawn.
allig.jaw[0]is the value on the current bar: the jaw average computed Jaw Shift bars ago. With a shift of 1 or more it is a closed bar's value, even in an On Tick rule. "The lines in rising order on the current bar" isallig.lips > allig.teeth and allig.teeth > allig.jaw. - With a shift of 0 a line is a plain moving average, and in an On Tick rule
[0]follows the bar in progress. - The part of each line drawn ahead of the newest bar cannot be read (a negative shift is refused). What a line will show that many bars from now is its average today, which a second Alligator with every shift at 0 gives.
- With the linear-weighted method, the averages carry a slow rounding drift (the drift).
Verified value by value against an independent reference (the record).
Awesome Oscillator
AO in the strategy text · a histogram and its colour, in its own pane
Bill Williams' momentum: the 5-bar simple average of the median price, (high + low) ÷ 2, less the 34-bar one. Around
zero and unbounded, in price units: above zero the short-term average is above the long-term one. The text is AO():
no parameters. It reads no volume.
| Line (number, name) | What it is | Drawn | First value on bar |
|---|---|---|---|
0 ao, AO | the oscillator | on its own bar | 33 |
1 color, Colour | 0 when ao rose from the previous bar, 1 when it fell, the previous colour when it did not move; 0 on its first value, which a run never reads (one more bar of warm-up) | read, never drawn as a line | 33 |
- On the bars before the first value neither line has a value.
No parameters.
Reading it in a rule.
- With
let awesome = AO() on EURUSD H1and a constantparam zero = 0,awesome.ao crosses above zerois the zero-line cross, andawesome.color[0] == zeroin a candle-close rule (awesome.color[1] == zeroin an On Tick rule) is "the last closed bar was green". - The colour says whether the oscillator rose or fell, not whether it is above zero; an unchanged value keeps it.
- Both averages are carried from bar to bar, so on a flat stretch they can sit a rounding residue apart:
aois then a tiny number rather than exactly 0, and its colour can turn on it. - In an On Tick rule
[0]is the bar in progress, with the median price so far.
Verified value by value against an independent reference (the record).
Fractals
Fractals in the strategy text · marks over the candles
Bill Williams' turning points of five bars. An up fractal is a bar whose high is strictly above the highs of the two
bars after it and at or above the highs of the two bars before it; the upper line then holds that high. A down fractal
mirrors it on the lows. Of two equal highs in a row, only the later can be the fractal. On every other bar a line has
no value, and one bar can carry both. The text is Fractals(): no parameters. It reads no volume.
| Line (number, name) | What it is | Drawn | First value on bar |
|---|---|---|---|
0 upper, Upper | the high of an up fractal, on the fractal's own bar | 2 bars back from the bar that confirms it | 2 at the earliest; a read holds it from [2] ([3] in an On Tick rule); the newest two bars never hold one |
1 lower, Lower | the low of a down fractal, on the fractal's own bar | 2 bars back from the bar that confirms it | 2 at the earliest; a read holds it from [2] ([3] in an On Tick rule); the newest two bars never hold one |
No parameters.
Reading it in a rule.
- A read at
[s]returns the fractal sitting on bar s. A fractal is known two bars after its own bar: it needs two closed bars to its right. In a candle-close rulefractals.upper[2]is the fractal the bar that just closed confirmed.[0]and[1]can never hold one and are refused when you save and when a run starts, with a message naming[2]. The strategy editor starts a fractal read at[2]and does not let it go nearer. - In an On Tick rule
[0]is the bar in progress, so the nearest read that can hold a fractal is[3]: the fractal the last closed bar confirmed. A read of[2]saves there but is always empty. - The bar in progress never confirms a fractal, so a fractal a strategy reads never disappears.
- A fractal read is empty on most bars, and a comparison that reads an empty value is false. To keep the last fractal, store it in a status holder whenever one is confirmed:
param zero = 0
let fractals = Fractals() on EURUSD M1
let close = candle(close) on EURUSD M1
let lots = volume.lots(0.1)
# a fractal read is empty on most bars, so the last one is kept here whenever one is confirmed
hold lastUpper: number = zero on close(M1) {
when fractals.upper[2] > zero -> fractals.upper[2]
}
buy market EURUSD when lastUpper > zero and close crosses above lastUpper {
volume lots
} The holder starts from 0 at a run's start, so lastUpper > zero waits for the first fractal confirmed in the run.
In an On Tick strategy the holder reads fractals.upper[3].
Verified value by value against an independent reference (the record).
Gator Oscillator
Gator in the strategy text · two histograms and their colours, in its own pane
How far apart the Alligator's lines are, as two histograms around zero, from an Alligator with the same parameters: the upper one is |jaw − teeth| (zero or above), the lower one −|teeth − lips| (zero or below), in price units. Both bars large and growing: the Alligator eats (a trend); both shrinking towards zero: it sleeps. It reads volume only when the applied price is Volume.
Each gap compares the two lines as they are drawn on the same bar. A row of the Gator holds the Alligator as drawn at that row + Teeth Shift − 5, so within one histogram the line with the smaller shift is the newer one: the gap is computed on that line's bar, the other line is taken the difference of the two shifts bars earlier, and the histogram is drawn forward by 5 − Teeth Shift + the smaller of its two shifts. At the defaults the upper histogram is |jaw 3 bars earlier − teeth|, drawn 5 bars forward, and the lower one −|teeth 2 bars earlier − lips|, drawn 3 bars forward.
| Line (number, name) | What it is | Drawn | First value on bar |
|---|---|---|---|
0 upper, Upper | |jaw − teeth| | 5 − Teeth Shift + the smaller of Jaw Shift and Teeth Shift | computed on the later of its two lines' period − 1 + shift − the smaller shift, drawn 5 − Teeth Shift + the smaller shift bars after it: bar 20 at the defaults |
1 upperColor, Upper colour | 0 when the upper gap grew from the previous bar, 1 when it shrank, the previous colour when unchanged; 0 on its first value, which a run never reads (one more bar of warm-up) | read, never drawn as a line | with upper |
2 lower, Lower | −|teeth − lips| | 5 − Teeth Shift + the smaller of Teeth Shift and Lips Shift | the same rule over the teeth and the lips: bar 12 at the defaults |
3 lowerColor, Lower colour | the same rule over the size of the lower gap | read, never drawn as a line | with lower |
- The text is
Gator(jawPeriod, jawShift, teethPeriod, teethShift, lipsPeriod, lipsShift, method, appliedPrice), the Alligator's parameters in the Alligator's order. - A colour has no value where its histogram has none. With the exponential method each histogram has no value until its averages have consumed their periods.
| Field | In the text | Default | Values | Can be swept |
|---|---|---|---|---|
| Jaw Period | jawPeriod, 1st | 13 bars | 1 – 2,500 bars | Yes |
| Jaw Shift | jawShift, 2nd | 8 bars | 0 – 1,000 bars | No |
| Teeth Period | teethPeriod, 3rd | 8 bars | 1 – 2,500 bars | Yes |
| Teeth Shift | teethShift, 4th | 5 bars | 0 – 1,000 bars | No |
| Lips Period | lipsPeriod, 5th | 5 bars | 1 – 2,500 bars | Yes |
| Lips Shift | lipsShift, 6th | 3 bars | 0 – 1,000 bars | No |
| Method | method, 7th | Smma | Sma, Ema, Smma, Lwma | No |
| Applied Price | appliedPrice, 8th | Median | Close, Open, High, Low, Median, Typical, Weighted, Volume | No |
The parameters are the Alligator's, in any order. Each histogram's history (its lines' periods, the difference of the shifts it reads one line behind the other, and its draw shift) may not pass 2,500 bars; a set beyond it is refused when you save.
Reading it in a rule.
- Each histogram is drawn forward, so at the defaults
gator.upper[0]is a closed bar's value, even in an On Tick rule. gator.upperColor[0] == zero(withparam zero = 0) is "the upper gap grew on the newest bar shown". An unchanged size keeps the colour.- A Teeth Shift more than 5 above a histogram's smaller shift draws that histogram back instead: a read nearer than
that many bars can never hold a value and is refused when you save, naming the line. Its colour line goes with it.
With Teeth Shift 8, Jaw Shift 8 and Lips Shift 0 the lower histogram is drawn 3 bars back and its smallest read is
[3]; the default Gator draws nothing back. - The shifts change which bars a gap compares, not only where it is drawn: a Gator with other shifts than its Alligator's is a different oscillator.
- With the linear-weighted method, the gaps carry the averages' slow rounding drift (the drift).
Verified value by value against an independent reference (the record).
Market Facilitation Index
BWMFI in the strategy text · a histogram and its colour, in its own pane
Bill Williams' price movement per unit of volume: the bar's range, high − low, counted in the instrument's points,
divided by the bar's volume, computed as (high − low) ÷ volume × the points in one price unit. Zero or above and
unbounded. Its scale depends on the instrument's point and on the bar's tick count, which differs by price feed, so compare it with its own
earlier values, not with a fixed number. The text is BWMFI(): no parameters.
- A bar without volume carries the previous bar's index, over any run of such bars.
- The point is the instrument's as the run trades it (the virtual symbol's digits, or the broker's live), taken when the run is built.
- The first bar has no value on either line: it has no previous bar to compare with.
- It reads the bar's volume (volume).
| Line (number, name) | What it is | Drawn | First value on bar |
|---|---|---|---|
0 mfi, BW MFI | the index | on its own bar | 1 |
1 color, Colour | 0 index and volume both rose, 1 both fell, 2 the index rose and the volume fell, 3 the index fell and the volume rose | read, never drawn as a line | 1 |
Each direction is that of the last strict change against the previous bar: an unchanged index or volume keeps the direction it had, and both start as rises; a run never reads that first colour, since a colour line warms up one bar more. Bill Williams' names for the four colours are green (0), fade (1), fake (2) and squat (3).
No parameters.
Reading it in a rule.
- With
let bw = BWMFI() on EURUSD H1and a constantparam squat = 3,bw.color[0] == squatin a candle-close rule (bw.color[1] == squatin an On Tick rule) is "the last closed bar was a squat". - In an On Tick rule
[0]is the bar in progress, with its volume so far (volume). Sobw.mfi[0]is its range so far divided by its volume so far, andbw.color[0]compares that index and that volume with the last closed bar's. Both change while the bar forms. Read[1]for the last closed bar.
Verified value by value against an independent reference (the record).
Questions?support@algotradinghub.io