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 the Teeth and Jaw, price above the three lines, 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 stateThe default Jaw, Teeth, and Lips use smoothed averages with lengths of 13, 8, and 5 and forward shifts of 8, 5, and 3 bars.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.Choose one trigger and apply it only after the Alligator trend condition is true.
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

    Choose one MACD event

    Use either a MACD signal-line crossover or a histogram move through zero. Do not switch between them during the same test.

    Each event has different timing. Mixing them hides which rule produced the trade.

  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.

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 I use before accepting a result

I start with the documented defaults so the first SPY result is easy to reproduce. I save that control before changing any length.

When I compare the combined rule with MACD alone, I keep the exit and position size unchanged. Otherwise I cannot tell whether the filter helped.

I reject a setup when the Alligator filter only removes losing trades in the development sample. The same filter must hold up on untouched dates.

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 send the same rule to the Strategy Optimizer.

Build the combined strategy

Frequently asked questions

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.