All scripts
Pro Β· Invite-only on TradingView
Free Β· Open source
Range-Filtered Momentum
Momentum crosses only when the market is really trending.
- Type
- Momentum with range filter
- Replaces
- MACD Β· TSI Β· TRIX Β· AO
- Recommended
- 4h and daily chart
- Price
- Free, open source
Range-Filtered Momentum takes a momentum indicator such as the MACD and mutes it during sideways phases: the line and histogram turn gray, and no crosses are marked. Only when the market is trending do bullish and bearish crosses appear. On top of that, the value can be divided by the ATR β so a MACD of 1 on gold means the same as on Bitcoin or EUR/USD. You can choose from seven momentum sources. This page explains every element β and above all, what you do with it and why.
Overview
At a glance
What does it do?
It shows momentum like a MACD β and grays everything out as long as the market is moving sideways. Crosses are only marked in trend phases.
What do I do with it?
You only read crosses when theyβre colored and deliberately skip the gray phases.
Why?
In sideways phases, the momentum and signal lines cross all the time. Those crosses carry little information but cost money.
What do I get?
Less noise, clearer signals β and values you can compare across markets and timeframes.
On your chart in 2 minutes
Quickstart
- 01
Open the script page
The TradingView button at the top of this page takes you straight to the script page. The script is free and open source.
- 02
Add it to your favorites
On the script page, click Add to favorites (the star icon).
- 03
Add it to your chart
At the top of the chart, click Indicators, choose Favorites on the left and click Range-Filtered Momentum. Alternatively, search for βIndicatrβ in the Indicators window.
- 04
Pick a market and timeframe
Start with a market with clear trend phases, for example gold, the S&P 500 or Bitcoin, on 4h or the daily chart. The default β MACD 12/26/9, ATR-normalized, with an ADX filter β is fine to begin with.
The chart explained
What you see on the chart
- 1Momentum and signal line The thick line is green above and red below the gray signal line.
- 2Histogram The distance between the two lines. Strong color: the distance is growing. Pale color: itβs shrinking.
- 3Range phase Gray background, gray line and histogram: the filter reports a sideways market.
- 4Bullish cross Green triangle at the bottom: the momentum line crosses above the signal line while the market is trending.
- 5Bearish cross Red triangle at the top: the momentum line crosses below the signal line while the market is trending.
Elements 1 and 2
Momentum line, signal line and histogram
What does it do?
The momentum line measures how forcefully price is moving. The signal line is its smoothed average. The histogram shows the distance between the two.
What do I do with it?
You read whether momentum is building or fading. When the histogram turns paler, the move is losing steam β often before the lines cross.
Why?
Moves rarely end abruptly. Usually the momentum fades first, then price turns. The histogram makes that transition visible.
What do I get?
You recognize early whether a trend still has strength or is getting tired β and can review your trade accordingly.
| Histogram color | Meaning |
|---|---|
| Strong green | Above zero and growing: bullish momentum is increasing. |
| Pale green | Above zero but shrinking: the upward momentum is fading. |
| Strong red | Below zero and falling: bearish momentum is increasing. |
| Pale red | Below zero but rising: the downward momentum is fading. |
| Gray | Range phase: the filter reports no trend. |
Element 3
The range filter
The filter decides for every candle: trend or range? You can choose the ADX (default: above 20 counts as a trend), the Choppiness Index (below 61.8 counts as a trend) or both together. In range phases, the background turns gray, the line and histogram turn gray, and crosses arenβt marked.
Elements 4 and 5
Crosses in trend phases
A bullish cross (green triangle at the bottom) forms when the momentum line crosses above the signal line while the filter reports a trend. A bearish cross (red triangle at the top) forms the mirrored way. In gray phases the lines still cross β just without a mark.
Before you take a cross
- Does the cross point in the direction of the bigger trend β or against it?
- Where is it relative to the zero line? Early in the move or late after a long run?
- Are there important events coming up? Central banks, jobs data, inflation, earnings for stocks.
- Is there a major level right ahead of you β an old high or low, a round number?
- What are the related markets doing? For gold the dollar and real yields, for stocks bond yields, for Bitcoin risk sentiment.
Seven to choose from
Momentum sources and ATR normalization
| Source | What it measures | Character |
|---|---|---|
| MACD | Distance between a fast and a slow EMA. | The classic. A good default. |
| TSI | Double-smoothed price change relative to its fluctuation. | Calm, fixed scale, few spikes. |
| TRIX | Change of a triple-smoothed EMA. | Very calm, filters out small moves, reacts later. |
| Awesome Oscillator | Distance between two averages of the candle midpoint (5 and 34). | Fixed standard lengths, strong swings. |
| ROC | Percentage change compared with N candles ago. | Direct and fast, rather jagged. |
| Momentum | Price difference compared with N candles ago. | The simplest form, fast and restless. |
| Elder Ray | Bull Power + Bear Power: high and low relative to the EMA. | Shows how far buyers and sellers push price away from the EMA. |
All sources use their standard formulas. Donβt keep switching until the past looks good β stick with one and learn how it behaves on your market.
Why ATR normalization?
MACD, Awesome Oscillator, Momentum and Elder Ray are measured in price units. A MACD of 50 is tiny on Bitcoin and impossible on EUR/USD. With Normalize price-based sources by ATR (on by default), the script divides these values by the ATR, the average candle range. A value of 1 then roughly means: the momentum is as large as a typical candle.
Step by step
How to work with it
- 01
Determine the direction
Set the direction yourself β on the price chart, with a long-term average like the EMA 200 or on the higher timeframe. Range-Filtered Momentum only tells you whether the market is moving.
- 02
Skip the gray phases
As long as the pane is gray, thereβs nothing to do. Use the time to mark levels.
- 03
Wait for a cross in the trend direction
In an uptrend you care about the green triangles, in a downtrend about the red ones. Wait until the candle has closed.
- 04
Check the price chart
Is the cross at a meaningful level? Has the move already run a long way?
- 05
Set stop and size
Place the stop beyond the last swing low (for a short, beyond the swing high) and calculate the position size from it β always the same risk per trade.
- 06
Watch the momentum
When the histogram turns pale or a cross appears against your trade, thatβs the moment to actively review it.
Recommendations
Which markets fit β and which donβt
Momentum crosses work best in markets that move in clear legs: move, pause, next move. The more jagged a market is, the more often the crosses alternate β even in phases the filter recognizes as a trend.
Gold
4h and daily chart
- Pronounced legs: gold moves in distinct waves, driven by the dollar, real yields and central-bank buying. The filter recognizes these phases well.
- The bearish cross at the high at the end of August (see the chart above) came in a trend phase β shortly before the downtrend began.
- Tip: gold often jumps before US inflation data and central-bank dates β better to wait there.
S&P 500, Nasdaq and large-cap stocks
Daily chart
- Very liquid, with persistent trends and orderly pullbacks.
- On the daily chart the legs are clean and the noise is low.
- Careful: earnings create gaps that flip momentum instantly.
Bitcoin
4h and daily chart
- Strong trend phases in both directions, traded around the clock, no overnight gaps.
- In between, long sideways phases β exactly where the filter shows its strength.
Bad example: GBP/NZD
GBP/NZD
4h
- Jagged instead of moving in legs: the pair often rises or falls in small, irregular waves. The ADX reports a trend, yet momentum turns every few days.
- Two central banks and a commodity currency pull in different directions β short spikes without follow-through.
- Thin and expensive: with many crosses, wide spreads eat a large part of the result.
- The lesson: the filter hides sideways phases, but not jagged market behavior within a trend.
EUR/USD and major forex pairs
Daily chart
- Very liquid, but trends form over weeks. Lots of back and forth on 4h.
- Much calmer on the daily chart. ATR normalization makes the values comparable with other markets here.
Which timeframe?
- Daily chart: few, calm crosses, big moves. Costs hardly matter.
- 4h: a good compromise for gold, Bitcoin and indices. More crosses, but earlier.
- 1h and below: many crosses, even in trend phases. Spread and fees weigh heavily. Only with a clear direction from the higher timeframe.
Both directions
Long and short
Range-Filtered Momentum marks crosses in both directions by the same rules. In the gold example you see both: the bearish cross at the high at the end of August, shortly before the downtrend, and bullish crosses in the bounces afterwards. Which of them you trade depends on the direction you set beforehand.
The part that makes the difference
Practical tips
- Direction first, cross second. The cross is the timing, not the reason for the trade.
- If the triangles keep alternating, the market is jagged β even if the filter reports a trend. Better to pause or move to a higher timeframe.
- Take a pale histogram seriously. Shrinking momentum is often the first warning before the lines cross.
- Filter more strictly if needed. With Both (ADX and Choppiness) or a higher ADX value, trend phases become rarer but clearer.
- Calculate position size from the stop β always the same risk per trade.
Donβt miss a thing
Setting up alerts
- 01
Open the alert window
At the top of the chart, click Alert or press
Alt + A. - 02
Choose the condition
Under Condition, select Range-Filtered Momentum and below it the alert you want.
- 03
Trigger
Choose βOnce per bar closeβ so the alert only fires on the finished candle.
- 04
Notification
Choose app, email or webhook and save.
| Alert | When it fires |
|---|---|
| Bullish cross in trend | Bullish cross while the filter reports a trend (green triangle). |
| Bearish cross in trend | Bearish cross while the filter reports a trend (red triangle). |
| Trend phase starts | The filter switches from range to trend β the gray phase ends. |
Reference
All settings
Double-click the name βRFM [Indicatr]β at the top left of the indicator pane to open the settings. They are split into three groups. The defaults are enough to get started.
1 Β· Momentum source
- SourceDefault: MACD
- Which of the seven momentum sources is shown.
- Fast length (MACD / TSI short)Default: 12
- Fast length for the MACD, short smoothing for the TSI. Smaller = earlier but more restless.
- Slow length (MACD / TSI long)Default: 26
- Slow length for the MACD, long smoothing for the TSI. Larger = calmer and later.
- Signal lengthDefault: 9
- Smoothing of the signal line for all sources. Smaller = more crosses, larger = fewer but later.
- Length (TRIX / ROC / Momentum / Elder EMA)Default: 14
- Lookback for these four sources. The Awesome Oscillator always uses its standard lengths 5 and 34.
- Normalize price-based sources by ATRDefault: on
- Divides MACD, Awesome Oscillator, Momentum and Elder Ray by the ATR. Makes the values comparable across markets and timeframes. Turn it off if you want to see the classic price values.
- ATR lengthDefault: 14
- Lookback of the ATR used for normalization.
2 Β· Range filter
- FilterDefault: ADX
- ADX: trend when the ADX is above the threshold. Choppiness Index: trend when the market isnβt chopping back and forth much. Both: both have to report a trend β stricter, fewer crosses.
- ADX lengthDefault: 14
- Lookback of the ADX.
- ADX: trending aboveDefault: 20
- From this value on, the market counts as trending. Higher = fewer but stronger trend phases.
- Choppiness lengthDefault: 14
- Lookback of the Choppiness Index.
- Choppiness: ranging aboveDefault: 61.8
- Above this value, the market counts as sideways. Lower = stricter, more gray phases.
3 Β· Display
- Bullish / Bearish / Range (muted)Default: Green / Red / Gray
- Colors for the line, histogram, triangles and range phases.
- Show crosses (trend phases only)Default: on
- The triangles for crosses in trend phases.
- Shade range phasesDefault: on
- Gray background in range phases. Turn it off if it feels too busy β the line and histogram still turn gray.
From practice
Common mistakes
- Taking every triangle as an entry. The filter knows no direction β without your own decision on direction, you trade half of the crosses against the trend.
- Thinking the filter is infallible. It hides sideways phases, but not jagged trends.
- Trading crosses on the open candle. Until the candle closes, everything can still change.
- Chasing late crosses. A cross far from the zero line often comes when the move has already run.
- Turning off ATR normalization and comparing markets. Without normalization, MACD values of different markets arenβt comparable.
- Optimizing settings on the past. What looks perfect in hindsight is often chance.
FAQ
Does Range-Filtered Momentum repaint?
Not on closed candles. On the current, still open candle, lines, colors and triangles can change until it closes. Thatβs why you should use βOnce per bar closeβ for alerts.
Why donβt I see a cross even though the lines cross?
Because the filter is reporting a range phase (gray). Crosses are deliberately not marked there.
Why are there red triangles in an uptrend?
Because ADX and Choppiness only measure whether the market is moving directionally, not where. In an uptrend, a red triangle is often a pullback. You determine the direction yourself.
What do the numbers on the scale mean?
With ATR normalization, MACD, Awesome Oscillator, Momentum and Elder Ray are shown in ATR units: 1 roughly means one average candle range. TSI, TRIX and ROC keep their own scale.
ADX or Choppiness β which is better?
The ADX is the more widely used standard. The Choppiness Index measures more how much the market chops back and forth. Both is the strictest. Check on your market which filter recognizes the sideways phases more cleanly.
What does the script cost?
Nothing. Range-Filtered Momentum is free and open source on TradingView. You can look at the code and learn how it works.
How do you like Range-Filtered Momentum?
Your vote tells us what to work on next.
Support
Report a problem or share feedback
Something off with the script, unclear in the docs, or you have an idea? Write to us. We reply by email.
Range-Filtered Momentum
Greys out range phases and marks crosses only while the market trends. ATR normalisation makes values comparable across markets.
For educational and analytical purposes only. Not financial advice. Marks and signals are not recommendations to buy or sell. Past behavior is no guarantee of the future. Trading involves a risk of loss.