Trend filter and momentum trigger

MACD and Alligator Strategy

Short answer

Use the Williams Alligator as a trend filter and MACD as the timing rule. A testable long setup requires the Alligator Lips above Teeth above Jaw, with price above Lips, and a confirmed bullish MACD event. Reverse the conditions for a short setup. This combination can still lag and whipsaw, so judge it with costs and out-of-sample data.

Parts of the setup

MACD concept definitions and test uses
ConceptDefinitionTest use
Alligator trend stateJaw, Teeth and Lips use smoothed averages of the bar midpoint (high + low) / 2 with lengths 13, 8 and 5, plotted forward 8, 5 and 3 bars. This example compares the shifted values visible at the current bar.Require the lines to be ordered and separated before the strategy accepts a MACD trigger.
MACD triggerThe standard MACD uses fast 12, slow 26, and signal 9. A trigger can be a signal-line cross or a histogram sign change.For identical MACD and signal series, a histogram zero cross is the same event as a MACD/signal cross. Require the trend state on that confirmed bar.
Closed-bar confirmationThe strategy evaluates the setup after the current candle closes.This prevents a temporary intrabar crossover from being counted as a completed signal.
InvalidationThe setup ends when the Alligator order breaks, the MACD condition reverses, or a written stop rule fires.Code one exit hierarchy so the backtest does not choose an exit after seeing the result.

A rule you can put into code

  1. 1

    Define the trend state

    For a long setup, require Lips above Teeth, Teeth above Jaw, and the close above Lips. Use the opposite order for a short setup.

    The Alligator is the market-state filter. Without this step, the MACD trigger can fire repeatedly inside a range.

  2. 2

    Define the MACD crossing event

    Define a bullish event as MACD > signal now and MACD <= signal on the previous bar; reverse the inequalities for a bearish event.

    Because histogram = MACD − signal, the equivalent histogram crossing has identical timing. Crossing the MACD line through zero is a different event.

  3. 3

    Wait for the candle close

    Confirm both the Alligator order and MACD event on a completed bar, then enter on the next permitted fill.

    A live candle can reverse before it closes, especially on 5-minute and 15-minute charts.

  4. 4

    Write the exit before testing

    Exit on the opposite MACD event, a broken Alligator order, an ATR stop, or a fixed time limit.

    A strategy needs one reproducible exit process. The indicators do not define risk by themselves.

Use the Alligator values visible at the decision bar

A positive plot offset moves a previously calculated value to a later chart position; it does not provide future data. At bar t, the plotted Jaw corresponds to its 13-period smoothed midpoint value from t − 8, Teeth to its 8-period value from t − 5, and Lips to its 5-period value from t − 3.

Comparing the current, unshifted averages is another valid rule, but it will not reproduce the displayed line ordering. Choose one convention and use it consistently for filters, exits and chart checks. Wait until all required historical values are available.

Why the pair can still fail

MACD and the Alligator both derive signals from smoothed price data. Using both does not create independent confirmation. It can delay entry because the strategy waits for two lagging conditions.

The Alligator is most useful when its lines have a clear order and slope. When the lines overlap, TradingView describes the market as choppy and notes that false signals can occur. A MACD cross during that state is a reason to wait, not proof that the range has ended.

  • Measure trade count and average trade after commission and slippage.
  • Separate trending and sideways samples before comparing results.
  • Reject a result that depends on a few unusually large trades.

Long and short rules need exact symmetry

A symmetric rule makes review easier. If a long entry requires three ordered Alligator lines and a bullish MACD cross, the short entry should require the reverse order and a bearish cross. Any exception needs a written reason.

Stops do not need to be symmetric in price distance, but the method should be. An ATR multiple, the Jaw line, or the last swing can each define risk. Pick one before running the test.

How to compare the combined strategy

Run three versions on the same symbol and dates: MACD alone, Alligator alone, and the combined rule. Keep position sizing and exits fixed. The useful question is whether the extra filter improves drawdown or average trade enough to justify fewer and later entries.

Use a holdout period that was not used to choose parameters. If the combined rule only works on the development sample, the extra conditions may be fitting noise.

Test templates

These examples define a research process. They are not trade calls or evidence that a setup will make money.

SPY

1H

Rule to test

Enter long after the default Alligator is ordered upward and MACD 12, 26, 9 crosses above its signal line on a closed bar. Exit on the opposite MACD cross.

Validation

Compare against the same MACD rule without the Alligator filter. Include commission, slippage, and an untouched final 30 percent of the sample.

QQQ

15m

Rule to test

Trade only in the direction of the Alligator order. Use a MACD histogram zero cross as the entry and a two ATR stop.

Validation

Break results into trending and sideways weeks. Check whether the filter reduces false entries without making the average trade worse.

EURUSD

4H

Rule to test

Require price above or below all three Alligator lines, then use a matching MACD signal-line cross. Close after 12 bars if no exit fires.

Validation

Model spread and swap assumptions. Test more than one market period before changing the default indicator lengths.

Checks before accepting a result

Record the default lengths, midpoint source and displacement convention before changing any parameter.

Keep exits and position size unchanged when comparing the combined rule with MACD alone.

Evaluate the selected filter on untouched dates; a favorable development sample does not establish future results.

Turn the idea into an inspectable Pine Script rule

Pineify can generate a TradingView strategy with separate Alligator state, MACD trigger, bar-close confirmation, and exit conditions. You can inspect the Pine Script, change one input at a time, and, with an eligible Advanced-or-higher plan, configure parameter tests through the Strategy Optimizer extension in TradingView.

Build the combined strategy

Frequently asked questions

What is the MACD and Alligator strategy?

The MACD and Alligator strategy uses the Alligator to define trend direction and MACD to time a momentum entry. It is a rule combination, not a guarantee that a trend will continue.

What settings should I use for MACD and Alligator?

Start with MACD 12, 26, 9 and the default Alligator lengths of 13, 8, and 5. Treat those values as a control, then test any change on the same symbol, timeframe, costs, and dates.

Does the Alligator remove false MACD signals?

It may remove some MACD signals during ranges, but it can also enter later and miss early trend movement. Only a controlled backtest can show whether that tradeoff helped a written strategy.

Can AI predict stock prices with this strategy?

Drafting a combined rule does not establish predictive accuracy. Inspect its timing and data use, then evaluate it separately from code correctness.

Is this strategy investment advice?

No. This page is an information and strategy-testing resource, not personalized investment advice or a trade recommendation.

Sources and limits

Source review completed 2026-07-26.

This page is an information and strategy-testing tool, not investment advice. The settings and templates are research starting points, not promises of returns. Backtests can omit execution effects and do not predict future performance. Trading can result in loss.