Swing trading settings

Best MACD Settings for Swing Trading

Short answer

MACD 12, 26, 9 is a documented default that can serve as a comparison baseline, not evidence of the best swing-trading setting. Test it against a faster 8, 21, 5 setup and a slower 19, 39, 9 setup on your own symbol, timeframe, and trading rules. Judge the full strategy after costs, not the indicator crossover by itself.

Parameters and what they change

Treat each value as a starting point. A setting only becomes useful after you test it on the same market, timeframe, costs, and date range you plan to study.

Swing trading parameter comparison
ParameterStarting pointWhat it changesCaution
Fast EMA length12 barsA shorter value makes the MACD line react sooner to recent price changes.Measure crossover frequency on the chosen series. A shorter length does not guarantee a specific number of signals or completed trades.
Slow EMA length26 barsThis is the slower trend reference subtracted from the fast EMA.Keep it longer than the fast length. Changing both lengths together makes the test harder to diagnose.
Signal EMA length9 barsThis smooths the MACD line and defines signal-line crossovers.A shorter signal length responds sooner but can increase turnover and trading costs.
Price sourceCloseThe source supplies the price series used by both MACD averages.Do not compare source changes and length changes in the same test run.
Signal confirmationConfirmed bar closeThe strategy waits until the current candle is complete before accepting a crossover.A close-confirmed backtest will enter later than an intrabar alert and may produce different fills.

Presets to test, not copy blindly

Liquid US stocks and ETFs

Daily

12 fast EMA, 26 slow EMA, 9 signal EMA, close source

Use this documented default as the control before testing any custom settings on SPY, QQQ, AAPL, or another liquid symbol.

Liquid US stocks and ETFs

4-hour

8 fast EMA, 21 slow EMA, 5 signal EMA, close source

Test as a faster alternative when the 12, 26, 9 control reacts too late for the written holding-period rule.

Index ETFs with slower swing rules

Daily or weekly

19 fast EMA, 39 slow EMA, 9 signal EMA, close source

Test when reducing turnover matters more than catching early momentum changes. Measure signal timing and turnover rather than assuming that both will improve.

Test templates you can audit

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

SPY

1D

Rule to test

Enter long when MACD 12, 26, 9 crosses above its signal line while the close is above the 200-bar SMA. Exit on the opposite MACD cross.

Compare with buy and hold, include realistic commission and slippage, and reserve the most recent 30 percent of data for an untouched out-of-sample test.

QQQ

4H

Rule to test

Compare 12, 26, 9 with 8, 21, 5 using the same long-only crossover rule, 50-bar EMA trend filter, and ATR-based stop.

Keep position sizing and exits fixed. Compare drawdown, profit factor, trade count, and average trade after costs rather than net profit alone.

AAPL

1D

Rule to test

Enter only after a positive MACD histogram bar closes and price is above a rising 50-bar SMA. Exit when the histogram closes below zero.

Walk the test forward across several market periods and reject settings whose result depends on a small group of exceptional trades.

Checks to run before trusting the result

Begin with 12, 26, 9 on a daily SPY chart so the first result is easy to reproduce. Record that baseline before changing one length at a time.

Treat faster combinations such as 8, 21, 5 as illustrative comparison settings on a four-hour QQQ chart. Measure the resulting trades and false turns; their count depends on the price path and the complete entry and exit rules.

Use the completed bar for MACD signals. Acting before the bar closes can make a crossover appear and disappear while the candle is still forming.

Review trending and sideways samples separately. Fidelity notes that MACD can whipsaw in trading ranges, and a single blended result can hide that weakness.

Turn the idea into an inspectable rule

Pineify can turn the MACD lengths, trend filter, entry rule, and exit rule into an editable Pine Script strategy. Inspect the draft and request syntax checking, then run the same rules across several settings, include commission and slippage, and compare out-of-sample results before considering paper trading.

Build and test a MACD strategy

Frequently asked questions

What are the best MACD settings for swing trading?

MACD 12, 26, 9 is a documented baseline; this page does not establish that it is the best setting for any particular market or timeframe. Treat it as a control, then test a small number of alternatives with identical entries, exits, costs, and position sizing.

Is 8, 21, 5 better than MACD 12, 26, 9?

No setting is inherently better. The 8, 21, 5 version reacts faster and may fit shorter swings, but it can also create extra false signals and higher turnover.

Should swing traders use MACD crossovers or the zero line?

Either can become a testable rule, but they answer different questions. A signal-line crossover tracks a momentum change, while a zero-line cross indicates that the fast average has moved above or below the slow average.

Can AI reliably predict swing trading prices with MACD?

Generating MACD code does not establish predictive accuracy. AI can help draft and compare explicit rules; any prediction claim needs separate evidence, and a backtest cannot promise future returns.

How should I validate MACD settings?

Validate them with out-of-sample data, realistic commission and slippage, enough trades, and forward testing. Compare several symbols and market conditions so one favorable period does not decide the result.

Sources and limits

Sources checked 2026-07-18

  • MACD technical indicator guide (Fidelity, checked 2026-07-18). Documents the 12-period EMA minus 26-period EMA calculation, the 9-period signal EMA, and the risk of whipsaws in trading ranges.
  • Moving Average Convergence Divergence indicator (TradingView, checked 2026-07-18). Explains the MACD line, signal line, histogram, configurable average types, lengths, source, and timeframe behavior.
  • MACD Strategy (TradingView, checked 2026-07-18). Confirms 12, 26, and 9 as the built-in MACD strategy defaults and describes its histogram sign-change rule.
  • Strategy publishing rules (TradingView, checked 2026-07-18). Calls for realistic parameters, commissions, sufficient samples, and performance claims that do not mislead traders.

This page is an information and strategy-testing tool, not investment advice. MACD settings are test starting points, not trade recommendations or promises of profit. Backtests and paper trades are hypothetical, can omit real execution effects, and do not predict future performance. Trading can result in loss.