Liquid US stocks and ETFs
Daily12 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.
Swing trading settings
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.
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.
| Parameter | Starting point | What it changes | Caution |
|---|---|---|---|
| Fast EMA length | 12 bars | A 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 length | 26 bars | This 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 length | 9 bars | This smooths the MACD line and defines signal-line crossovers. | A shorter signal length responds sooner but can increase turnover and trading costs. |
| Price source | Close | The source supplies the price series used by both MACD averages. | Do not compare source changes and length changes in the same test run. |
| Signal confirmation | Confirmed bar close | The 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. |
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.
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.
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.
These templates define a research process. They are not trade calls or evidence that a setup will make money.
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.
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.
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.
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.
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 strategyMACD 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.
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.
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.
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.
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 checked 2026-07-18
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.