Trend Regularity Adaptive Moving Average
- Indicadores
-
Minh Truong Pham
Hello, my name is Pham and I am a programmer and trader! At here, I create amazing forex indicators and expert advisors for Metatrader.
I will try:
+ Provide best tools base on my 5 years experience as a trader and 10 years as a programmer. - Versão: 1.0
- Ativações: 20
# TRAMA — Trend Regularity Adaptive Moving Average
**A moving average that knows the difference between a trend and noise — and adapts its speed automatically, bar by bar.**
Most moving averages force you to pick one speed and live with it: fast enough to catch trends, and it whips you around in every chop; slow enough to survive chop, and it lags every real move. TRAMA (Trend Regularity Adaptive Moving Average) removes that trade-off. It measures how *regularly* price has been making new highs or new lows over the lookback window — a genuine, one-directional trend — and speeds up only when that regularity is high. The moment price starts alternating between new highs and new lows (chop, range, indecision), TRAMA automatically slows down and flattens out, filtering the noise without you touching a single setting.
## How it works
For every bar, TRAMA checks two things over the lookback `Length`:
1. Did the rolling **highest high** just make a new high? Did the rolling **lowest low** just make a new low?
2. How often has that happened across the last `Length` bars — i.e., how *regular* is the directional movement?
That regularity score (0 to 1) is squared and used as the smoothing constant of a recursive moving average. High regularity (a clean, sustained trend) → the constant approaches 1 → TRAMA hugs price closely and reacts fast. Low regularity (price chopping both ways) → the constant approaches 0 → TRAMA barely moves, staying flat through the noise.
The result: a single, self-adjusting line that stretches out and tracks price tightly during real trends, and goes nearly flat during ranges — with no separate "trend detector" or second indicator required.
## Features
- ✅ **Fully adaptive** — one `Length` input, no fast/slow period pair to tune
- ✅ **Flattens in ranges automatically** — filters chop without lag-heavy extra smoothing
- ✅ **Tracks price tightly in trends** — reacts faster than a fixed-period MA of the same length
- ✅ **Selectable price source** — Close, Open, High, Low, Median, Typical, Weighted
- ✅ **Non-repainting** — calculated on confirmed history, incremental updates each tick
- ✅ Lightweight — no DLLs, no external dependencies
- ✅ Works on **any symbol and any timeframe**
- ✅ Available for both **MetaTrader 5** and **MetaTrader 4**
## How to trade / read signals with it
TRAMA is a trend filter and dynamic support/resistance line, not a signal generator with arrows — read it the way you'd read any adaptive trend MA:
| What you see | What it means |
|---|---|
| Line **flat / barely moving** | No regular trend — price is ranging or choppy. Stand aside or trade the range, not the trend. |
| Line **sloping and tracking price closely** | A regular trend is underway — the more the line tilts and hugs price, the stronger the directional regularity. |
| **Price above a rising line** | Uptrend bias — look for longs |
| **Price below a falling line** | Downtrend bias — look for shorts |
| **Price crosses the line after it was flat** | Possible start of a new trend leg — early signal, wait for the line itself to start sloping in the same direction before trusting it |
| **Price pulls back to the line and holds** | Trend intact — treat the line as dynamic support (uptrend) / resistance (downtrend) |
**Long playbook:**
1. Wait for the line to slope up and price to be trading above it.
2. Enter on a pullback to the line that holds (price doesn't close back below it).
3. Stop-loss below the most recent swing low, or a fixed ATR distance.
4. Exit when price closes back through the line, or when the line itself flattens out.
**Short playbook:** mirror the above on a falling line with price below it.
**Signals to skip:**
- A single price/line cross while the line is still flat — that's noise, not a new trend, by TRAMA's own design.
- Trading against a clearly sloped higher-timeframe TRAMA.
- Entries right into major news releases — no trend filter substitutes for volatility risk management.
**Tip:** because TRAMA already filters chop internally, it pairs well with a simple slope/angle rule (e.g., "only trade when the line has moved X points over the last N bars") instead of adding a second, correlated indicator like ADX.
## Input parameters
| Parameter | Default | Description |
|---|---|---|
| **Length** | 99 | Lookback window used for the highest/lowest regularity measurement and the adaptive smoothing |
| **Source** | Close | Applied price: Close, Open, High, Low, Median, Typical, Weighted |
**Tuning tips:** a larger `Length` produces a smoother, more conservative line that needs a longer, more regular trend before it speeds up — good for higher timeframes and swing trading. A smaller `Length` reacts faster but resets its "regularity memory" more quickly, giving more (and earlier) signals at the cost of more false starts.
## Notes
- Faithful port of the original TRAMA concept published for TradingView by LuxAlgo, rebuilt natively for MetaTrader (both MT5 and MT4 versions included/available).
- Calculation is fully incremental — efficient even with a large `Length` on high tick-volume symbols.
- Questions, suggestions, or a feature request? Leave a comment — happy to extend it (e.g. optional slope-based coloring or alerts) on request.
