The bb trend flat indicator asks one question before anything else. Is this market trending or flat? Bandwidth answers it. When the bands sit wider than their own recent average, the basis line takes a direction colour. When they do not, it turns grey.
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 | Main price chart |
| Plots | 3: Trend Up, Trend Down, Flat |
| Alerts | popup, push notification, email, sound |
| Inputs | 13 |
What the BB Trend Flat Indicator draws on the chart
Three line plots that share one path.
`Trend Up` colours the basis lime.
`Trend Down` colours it red.
`Flat` colours it silver.
A corner panel prints the current regime.
Only one of the three holds a value per bar.
- Trend Up: line, lime, width 2
- Trend Down: line, red, width 2
- Flat: line, silver, width 2

How the BB Trend Flat Indicator calculates its values
Bands and bandwidth
`InpBBPeriod` `20` gives the basis and the deviation. `InpDeviation` `2.0` sets the band distance. Bandwidth is how far apart those bands sit, relative to the basis.
Against its own history
One comparison decides everything. `InpAvgPeriod` `50` averages recent bandwidth. Current bandwidth over that average times `InpTrendFactor` `1.00` is the test.
Picking the colour
Wide enough means trending. Then price against the basis decides which direction colour applies. Too narrow and the flat buffer takes over instead.
How to read the signals
Grey means the bands are no wider than usual.
Lime means wide bands with price above the basis.
Red means wide bands with price below it.
The line itself is always the Bollinger basis.
Long grey stretches describe a range.
The panel repeats the regime in words.
Alert channels in this build: popup, push notification, email and sound, one message per closed bar.
`EnableAlerts` sits over the regime alerts and ships true with `EnablePopup`. Turn on `EnablePushNotify` for a phone, `EnableEmail` for mail, or `EnableSound` to play `SoundFile`. Regime changes report once a bar.
Every BB Trend Flat Indicator input
Core settings
| Setting | What it does | Default |
|---|---|---|
InpBBPeriod |
Bollinger period (basis + std-dev). Bars in the band calculation, `20`. | 20 |
InpDeviation |
Std-dev multiplier. Band width in deviations, `2.0`. | 2.0 |
InpAvgPeriod |
Bandwidth averaging period. Bars in the bandwidth average, `50`. | 50 |
InpTrendFactor |
Trending if bandwidth > avg * factor. Multiplier on that average, `1.00`. | 1.00 |
Display settings
| Setting | What it does | Default |
|---|---|---|
ShowPanel |
Show corner info panel. Show the corner readout, `true`. | on |
PanelCorner |
0=UL 1=UR 2=LL 3=LR. Which corner, `0`. | 0 |
PanelBg |
Panel background. | RGB 18,22,30 |
Alert settings
| Setting | What it does | Default |
|---|---|---|
EnableAlerts |
Master switch, `true`. | on |
EnablePopup |
Box in the terminal, `true`. | on |
EnablePushNotify |
(see inputs panel) | off |
EnableEmail |
Mail on a regime change, `false`. | off |
EnableSound |
(see inputs panel) | off |
SoundFile |
Which clip plays, `”alert.wav”`. | alert.wav |

Settings that fit your chart
Fifty bars of bandwidth history needs a chart where conditions actually change. EURUSD H1 is the reference chart. Regime switches come a few times a week there. On M5 the colour changes hourly. On H4 each regime lasts a fortnight.
When the BB Trend Flat Indicator fails
Bandwidth widens after a move has started.
A factor of exactly one puts the test on a knife edge.
Direction comes from one close against the basis.
Warm-up needs seventy bars before any colour appears.
Copy the compiled BB Trend Flat 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 BB Trend Flat Indicator: Bollinger Bands on Wikipedia, Bollinger Bands at BabyPips.
Download the BB Trend Flat Indicator for MT4 and MT5
The zip holds the compiled BB Trend Flat 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.
FAQ
What does InpTrendFactor 1.00 compare?
Current bandwidth against its own fifty-bar average. At exactly one the test flips the moment bandwidth crosses the average, which sits on a knife edge. Raising it to 1.2 demands genuinely wide bands before the trend colour appears.
Why does InpAvgPeriod judge bandwidth, not price?
Because direction alone cannot separate a trend from a range. Bandwidth measures how far the bands have spread, which says whether there is enough movement for a direction to matter at all.
How does the Flat plot differ from the other two?
It takes over whenever bandwidth fails the test, regardless of where price sits. All three colour the same basis line, so exactly one holds a value on any bar and the line never breaks.
What does the InpAvgPeriod 50 window cover?
Fifty bars of past bandwidth, roughly two days on H1. That is long enough to know what normal looks like for this market without dragging in conditions from a month ago.
Are results guaranteed?
No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the BB Trend Flat Indicator as one input. Always backtest before trading live.
External references
- The core method is documented in Loan note on Wikipedia.
- Additional market context is at the MetaTrader 5 user guide at MetaTrader.
