VALYNOXSTRATEGY RESEARCH TECHNOLOGY
AlphaPrimeAlphaPrime
ACADEMY / Indicators and signals

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 · Published · updated · Editorial policy

Contents
  1. How does the Williams Alligator indicator work?
  2. What are the best alligator settings, and how do you read sleeping and eating?
  3. How is the alligator different from plain moving averages?
  4. How much lag and how many whipsaws should you expect?
  5. Is the alligator indicator suitable for day trading?
  6. How do you turn alligator signals into a testable rule?
  7. How do you check whether the 13/8/5 settings are stable?
  8. Frequently asked questions
  9. 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.

Each alligator line is an average of the median price, the midpoint of high and low, drawn ahead of the bar it was calculated on: the 13-bar jaw is shifted 8 bars, the 8-bar teeth 5 bars and the 5-bar lips 3 bars Each line is drawn ahead Dot = calculated bar, arrow = shift Jaw 13 +8 bars Teeth 8 +5 bars Lips 5 +3 bars High Median Low Shifted, but no future prices. So: test it like any MA rule.
Each line is an average of the median price, drawn ahead of the bar it was calculated on. The arrows show the forward shift of each line in bars.

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.

LineAverage lengthForward shiftRole in the picture
Jaw13 bars8 barsSlow reference; sets the long-run direction
Teeth8 bars5 barsMiddle line; the one the lips must cross
Lips5 bars3 barsFast 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.

Three alligator states: sleeping, with jaw, teeth and lips tangled in a narrow band, means no trade; eating up, with lips on top, teeth in the middle and jaw at the bottom, all rising, means a long bias; eating down, with the order reversed and all falling, means a short bias Tangled or fanned out? Lips Teeth Jaw Sleeping Eating up Eating down No trade Long bias Short bias Line order gives the direction. So: stay out while lines tangle.
Sleeping is three tangled lines; eating is three lines fanned out in order. The order of the lines tells the direction.

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.

FeatureWilliams AlligatorThree plain SMAs or EMAs
Input priceMedian priceClose (usually)
SmoothingSmoothed average, keeps a share of all past barsSimple or exponential
Forward shift8 / 5 / 3 barsNone
What a cross meansLines fan out in orderFast line crosses slow line
Lag versus priceSmoothing lag plus shiftSmoothing lag only
Comparison of the Williams Alligator with three plain moving averages: median price versus close, smoothed versus simple or exponential averages, an 8, 5 and 3 bar forward shift versus none, lines fanning out versus a fast line crossing a slow one, and lag from smoothing plus shift versus smoothing only Same bars, different display Alligator Plain MAs Input Median Close Smoothing Smoothed SMA / EMA Shift 8 / 5 / 3 bars None Cross Lines fan out Fast × slow Lag Smooth + shift Smooth only The shift moves crosses, adds no data. So: test it as an MA cross rule.
The alligator and three plain moving averages differ only in smoothing and forward shift, not in the information they use.

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.

Hypothetical chart in two zones: in a sideways stretch the three alligator lines cross four times, each cross costing a 30 dollar round trip; in the following trend the price turns up at bar 0 and the fanned-out order is confirmed only several bars later, marked as signal lag Late signals, costly whipsaws White: price. Grey: the three lines Sideways Trend Cost: 4 × $30 Signal lag Most costs come while it sleeps. So: count sideways crosses first.
Smoothing and the forward shift delay the eating signal, and a sideways stretch produces one round-trip cost per false cross.

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.

MeasureDaily bars5-minute bars
Bars per yearAbout 250Many thousands (a few hundred each trading day on NQ)
Crosses per monthFewMany
Typical move captured per tradeLargeSmall
Round-trip cost as a share of the moveSmallLarge
Session handlingOne bar per day, no close-out neededMust 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.

The same alligator rule on daily and 5-minute bars: 5-minute bars give many more bars and crosses but a much smaller move per trade, so round-trip costs take about 1 percent of the move on daily bars and about 23 percent on 5-minute bars in a hypothetical NQ example Small bars, big cost slice Daily bars 5-min bars Bars / year Crosses Move / trade Cost share 1% 23% Same rule, costs eat far more. So: judge it on net average trade.
Moving the same rule to intraday bars multiplies the crosses and costs while the move per trade shrinks, so costs take a larger slice.

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:

  1. 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.
  2. 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.
  3. 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.
  4. Add fees, slippage and next-bar execution, and keep them identical in every run you compare.
  5. 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.
Five steps that turn an alligator reading into a testable rule: define the sleeping band for N bars, define the fan-out entry with a next-bar fill, define the exit by cross back or stop, add fees and slippage, and compare with a stand-in trend rule on the same bars by net average trade Five steps to a testable rule Each step a checkable condition 1 Sleep: tight band for N bars 2 Entry: fan-out, next-bar open 3 Exit: cross back, or a stop 4 Costs: fees and slippage 5 Compare: same bars, net trade Step 5 is the one most skip. So: run a stand-in on the same bars.
A chart reading becomes a rule only when every step is written as a condition a program can check.

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.

NumberResult
Net profit (closed trades)$267,055
Max drawdown$90,210
Trades135
Win rate60.74%
Profit factor1.686
Average trade$1,978.19
Time in market86.03%
Two hypothetical bar charts of net result against jaw length 9 to 17: on the left, lengths 11 to 15 give similar results and form a plateau worth keeping; on the right, only length 13 is high while 12 and 14 collapse, a lucky spike to reject Plateau or lucky spike Net result by jaw length Hypothetical Plateau: keep Spike: reject 9 13 17 9 13 17 Neighbours alike: the setting holds. So: reject a lone spike.
The equity curve of the stand-in trend rule with its drawdown below it and the out-of-sample stretch marked. Look at how long the deepest drawdown lasted and whether the slope changes at the out-of-sample boundary. NQ · daily · 2019-01-02 to 2025-06-30 · CPU engine backtest

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.

  1. Hold the rule and the costs fixed. Change only the setting you are testing.
  2. 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.
  3. Shade the grid. Light cells for results close to the 13/8 cell, dark cells for results far from it.
  4. Repeat for the teeth and the lips, then for the sleeping range and the number of sleeping bars.
  5. 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.
Two illustrative grids of jaw period against jaw shift, 81 settings each: in the plateau grid a broad region around 13/8 gives similar results, which is robust; in the spike grid only the 13/8 cell is good and its neighbours are poor, which suggests a lucky fit Plateau or lucky spike? Green: result close to 13/8 Plateau Robust Spike Lucky fit One best cell is not evidence. So: pick the middle of a plateau.
A plateau of similar results around the chosen setting is evidence; a lone spike at 13/8 is a sign of a lucky fit.

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