# Add a trend filter to a strategy

> A trend filter lets a strategy trade only with the larger trend. Add a 200-period moving average to an RSI strategy in four steps, then check that it helped.

Guide · Janorium · Published 2026-11-05  
Web page: https://janorium.com/guides/trend-filter-trading-strategy

A trend filter is one more entry condition that lets a strategy trade only with the larger trend — most often “the price is above its 200-period moving average”. This recipe adds one to an RSI dip-buying strategy in four steps and shows how to check whether it helped.

## What a trend filter does

Buy-the-dip rules have a known weak spot: in a falling market a dip is often followed by a deeper one. A trend filter keeps them out of such a market. It is not a signal of its own — it only blocks entries the main rule would make in the wrong regime, and never adds one. The usual ones:

- **Price above SMA(200)** — the most common: slow, simple, one row.
- **EMA(50) above EMA(200)** — the same idea on two averages, as in the golden cross.
- **A higher timeframe** — the trend measured on daily candles while the strategy trades 4-hour ones.

## Add it in four steps

> **Idea: Buy oversold**
>
> Trades BTCUSDT on Binance spot, on 4-hour candles.
>
> Buys when the relative strength index RSI(14) is below 30, using 50% of the free capital.
>
> Closes the trade at +5% profit or at a loss of −4%, whichever comes first. It also closes when RSI(14) is above 50.
>
> Every entry and every exit pays 0.1% in fees plus 0.01% slippage.
>
> [Open in the wizard](https://janorium.com/strategies/new?idea=meanReversion&setting=0&src=guide:trend-filter-trading-strategy)

*The starting point: the strategy of [the RSI recipe](https://janorium.com/guides/rsi-trading-strategy-in-5-minutes).*

1. **Open the strategy.** Press **Open in the wizard** on the card, then **Open in the editor** — or open one of your own strategies for editing.
2. **Add a row.** Under the entry conditions press **+ compare**. The new row compares two indicators and starts as EMA(50) CROSS_UP EMA(200).
3. **Make it a filter.** Set the left side to `CLOSE`, the operator to `>` and the right side to `SMA` with period 200. Leave the group on **ALL (AND)**: an entry now needs both rows on the same candle.
4. **Compare.** Dry-run it on the same period as before and compare the number of trades, the return and the drawdown with the run without the filter.

> **Why “>” and not CROSS_UP**
>
> A filter is a state: the price must be above the average on the candle the RSI row fires. CROSS_UP is true only on the one candle of the cross, and RSI rarely sits below 30 on the very candle the price climbs over its average — the strategy would hardly trade.

## Which average, on which candles

SMA(200) counts candles, not days. On daily candles it is the classic 200-day average; on 4-hour candles it covers about 33 days. For the 200-day line on a 4-hour strategy there are two ways:

- **SMA(1200)** on the strategy’s own candles — 200 days × 6 four-hour candles.
- **SMA(200) on 1d** — in the SMA’s modifiers set **Timeframe** to 1d. Its value updates once a day, after the daily candle closes, so the backtest never reads a day that has not ended.

A long average needs history before its first value. Janorium loads that history from before the start of the period when the coin has it, so the test still starts on the date you set.

## Did the filter help?

- **It should cut bad trades more than good ones.** If the return falls in step with the number of trades, the filter only made the strategy trade less.
- **Look at the drawdown.** Staying out of falling markets is what a trend filter is for; that is where it should show.
- **Check other coins and periods.** A filter picked because it looked best on one chart is fitted to that chart. Choose the rule first, then test it on what you have not looked at.

> **On BTC, 2020–2026**
>
> Dry runs of the RSI recipe on BTC 4-hour candles from 2020-01-01 to 2026-10-01: without the filter, more than 200 trades and almost half of the capital lost; with CLOSE > SMA(200), 21 trades, a gain of about 10% and a drawdown of about 5%; with the 200-day line — SMA(1200), or SMA(200) on 1d, which gave the same trades — 79 trades and about 13%. One coin and one period, and still far behind holding BTC: run it on others before believing it.

## The filter on its own

Turned into a strategy of its own, a trend filter is a trend-following rule: buy when the fast average crosses above the slow one, sell when it crosses back.

> **Idea: Follow the trend**
>
> Trades BTCUSDT on Binance spot, on daily candles.
>
> Buys when the simple moving average SMA(50) crosses above SMA(200), using 50% of the free capital.
>
> Closes the trade at a loss of −6%. It also closes when SMA(50) crosses below SMA(200).
>
> Every entry and every exit pays 0.1% in fees plus 0.01% slippage.
>
> [Open in the wizard](https://janorium.com/strategies/new?idea=trend&tf=1d&setting=2&src=guide:trend-filter-trading-strategy)

*The SMA 50/200 golden cross on daily BTC candles, as the wizard builds it. [How the golden cross did on the top-20 coins](https://janorium.com/articles/golden-cross-top-20-crypto-2020-2025).*

## Frequently asked questions

### What is a trend filter in trading?

A condition that lets a strategy enter only in the direction of the larger trend, such as “the price is above its 200-day moving average”. It does not create trades; it removes the ones the main rule would make against the trend.

### Which moving average is best as a trend filter?

There is no best one. The 200-day simple average is the most common because it is slow and simple; shorter averages switch more often and filter less. Whatever you choose, test it on coins and periods you did not choose it on.

### Can the trend be measured on another timeframe?

Yes. Any indicator in a condition can be computed on a timeframe higher than the strategy’s — daily, weekly or monthly — and its value changes only after that higher candle has closed.
