◆ New — Strategy Validator, Code Fixer & Prop Compliance Checker are live. Try one free →
Home / Strategies / RMA Crossover + MACD Filter
Combination strategy

RMA Crossover + MACD Filter

A combination strategy that uses a RMA crossover to define trend direction and MACD as a filter on those signals. The idea: only act on crossovers that agree with momentum, to skip some of the false signals a crossover alone produces. Educational only — not predictive, and trading involves risk of loss.

How it works

Trend trigger — RMA crossover. A moving average (MA) takes the average price over a chosen number of bars and plots it as a single line that updates each bar. Two RMAs of different lengths (e.g. 9 and 21) are plotted; the fast one crossing above the slow one is read as upward momentum, and below as downward.

Filter — MACD. MACD (Moving Average Convergence Divergence) is a momentum and trend-following indicator developed by Gerald Appel in the late 1970s. Here it is used to require the MACD line to agree with the cross — above its signal line for longs, below for shorts.

Why combine them. A moving-average crossover defines direction but fires on every cross, including in choppy conditions; adding a MACD filter tries to skip crossovers that trigger into already-stretched momentum. Both components are lagging by construction, so this reduces some false signals at the cost of entering later — it does not remove risk or guarantee anything.

Entry rules

Exit rules

Risk notes

Pine v6 example

//@version=6
strategy("RMA Crossover + MACD Filter (Educational)", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10, process_orders_on_close=true)

fastLen = input.int(9, "Fast RMA length", minval=1)
slowLen = input.int(21, "Slow RMA length", minval=1)

fast = ta.rma(close, fastLen)
slow = ta.rma(close, slowLen)
[macdLine, signalLine, histLine] = ta.macd(close, 12, 26, 9)

longCond  = ta.crossover(fast, slow)  and macdLine > signalLine
shortCond = ta.crossunder(fast, slow) and macdLine < signalLine

if longCond
    strategy.entry("Long", strategy.long)
if shortCond
    strategy.entry("Short", strategy.short)

plot(fast, "Fast RMA", color.aqua)
plot(slow, "Slow RMA", color.orange)

// Educational only. Not financial advice. Validate for look-ahead bias &
// repainting before trusting any backtest. Past results do not predict future.

Pitfalls

FAQ

Does adding MACD improve a RMA crossover?

It can reduce some false signals by skipping crossovers that fire into stretched momentum, but it also delays or removes some good entries, and it does not make the strategy predictive. Test it out-of-sample and account for costs. This is educational, not advice.

What settings should I use?

9/21 for the RMAs and standard MACD settings are common starting points, but there is no universally correct value — choose lengths that fit your timeframe and validate out-of-sample rather than tuning to past data.

Educational & software only — not financial advice, not a recommendation to trade. Backtests are illustrative; past performance does not predict future results. Trading involves substantial risk of loss.

Catch the bug that compiles.Run auditGet Pro