Flat Trend RSI Indicator: Colouring the Dead Stretches

Written by Dominic Walsh · Published · Last updated

The flat trend rsi indicator answers a question a plain momentum line leaves open: has this market actually been going anywhere? It watches how long the reading has sat inside a middle band, and colours the line flat once that run gets long enough.

This build ships as a compiled .ex4 for MT4 and .ex5 for MT5; the screenshots below come from EURUSD H1.

Platforms MT4 (.ex4) + MT5 (.ex5)
Chart window Separate window (levels 40 / 50 / 60)
Plots 3: RSI Trend Up, RSI Trend Down, RSI Flat
Alerts popup, push notification, email, sound
Inputs 12

What the Flat Trend RSI Indicator draws on the chart

RSI Trend Up carries the reading while it sits above the middle band.

RSI Trend Down takes over below it.

RSI Flat replaces both once the reading has stayed inside the band long enough to qualify.

Levels cross the pane at 40, 50 and 60, matching the band boundaries and the midpoint.

  • RSI Trend Up: line, dodger blue, width 2
  • RSI Trend Down: line, crimson, width 2
  • RSI Flat: line, gray, width 2
EURUSD H1 pane: the flat trend rsi indicator showing RSI Flat through a dead stretch.
EURUSD H1 pane: the flat trend rsi indicator showing RSI Flat through a dead stretch.

How the Flat Trend RSI Indicator calculates its values

The reading itself

One call gives a standard momentum reading over RsiLength bars. Nothing about that half differs from a conventional build.

What follows is the colouring logic, which is where this tool earns its name.

Counting the flat run

For each bar the code walks back and counts how many consecutive readings sat between FlatZoneLower and FlatZoneUpper.

Once that count reaches FlatBarsTrigger the bar gets the flat colour. A single reading inside the band is not enough; it takes a sustained run.

Which buffer gets the value

All three buffers carry the same reading, and only one receives it on any bar. That is what makes the line change colour rather than showing three separate curves.

The code also writes the neighbouring bar value into the same buffer, which keeps the coloured segments joined instead of leaving gaps at each transition.

How to read the signals

A flat stretch means the reading held the middle band for at least FlatBarsTrigger bars, which usually means price went nowhere.

The colour changing out of flat is the more useful event than the reading crossing 50.

OverboughtLevel and OversoldLevel sit outside the plotted levels as reference points for the extremes.

The flat state is retrospective by construction: it needs the run to have already happened.

Alert channels in this build: popup, push notification, email and sound, one message per closed bar.

Alerts cover popup, push, email and sound on a state change. A bar time check keeps it to one alert per closed bar.

Every Flat Trend RSI Indicator input

Core settings

Setting What it does Default
RsiLength RsiLength is the momentum lookback. It defaults to 14. 14
FlatZoneLower FlatZoneLower is the floor of the middle band, 40 by default. 40
FlatZoneUpper FlatZoneUpper is its ceiling at 60. 60
FlatBarsTrigger FlatBarsTrigger is how many consecutive bars inside the band it takes to count as flat, 10 by default. 10
OverboughtLevel OverboughtLevel is the upper extreme reference at 70. 70
OversoldLevel OversoldLevel is the lower one at 30. 30

Alert settings

Setting What it does Default
EnableAlerts (see inputs panel) on
EnablePopup (see inputs panel) on
EnablePushNotify (see inputs panel) off
EnableEmail (see inputs panel) off
EnableSound (see inputs panel) off
SoundFile (see inputs panel) alert.wav
Inputs panel for the flat trend rsi indicator showing RsiLength, FlatZoneLower and FlatBarsTrigger.
Inputs panel for the flat trend rsi indicator showing RsiLength, FlatZoneLower and FlatBarsTrigger.

Settings that fit your chart

The screenshot uses EURUSD H1. Flat detection is most useful on charts where dead stretches actually cost you something, which usually means intraday. H1 and H4 give runs long enough for FlatBarsTrigger to mean something. On M1 a ten bar run passes in minutes.

When the Flat Trend RSI Indicator fails

The flat state arrives late by design. It needs FlatBarsTrigger bars to have already passed inside the band before it can colour anything.

A market can trend steadily while the reading sits inside 40 to 60, so flat here means flat momentum rather than flat price.

Widening the band with FlatZoneLower and FlatZoneUpper makes flat far more common, and narrowing it makes the state nearly unreachable.

The colouring adds no information the reading did not already carry. It makes a pattern easier to see rather than detecting anything new.

Copy the compiled Flat Trend RSI Indicator file into your MQL4/Indicators folder, and the MT5 build into MQL5/Indicators, then restart the terminal and drag it onto a chart. The step-by-step guide with screenshots is at how to install MT4 and MT5 indicators.

Background reading on the method behind the Flat Trend RSI Indicator: Nium on Wikipedia, Net New 52 Week Highs at StockCharts ChartSchool.

Download the Flat Trend RSI Indicator for MT4 and MT5

The zip holds the compiled Flat Trend RSI Indicator build for MT4 and MT5, plus a short README. Compiled files only, no source. Enter your email below and the download link arrives in your inbox.

Download this indicator free

Enter your email and the file is yours. You also get the full MT4 and MT5 library.

  • 1,380+ indicators
  • MT4 and MT5 files
  • No spam, unsubscribe any time

FAQ

What has to happen before RSI Flat takes over?

The reading has to sit between FlatZoneLower and FlatZoneUpper for FlatBarsTrigger consecutive bars. At the defaults that means ten bars inside 40 to 60. One reading in the band changes nothing, since the state describes a sustained run rather than a moment.

Does flat here mean price is flat?

Not necessarily. It means momentum has been flat. A market can grind steadily in one direction while the reading holds the middle band, especially on a slow trend. Read the state as momentum going nowhere rather than as price standing still.

Should I widen FlatZoneLower and FlatZoneUpper?

Only if flat almost never triggers on your chart. Widening it makes the state far more common, since more of the reading range counts as the middle. Narrowing it does the reverse and can make flat effectively unreachable at a ten bar trigger.

Why do OverboughtLevel and OversoldLevel exist if the bands are 40 and 60?

They mark the extremes at 70 and 30 as reference points, separate from the flat detection. The flat logic uses FlatZoneLower and FlatZoneUpper only, so the two pairs do different jobs and can be set independently.

Are results guaranteed?

No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Flat Trend RSI Indicator as one input. Always backtest before trading live.

Category: this is part of our Oscillators collection. Also, browse more Oscillators for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.

External references

Dominic Walsh - Forex trader and MT4/MT5 developer

About the author

Written by Dominic Walsh, a Forex trader and MT4/MT5 indicator, Expert Advisor and script developer. Every tool on forexmt4systems.com is tested on live charts before release and ships with ready-to-use compiled MT4 (.ex4) and MT5 (.ex5) files. Learn more about the trader and developer behind this site.

How we build, test and correct every tool: Editorial & Testing Policy. Trading carries risk; see the disclaimer.

Leave a Comment