VALYNOX
VALYNOXSTRATEGY RESEARCH TECHNOLOGY
AlphaPrimeAlphaPrime
ACADEMY / Indicators and signals

MACD and RSI strategy: combined rules, settings and a fair backtest

A MACD and RSI strategy uses the MACD cross as the entry trigger and RSI as a filter that blocks entries when price is already stretched. The pair is worth keeping only if it beats MACD alone and RSI alone on the same data, with the same costs and execution, and if the RSI filter removes losing trades faster than it removes profit.

By · Published · updated · Editorial policy

Contents
  1. How do traders combine MACD and RSI in one strategy?
  2. What does each indicator measure, and why is the pair so popular?
  3. What do the MACD and RSI combination rules look like?
  4. How should you set MACD and RSI parameters without overfitting?
  5. Is combining MACD and RSI better than using one alone?
  6. How do you backtest a MACD RSI strategy with costs and out-of-sample checks?
  7. Frequently asked questions
  8. References

How do traders combine MACD and RSI in one strategy?

A MACD and RSI strategy usually takes the MACD cross as the entry trigger and uses RSI as a filter that blocks entries when price is already stretched. Keep the pair only if, on the same data with the same costs and execution, it does better than MACD alone and RSI alone.

A filter is a condition that does not open trades by itself but can stop another rule from opening one. In this strategy the MACD cross says "momentum just turned", and the RSI reading says "but price has already run far", so the long entry is skipped when RSI is high and the short entry is skipped when RSI is low. The idea is sensible. The problem is that adding a second indicator adds parameters, and more parameters make it easier to find a setting that fits the past by luck. The rest of this article gives you a version of the rules you can test, the settings worth trying, and a way to tell a filter that helps from a filter that only shrinks the trade list.

What does each indicator measure, and why is the pair so popular?

MACD and RSI answer two different questions about the same bars, which is why traders pair them: MACD asks which way momentum is leaning, RSI asks how one-sided the recent closes have been. MACD is the gap between a fast and a slow exponential moving average of the close, drawn with a signal line (a moving average of that gap) and a histogram (the distance between the two lines). RSI is a 0 to 100 reading of how much of the recent movement came from up closes versus down closes, with 70 and 30 as the usual "stretched" levels. The 14-bar length comes from the indicator's original description (Wilder, 1978), and most charting packages still ship it as the default; the RSI indicator guide with its 70/30 levels covers how the levels behave on their own.

Each indicator has a known blind spot. MACD reacts late and flips back and forth in a sideways market, so it opens many small losing trades in ranges. RSI reaches 70 early in a strong trend and stays there, so a rule that sells at 70 fights the trend. Traders pair them hoping that MACD supplies the direction and RSI stops the entries that come too late in a move. Both are free in every platform and need no extra data, which explains much of the popularity. Whether the pairing improves results is a question a backtest answers, not a chart. Surveys of technical rules find that reported results shrink or vanish once costs and the number of rules tried are accounted for (Park & Irwin, 2007), which is a reason to test the pair with the same discipline you would apply to any rule in the guide to technical analysis tools and which indicators you can test.

A price panel with a MACD panel and an RSI panel under it. MACD is the gap between a fast and a slow average, and RSI shows how one-sided recent closes are. One highlighted bar shows MACD crossing up while RSI already reads 74, above the 70 line. Two questions about one bar Highlighted: MACD up, RSI at 74 Price MACD Fast vs slow gap RSI One-sided closes Momentum turns; price is stretched. So: the RSI filter skips this entry.
MACD and RSI read the same bars but answer different questions. The highlighted bar is the case the filter exists for: momentum turns up while price is already stretched.

What do the MACD and RSI combination rules look like?

A testable version writes down the trigger, the filter level, the direction, the fill and the exit in one ordered list, so that nothing is left to judgment when the bar closes. Here is the long side with the common settings; the short side is the mirror image.

  1. Trigger: on the close of a bar, the MACD line (12, 26) crosses above its signal line (9).
  2. Filter: RSI(14) on that same close is below 65. If RSI is 65 or higher, no trade.
  3. Fill: buy one contract at the open of the next bar.
  4. Exit: sell at the open of the bar after the MACD line crosses back below the signal line. No stop or target in the base version, so the comparison is about the entry filter and nothing else.
  5. Short side: the MACD line crosses below the signal line, RSI(14) is above 35, sell short at the next open, cover after the MACD line crosses back above.
The combined rule checks in order: first the MACD trigger, then the RSI filter, then a fill at the next open. Long: MACD crosses up, RSI below 65, buy. Short is the mirror: MACD crosses down, RSI above 35, sell. If any check fails there is no trade, and the exit is the opposite MACD cross. Cross first, RSI second Then the fill at the next open Trigger Filter Next open Long Short Cross up RSI < 65 Buy Cross down RSI > 35 Sell Any check fails: no trade Same order, mirrored for shorts. So: exit on the opposite MACD cross.
The order of checks in the combined rule. The MACD cross is asked first, the RSI level second, and the fill always lands on the next bar.

To compare fairly, write the two single-indicator rules in the same shape. Each variant below uses the same exit, the same fill on the next bar and the same costs, so the only difference is the entry condition.

VariantLong entryShort entryExit
MACD aloneMACD line crosses above signalMACD line crosses below signalOpposite MACD cross, next open
RSI aloneRSI(14) crosses up through 35RSI(14) crosses down through 65Opposite MACD cross, next open (same exit for all three)
CombinedMACD cross up and RSI(14) below 65MACD cross down and RSI(14) above 35Opposite MACD cross, next open

The RSI-alone variant uses RSI as a trigger because a filter cannot open trades on its own. The same discipline of writing exact rules before testing applies to any entry you might swap in, whether a Donchian channel breakout with its settings as the trigger or a chart shape such as the double bottom pattern written as exact rules; the three-variant comparison stays the same.

How should you set MACD and RSI parameters without overfitting?

Start from the common MACD and RSI settings (12, 26, 9 and 14 with 65 and 35 as filter levels), test the neighbouring values, and keep only a setting that sits on a plateau. A plateau is a block of neighbouring settings that all give similar results, like a flat hilltop; a spike is one setting that looks excellent while the settings next to it look poor. The spike is almost always noise, because real market behaviour does not switch on at a lookback of 12 and off at 11 and 13.

The combination has at least five parameters: MACD fast length, slow length, signal length, RSI length and the RSI filter level (six if you set long and short levels separately). The number of variants multiplies with each one, and the more variants a search tries, the more likely the best one is inflated by luck (Bailey, Borwein, López de Prado & Zhu, 2014). Reasonable ranges to walk through: fast 8 to 16, slow 20 to 32, signal 6 to 12, RSI length 10 to 20, filter level 55 to 75 (and its mirror 25 to 45). When you set these as ranges in the strategy generation settings of AlphaPrime (Valynox), the search covers the whole grid with one set of costs and one exit, so the plateau or spike shows up in one pass instead of in dozens of hand-edited runs.

Hypothetical example

Give every parameter 8 values. MACD alone has three parameters, so 8 × 8 × 8 = 512 variants. RSI alone has two (length and level), so 8 × 8 = 64 variants. The combined rule has five, so 8 × 8 × 8 × 8 × 8, about 33,000 variants. The best of 33,000 tries will look better than the best of 64 even when none of them has an edge, which is why the combined winner needs a plateau check and an out-of-sample check before you believe it.

With 8 values per parameter, MACD alone has 512 variants, RSI alone 64 and the combined rule about 33 thousand, as illustrative counts. Two grids of RSI level against MACD fast length: a plateau, where a broad block of settings gives similar good results, is trustworthy; a spike, a single good cell among poor ones, is not. Five parameters, huge search 8 values each, illustrative counts MACD alone 512 RSI alone 64 Combined 33 thousand Plateau Spike Trust Distrust The best of thousands is flattered. So: trust plateaus, not spikes.
Combining indicators multiplies the variant count. On the right, the plateau is what a trustworthy setting looks like; the lone bright cell is the one to distrust.

A practical way to read the grid: pick the combined setting you like, then change one parameter at a time by one or two steps and watch the net profit after costs. If most neighbours stay within roughly a third of the chosen result, you are on a plateau. If one neighbour halves the result, you are standing on a spike.

Is combining MACD and RSI better than using one alone?

The combination is better only when the RSI filter removes losing trades faster than it removes profit, and the way to find out is to run the three variants on identical data, costs and execution and compare three numbers: trade count, net profit per year after costs, and average trade. A filter always cuts the trade count; that is what filters do. The question is what happens to profit when the trades go.

Hypothetical example

MACD alone: 200 trades a year, net profit $8,000 a year after costs, average trade $40. RSI alone: 120 trades, $3,600, average trade $30. Combined: 100 trades, $7,000, average trade $70. The filter removed half the trades and kept most of the profit, and the average trade rose from $40 to $70, so the trades it removed were mostly losers. Now the opposite case: combined gives 100 trades and $3,800, average trade $38. Here the filter cut profit almost as fast as trades. It removed winners and losers alike and only made the strategy smaller.

Hypothetical yearly results after costs: MACD alone has 200 trades, about 8 thousand dollars net and a 40 dollar average trade; RSI alone 120 trades, under 4 thousand dollars and 30 dollars; combined 100 trades, about 7 thousand dollars and the highest average trade at 70 dollars. Net profit is shown as an index with MACD alone at 100. If profit fell as fast as the trade count, the filter would only be making the strategy smaller. Fewer trades, bigger average Per year after costs, hypothetical MACD RSI Combined Trades Net index Avg trade 200 120 100 100 45 88 $40 $30 $70 The filter mostly cut losers. Profit falling as fast? Drop it.
A filter that works removes trades faster than it removes profit, so the average trade rises. When profit falls as fast as the trade count, the filter is only making the strategy smaller.

Two more checks separate a useful filter from a lucky one. First, look at which trades the filter removed: list the MACD-alone trades that the combined rule skipped and check that their total is negative, not merely that the kept trades are positive. Second, look at the long and short sides separately, because an RSI level that helps long entries in a market that mostly rose may hurt short entries, and a combined result that comes entirely from one side is a weaker result than it looks. If the combined variant wins on net profit but loses on average trade, or wins only because the filter skipped one large losing trade, treat the single-indicator rule as the base case and the filter as unproven.

How do you backtest a MACD RSI strategy with costs and out-of-sample checks?

Run all three variants with the same commission and slippage, next-bar execution and a time split that you write down before the first run, then judge the out-of-sample average trade against the in-sample one with a rule you set before looking. Next-bar execution is filling at the open of the bar after the signal bar closes, which is the earliest price you could really have traded. Out-of-sample data is the later part of the history that you keep out of the parameter search and run once with the settings frozen.

  1. Set costs first. Enter the commission and a slippage figure of at least one tick per side for a liquid index future, and use the same figures in every variant.
  2. Set next-bar execution. A fill on the same close that produced the signal uses a price you could not have traded.
  3. Write the split date and the pass rule. About 70 percent of the history for choosing settings, the rest for judging. Decide now what counts as a pass: for example, the out-of-sample average trade after costs must be above zero and at least half of the in-sample figure.
  4. Run the three variants. Same data, same costs, same exit. Compare them on the out-of-sample part, not the in-sample part, because the in-sample winner is the one the search was built to find.
Four steps before any result: 1 set commission and slippage, 2 use next-bar fills, 3 write the split date and pass rule, 4 run all three variants with identical settings. The history is split into an in-sample part of about 70 percent for choosing settings and an out-of-sample part of about 30 percent that is run unchanged and judged once. Fix rules before results Four steps, then one split 1 Set costs 2 Next-bar fills 3 Split, pass rule 4 Run all three In-sample 70% OOS 30% Choose settings Judge once OOS is the result you could trade. So: judge the three variants there.
The order of the backtest steps and where the data split sits. Costs and execution are set before any run; the split date and pass rule are written before any result is seen.

To show what a report looks like at the end of this process, here is a real run. It did not test MACD and RSI. It used a Standard Deviation rule as a stand-in, built from a standard indicator, as its only entry and exit, with no stop, no target and no filter, on NQ daily bars from 2019-01-02 to 2025-06-30, long and short, one contract, with $20 commission and $10 slippage charged on every trade. The result below is the one candidate the search kept out of 1,024 it tried, chosen for its return against its drawdown. Picking the kept candidate after the fact flatters it: the other candidates did worse, and the best of a thousand tries always looks better than the method deserves. Nothing here says the rule earned that money or that a reader can expect it; it is a report to learn to read.

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%

Read the table the way you would read your own MACD and RSI run. The trade count, 135 over six and a half years of daily bars, is about 20 trades a year, which is enough to see a pattern but not enough to trust a per-trade figure closely, so the out-of-sample stretch deserves most of your attention. The max drawdown of $90,210 against a net profit of $267,055 tells you how deep the worst stretch went relative to the whole result; a combined MACD and RSI variant that cuts the trade count in half should show a shallower drawdown than MACD alone if the filter really removed losers. Time in market of 86.03% says the rule was almost always holding a position, which is normal for a rule whose exit is the opposite signal and has no stop. The equity curve in the Performance Report is where you check the two things a table cannot show: whether the out-of-sample stretch keeps a similar slope to the in-sample part, and whether the deepest drawdown sits in one short episode or is spread across the period.

Lock the pass rule first: six backtest steps in order, write the rules, set costs and fills, split by date, set the pass rule before looking, run the three variants, then accept or reject against the written rule Lock the pass rule first Six steps, in this order 1 2 3 4 5 6 Write the rules Set costs, fills Split by date Set pass rule Run 3 variants Accept or reject Decide the bar before looking. So: never move it after the test.
Find the marked out-of-sample stretch and compare its slope with the part before it, then find the deepest drawdown and note how long the curve took to climb back. Do the same for each of your three variants before deciding which to keep. NQ · daily · 2019-01-02 to 2025-06-30 · CPU engine backtest

Your next step: write the split date and the pass rule on paper, run MACD alone, RSI alone and the combined rule with identical costs and next-bar fills, and compare the out-of-sample average trade of the three. If the combined variant does not beat both single rules on that number, keep the single rule and drop the filter.

Frequently asked questions

Is it effective to use MACD and RSI together?

It depends on the market, the bar size and the costs, and only a three-way backtest can tell you. Run MACD alone, RSI alone and the combined rule on identical data with the same commission, slippage and next-bar fills, and compare the out-of-sample average trade. The combination is effective when the RSI filter removes losing trades faster than it removes profit, so the average trade rises while the trade count falls.

What are the best MACD and RSI settings?

Start with the common settings, MACD 12, 26, 9 and RSI 14, with an RSI filter level around 65 for longs and 35 for shorts. Then test the neighbouring values, such as fast 8 to 16, slow 20 to 32, signal 6 to 12, RSI length 10 to 20 and filter level 55 to 75. Keep a setting only if the values next to it give similar results; a single setting that looks far better than its neighbours is usually fitted to noise.

Is a MACD and RSI combination better than one indicator alone?

Not by default. Adding RSI as a filter always reduces the number of trades, but it only improves the strategy if the removed trades were mostly losers. Compare net profit per year after costs and the average trade across the three variants: if the combined rule keeps most of the profit with about half the trades, the filter is doing its job; if profit falls as fast as the trade count, the filter is only making the strategy smaller.

How do I backtest a MACD RSI strategy properly?

Set commission and slippage first, use next-bar execution so fills happen at the open after the signal bar, and write down a split date and a pass rule before the first run. Choose settings on the earlier part of the history, then run them unchanged on the later part and judge with the pre-written rule. Run the single-indicator variants with the same settings so the comparison is fair, and read the equity curve for the out-of-sample slope and the deepest drawdown.

References

  • Wilder, J. W. (1978). New Concepts in Technical Trading Systems. Trend Research.
  • Park, C.-H., & Irwin, S. H. (2007). What Do We Know About the Profitability of Technical Analysis? Journal of Economic Surveys, 21(4), 786–826.
  • Bailey, D. H., Borwein, J., López de Prado, M., & Zhu, Q. J. (2014). Pseudo-Mathematics and Financial Charlatanism: The Effects of Backtest Overfitting on Out-of-Sample Performance. Notices of the American Mathematical Society, 61(5), 458–471.