A triangular moving average is centred, which means it reads bars on both sides of the one it draws. That makes it smooth and it makes it repaint. The tma trend detector indicator puts that behaviour on a switch, so you choose between the smoother line and one that never moves.
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 | 6: TMA Up, TMA Down, Upper Band, Lower Band, Buy, Sell |
| Alerts | popup, push notification, email, sound |
| Inputs | 12 |
What the Tma trend detector Indicator draws on the chart
Six plots, all on the price chart.
`TMA Up` colours the line lime green.
`TMA Down` colours the same line orange red.
`Upper Band` and `Lower Band` run silver.
`Buy` uses arrow 233 and `Sell` uses arrow 234.
The bands are a range envelope, not deviation.
- TMA Up: line, lime green, width 2
- TMA Down: line, orange red, width 2
- Upper Band: line, silver, width 1
- Lower Band: line, silver, width 1
- Buy: arrow, lime, width 2, arrow code 233
- Sell: arrow, red, width 2, arrow code 234

How the Tma trend detector Indicator calculates its values
Two averaging passes
That is what makes it triangular. `TmaPeriod` `20` runs a simple average, then averages the result again. Weight ends up highest in the middle of the window.
The repaint switch
Centred weighting reads forward. With `NonRepaint` `true` the calculation only looks backward, so a drawn value never changes. Set it false and the line smooths but shifts.
Bands and marks
iATR at `AtrPeriod` `14` sizes the envelope. `BandMult` `2.0` sets its width. A change in line direction prints the mark, offset by `ArrowAtrFrac` `0.6` of the range.
How to read the signals
Line colour is the current direction of the average.
A mark appears where that direction flipped.
Bands widen when the market gets busier.
Price outside a band is unusual rather than a signal.
Leave `NonRepaint` on if a mark must stay put.
Two averaging passes make the line very smooth.
Alert channels in this build: popup, push notification, email and sound, one message per closed bar.
`EnableAlerts` is the master switch over the flip alerts and ships true with `EnablePopup`. `EnablePushNotify` pushes to the mobile terminal, `EnableEmail` sends mail and `EnableSound` plays `SoundFile`. Those three start off.
Every Tma trend detector Indicator input
Core settings
| Setting | What it does | Default |
|---|---|---|
TmaPeriod |
TMA period (each SMA pass). Bars in each averaging pass, `20`. | 20 |
AtrPeriod |
ATR period for the envelope. Bars behind the range figure, `14`. | 14 |
BandMult |
Envelope width (x ATR). Envelope width in ranges, `2.0`. | 2.0 |
NonRepaint |
true = backward-only (non-repaint). Backward-only build, `true`. | on |
Display settings
| Setting | What it does | Default |
|---|---|---|
ShowBands |
draw the ATR envelope. Draw the envelope, `true`. | on |
ArrowAtrFrac |
arrow offset (x ATR). Mark offset in ranges, `0.6`. | 0.6 |
Alert settings
| Setting | What it does | Default |
|---|---|---|
EnableAlerts |
master alert switch. Master switch, `true`. | on |
EnablePopup |
popup alert. Box in the terminal, `true`. | on |
EnablePushNotify |
push to mobile MetaTrader. | off |
EnableEmail |
email alert. Mail on a flip, `false`. | off |
EnableSound |
sound alert. | off |
SoundFile |
Which clip plays, `”alert.wav”`. | alert.wav |

Settings that fit your chart
Twenty bars run twice is a slow line by design. EURUSD H1 is the reference chart. Direction flips come a couple of times a week there. On M5 the line barely turns within a session. On H4 each flip marks a real trend change.
When the Tma trend detector Indicator fails
Two averaging passes lag more than one.
With the switch off, a drawn value can move.
In a range the direction flips without follow-through.
The bands measure range, so they say nothing about direction.
Copy the compiled Tma trend detector 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.
Download the Tma trend detector Indicator for MT4 and MT5
The zip holds the compiled Tma trend detector 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
Does the TMA Up line move once it is drawn?
Not with `NonRepaint` `true`. The average then reads only backward, so a printed value stays put. Set it false and the centred weighting reads forward bars, which smooths the line but shifts its recent values as new bars arrive.
Why does TmaPeriod run two passes?
Because that is what makes an average triangular. Averaging an average puts the most weight in the middle of the window, which gives a far smoother line than a single pass at the same length.
How does BandMult 2.0 size the envelope?
It multiplies the current range reading, so each band sits two average ranges from the line. That makes the envelope widen in a busy market and tighten in a quiet one automatically.
Should ShowBands stay on?
It depends what you want from the chart. The bands add context about how far price has stretched from the average, but with six plots already drawn some traders prefer the line and marks alone.
Are results guaranteed?
No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Tma trend detector Indicator as one input. Always backtest before trading live.
Category: this is part of our Trend collection. Browse more Trend for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.
External references
- Learn more about the underlying method in Exchange rate on Wikipedia.
- For wider market background, see What Are Charts at StockCharts ChartSchool.
