Alligator indicator: 13/8, 8/5, 5/3 settings and how to backtest it
The alligator indicator is three smoothed averages of the median price, each shifted forward by 8, 5 and 3 bars. Read it by whether the lines are tangled or fanned out, test a cross rule with costs and next-bar fills, and check that neighbouring settings around 13/8/5 give similar results.
By Soren Huang · Published · updated · Editorial policy
Contents
- How does the Williams Alligator indicator work?
- What are the best alligator settings, and how do you read sleeping and eating?
- How is the alligator different from plain moving averages?
- How much lag and how many whipsaws should you expect?
- Is the alligator indicator suitable for day trading?
- How do you turn alligator signals into a testable rule?
- How do you check whether the 13/8/5 settings are stable?
- Frequently asked questions
- References
How does the Williams Alligator indicator work?
The alligator indicator is three smoothed moving averages of the median price, each drawn a few bars ahead of the bar it was calculated on: a 13-bar jaw shifted 8 bars, an 8-bar teeth shifted 5, and a 5-bar lips shifted 3. It shows one thing: how far apart three averages of different speed sit, and in which order.
Median price is the midpoint of one bar: median price = (high + low) ÷ 2, where high and low are the highest and lowest trade of that bar. A smoothed moving average is an average that keeps a small share of every past bar instead of dropping bars beyond a fixed window, so it reacts more slowly than a simple average of the same length; a 13-bar smoothed average moves much like an exponential average of about 25 bars. The three lines are:
- Jaw: 13-bar smoothed average of median price, drawn 8 bars to the right. The slowest line.
- Teeth: 8-bar smoothed average, drawn 5 bars to the right.
- Lips: 5-bar smoothed average, drawn 3 bars to the right. The fastest line.
The forward shift means the jaw value calculated on bar 100 is drawn on bar 108. That is why the lines run past the last bar on the right edge of the chart. The part that sticks out looks like a forecast, but it is only the latest completed averages drawn further right. No value on any line uses a price the market has not printed yet. This is the claim the rest of the article tests from several sides: the alligator is a display of three averages, so a rule built on it has to be judged the way any moving-average rule is judged, by its average trade after costs on data the rule did not see.
Where the alligator sits among chart tools, and which of those tools can be tested at all, is covered in technical analysis tools and indicators: which ones you can test.
What are the best alligator settings, and how do you read sleeping and eating?
Test the standard settings first, 13/8 for the jaw, 8/5 for the teeth and 5/3 for the lips, and read the three lines as one picture rather than watching any single line. Other settings only change the spacing and the lag of the lines; they do not change what the indicator measures. Whether any setting is "best" is a question for the stability check in the last section, not for a chart.
| Line | Average length | Forward shift | Role in the picture |
|---|---|---|---|
| Jaw | 13 bars | 8 bars | Slow reference; sets the long-run direction |
| Teeth | 8 bars | 5 bars | Middle line; the one the lips must cross |
| Lips | 5 bars | 3 bars | Fast line; first to react to a turn |
The reading has three states. Sleeping is the state where the three lines run close together and cross back and forth, which marks a market without direction and means no trade. Eating is the state where the lines have fanned out in order and all point the same way: lips on top, teeth in the middle and jaw at the bottom for an up move, the reverse order for a down move. Between the two, the lines begin to separate, which is often called waking up. The order of the lines gives the direction; the distance between them gives a rough sense of how strong the move has been so far.
Note what the alligator does not have. There is no overbought or oversold level, unlike the stochastic oscillator and its %K and %D lines, and no histogram of the gap between two averages, unlike the MACD indicator and its signal-line crosses. The only events it produces are crosses and the order of the three lines, so every rule built on it is a cross rule or a spread rule.
How is the alligator different from plain moving averages?
The alligator differs from three plain moving averages in two things only, the type of smoothing and the forward shift of each line; the bars it draws from are the same. A trader who plots three moving averages of 5, 8 and 13 bars on the close sees almost the same shape, slightly earlier and slightly rougher.
| Feature | Williams Alligator | Three plain SMAs or EMAs |
|---|---|---|
| Input price | Median price | Close (usually) |
| Smoothing | Smoothed average, keeps a share of all past bars | Simple or exponential |
| Forward shift | 8 / 5 / 3 bars | None |
| What a cross means | Lines fan out in order | Fast line crosses slow line |
| Lag versus price | Smoothing lag plus shift | Smoothing lag only |
The shift does change the signal, but not in the way the picture suggests. Because each line is shifted by a different amount, a cross on the alligator chart compares a jaw value calculated 8 bars ago with a lips value calculated 3 bars ago. That is a different comparison from the same two averages without shift, so the crosses land on different bars. Every value in the comparison is still a past average. The shift decides where on the screen a cross appears; it adds no information that the bars did not already contain. Brock, Lakonishok and LeBaron (1992) tested plain moving-average cross rules on a long stock index history and found that the rules' returns differed from a random benchmark, while noting that they had not subtracted trading costs. The alligator inherits that result and that limit; it is a moving-average rule with a different display.
One more difference matters for testing. The alligator's three speeds are fixed. An adaptive average, such as the VIDYA indicator with its volatility-driven smoothing, speeds up when prices move and slows down when they stop. The alligator treats a quiet month and a trending month with the same lag, which is one reason it crosses so often while it is "asleep".
How much lag and how many whipsaws should you expect?
Expect the eating signal to arrive well after a move starts, and expect repeated false crosses in a sideways market, because smoothing and the forward shift both delay every line. In a steady trend, a smoothed average of n bars sits about n minus 1 bars behind price. Add the shift, and the plotted jaw is about 20 bars behind, the teeth about 12 and the lips about 7. The eating order needs all three lines fanned out, so the slowest line decides when the signal is confirmed.
A whipsaw is a signal that reverses shortly after it fires, so the trade is closed at a loss before the expected move happens. The alligator produces whipsaws in exactly the state it calls sleeping: the three lines sit in a narrow band and cross each other again and again. A rule that acts on every cross therefore pays most of its costs during the period when the indicator's own reading says to stay out. That is the trade-off any filter must solve: require a minimum spread between the lines before acting, or a number of bars in the fanned-out order, and accept that the entry comes even later.
Hypothetical example
Suppose a rule enters whenever the lips cross the teeth and exits on the cross back. In one sideways month on daily bars the lines cross four times. Each cross is a round trip: with $20 commission and $10 slippage per trade, that is $30 of cost per round trip, or $120 for the month, before any price loss from buying high in the band and selling low. In the trending month that follows, the rule fires once, about 20 bars after the low, and holds for the rest of the move. Whether the one trending trade pays for the four sideways ones is the question the backtest has to answer; the chart alone cannot.
Is the alligator indicator suitable for day trading?
The alligator can be drawn on any bar size, but on intraday bars it fires many more crosses while each trade captures a smaller move, so a day-trading rule stands or falls on its average trade after round-trip costs. The lag stays the same in bars: about 20 bars for the jaw whether a bar is a day or five minutes. What changes is how much price moves in 20 bars and how many round trips the rule makes in a month.
| Measure | Daily bars | 5-minute bars |
|---|---|---|
| Bars per year | About 250 | Many thousands (a few hundred each trading day on NQ) |
| Crosses per month | Few | Many |
| Typical move captured per trade | Large | Small |
| Round-trip cost as a share of the move | Small | Large |
| Session handling | One bar per day, no close-out needed | Must define session and close before the session end |
Hypothetical example
On NQ, one index point is worth $20 and one tick (0.25 point) is worth $5. Suppose a daily alligator rule captures an average gross move of 150 points per trade, which is $3,000; a round-trip cost of $30 is one percent of that. Suppose the same rule on 5-minute bars captures an average gross move of 3 points, which is $60; commission of $4 plus one tick of slippage on each side ($10) is $14, about a quarter of the gross move. The rule is the same. The share of the move that costs eat is twenty times larger on the small bars.
This is why an intraday alligator rule has to be read on the average trade after costs and on nothing else. A win rate or an equity curve without costs will look better on 5-minute bars, because there are more trades to smooth the curve. Add $30 per round trip and the picture usually reverses. If you want to day trade with it, also write down the session you trade and the time of the last exit before the session ends, because the lines carry a position across the break if the rule does not close it.
How do you turn alligator signals into a testable rule?
A chart reading becomes a testable rule only when every step is written as a condition a program can check, with costs and next-bar fills included. "The alligator is eating" is not a condition. "Lips above teeth and teeth above jaw on the bar close, after at least N bars in which the spread between jaw and lips stayed below a set range" is. The steps in order:
- Define the sleeping period. Choose how narrow the band between jaw and lips must be, and for how many bars, before a fan-out counts as a wake-up.
- Define the entry. Lips above teeth above jaw on the close for a long, the reverse for a short, with the fill on the next bar's open. Next-bar execution is the rule that a decision made on a bar's close is filled at the first price of the following bar, which is the earliest price you could really have traded.
- Define the exit. Lips crossing back below the teeth, or a fixed stop in points, or both. Write which one takes priority if both are hit.
- Add fees, slippage and next-bar execution, and keep them identical in every run you compare.
- Compare with a stand-in trend rule built from a standard indicator, run with the same costs on the same data, and read the average trade after costs of both.
The sleeping range, the number of bars, the three periods and the three shifts are all ranges rather than single numbers, and giving them to strategy generation in AlphaPrime (Valynox) as parameter ranges lets the alligator rule and its close neighbours be tried under one set of cost and session settings. AlphaPrime evaluates each candidate with fees, slippage and next-bar execution, so the ranking you read is already net of costs.
Step 5 is the one most traders skip. The run below is the comparison point this article uses. It did not test the alligator. It tested a stand-in trend rule built from the Standard Deviation indicator as its only entry and exit, with no stop, target or filter, on NQ daily bars from 2019-01-02 to 2025-06-30, long and short, one contract, $20 commission and $10 slippage per trade. Among 1,024 candidates tried, this one was kept for how its return compared with its drawdown. Picking the kept candidate after the fact flatters its numbers, so the figures show what a complete report of a trend rule on these bars looks like, not what the Standard Deviation rule or the alligator earns, and not what a reader should expect.
Source: AlphaPrime product engine (CPU), run 2026-10-31. NQ daily bars, 2019-01-02 to 2025-06-30, long and short, 1 contract, $20 commission and $10 slippage per trade.
| Number | Result |
|---|---|
| Net profit (closed trades) | $267,055 |
| Max drawdown | $90,210 |
| Trades | 135 |
| Win rate | 60.74% |
| Profit factor | 1.686 |
| Average trade | $1,978.19 |
| Time in market | 86.03% |
Read the stand-in the way you will read your own alligator run. It made 135 trades in about six and a half years, so roughly 20 a year, with an average trade of $1,978.19 against $30 of round-trip cost, and it sat in the market 86.03% of the time, which is normal for a rule with no filter. Its max drawdown of $90,210 is about a third of its net profit of $267,055. When your alligator rule's report comes back, put it beside this one: if the alligator rule has a similar trade count, a similar time in market and a similar shape, the sleeping filter and the shifted lines have added nothing a plainer trend rule did not already give. If it has fewer trades and a smaller drawdown for a comparable average trade, the filter did some work, and that is the result worth carrying to the stability check.
How do you check whether the 13/8/5 settings are stable?
Re-run the same rule at neighbouring periods and shifts and look for a flat plateau of similar results around 13/8/5; a single good cell surrounded by poor ones means the result belongs to that stretch of history, not to the indicator. Parameter stability is the property that small changes to a setting produce small changes to the result. An edge that depends on the jaw being exactly 13 bars and not 12 or 14 is describing noise in one data set.
- Hold the rule and the costs fixed. Change only the setting you are testing.
- Vary one line at a time first. Run the jaw period from 9 to 17 and the jaw shift from 4 to 12, which is 81 combinations, and record the average trade after costs for each.
- Shade the grid. Light cells for results close to the 13/8 cell, dark cells for results far from it.
- Repeat for the teeth and the lips, then for the sleeping range and the number of sleeping bars.
- Decide from the shape, not the peak. Choose a setting from the middle of a plateau even if a cell at its edge scored higher.
Pardo (2008) describes this as reading the shape of the optimization space and preferring a robust region over the single best point. The reason it matters grows with the number of settings you try. Sullivan, Timmermann and White (1999) re-examined moving-average and similar rules inside a large universe of variants and found that once the number of rules tried was taken into account, the apparent edge of the best one weakened, and it did not hold up in the later years. A grid of 81 cells is already 81 trials, so the best cell in it will almost always look better than it is. The plateau test is what separates the region that keeps working from the cell that happened to win. How to read such grids in detail, and how plateaus and spikes look on an actual parameter map, is covered in parameter stability in trading: plateau or lucky spike.
The next thing to do is concrete. Take your alligator rule exactly as written in the previous section, run the 9-to-17 by 4-to-12 jaw grid on the daily bars of one market with the same $30 round-trip cost, and before you look at the 13/8 cell, write down how wide a plateau you require around it. Then look.
Frequently asked questions
How do you decide entries and exits with the alligator indicator?
Enter when the three lines fan out in order on a bar close: lips above teeth above jaw for a long, the reverse for a short, after a period in which the lines were tangled. Fill on the next bar's open. Exit when the lips cross back through the teeth, or at a fixed stop in points, whichever is written to take priority. Every one of these conditions has to be a number a program can check, otherwise it cannot be tested.
What is the difference between the alligator and a moving average crossover?
The alligator is a moving-average crossover with three lines instead of two, smoothed averages instead of simple or exponential ones, the median price instead of the close, and each line drawn 8, 5 or 3 bars to the right. The forward shift changes which past values are compared and where the cross appears on the screen. The information both use is the same bars, so both are tested the same way, by the average trade after costs.
Does the alligator indicator repaint?
No. Each line's value is fixed once the bar it was calculated on has closed. The lines extend past the last bar because of the forward shift, and that part of the chart shows averages from 8, 5 and 3 bars ago, not future values. When a new bar closes, a new point is added at the far right and nothing already drawn moves.
Which time frame is best for the alligator indicator?
The lag is the same in bars on every time frame, about 20 bars for the jaw, so no time frame removes it. What changes is the size of the move captured per trade against a fixed round-trip cost, which falls as bars get shorter. Test the rule on the bar size you intend to trade, with your own fees and slippage, and judge it on the average trade after costs rather than on the chart.
References
- Brock, W., Lakonishok, J., & LeBaron, B. (1992). Simple Technical Trading Rules and the Stochastic Properties of Stock Returns. The Journal of Finance, 47(5), 1731–1764.
- Sullivan, R., Timmermann, A., & White, H. (1999). Data-Snooping, Technical Trading Rule Performance, and the Bootstrap. The Journal of Finance, 54(5), 1647–1691.
- Pardo, R. (2008). The Evaluation and Optimization of Trading Strategies (2nd ed.). John Wiley & Sons.
- CME Group. E-mini Nasdaq-100 Futures Contract Specs. https://www.cmegroup.com/markets/equities/nasdaq/e-mini-nasdaq-100.contractSpecs.html

