// recipe
Add a trend filter to a 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.
4 min read
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.
The wizard opens with these answers. Change any of them, then try it on candles in the editor’s Dry-run panel.
- 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.
- Add a row. Under the entry conditions press + compare. The new row compares two indicators and starts as EMA(50) CROSS_UP EMA(200).
- Make it a filter. Set the left side to
CLOSE, the operator to>and the right side toSMAwith period 200. Leave the group on ALL (AND): an entry now needs both rows on the same candle. - 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.
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.
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.
The wizard opens with these answers. Change any of them, then try it on candles in the editor’s Dry-run panel.
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.
Test your own idea
Create a free account, start from a template or from your own rules, and read your first report.
More guides
- What is backtesting?How a backtest works, which numbers matter and the traps that make results look too good.
- TradingView backtesting vs JanoriumWhat each tool does well, where it falls short, and which one to pick for crypto strategies.
- Build a strategy with ChatGPT or ClaudeDescribe a trading idea in plain words and let an AI assistant write the strategy config.
- How to backtest a crypto strategyStep by step: rules, costs, the run, the report — with a real BTC backtest as the example.
- Backtest metrics explainedSharpe, drawdown, profit factor, win rate and the rest — what they mean and what counts as good.
- Strategy builder glossaryEvery term of the strategy editor — layers, conditions, bar windows, exits, DCA — explained with an example.
- How Janorium backtestsThe methodology: data, when orders fill, stops, fees, funding, liquidation, metrics — and what is not modeled.
- An RSI strategy in 5 minutesThe classic RSI oversold rule, built in the wizard and backtested step by step.
- Why a backtest has 0 tradesThe usual reasons a strategy never enters, where to see them and how to fix each.