# TRAMA

Also known as: trend regularity adaptive moving average.
A Trend concept (Moving-average lineage) in the LuxAlgo Library, with 1 indicator implementation.

## What is TRAMA?

TRAMA, the Trend Regularity Adaptive Moving Average, is an adaptive average introduced by LuxAlgo whose smoothing factor is driven by how regularly price prints new extremes. Each bar, the calculation checks whether price set a new highest high or lowest low for the lookback; the average of those events over the window, squared, becomes the smoothing constant of an exponential-style recursion. When a trend keeps making new highs or lows, the factor rises toward one and the average tracks price closely; in a flat range with no new extremes, it decays toward zero and the line flattens out.

The design goal is the classic adaptive-average trade-off: hug the trend while it is regular, go quiet when it is not, instead of whipsawing through a range the way a fixed-length [EMA](https://www.luxalgo.com/library/concept/ema/) does. Because the flattened line tends to settle near consolidation equilibrium, traders also read it as [dynamic support and resistance](https://www.luxalgo.com/library/concept/dynamic-s-r-via-ma/) during trends.

The mechanics reward a close look. Each bar contributes a binary event, did the rolling highest high or lowest low change, and the average of those binaries over the window is a regularity score between 0 and 1. Squaring that score is the design's teeth: a market printing occasional new extremes gets a tiny smoothing constant and an almost frozen line, while one printing them persistently gets near-EMA responsiveness. The recursion itself is one line, the previous value plus the squared score times the distance to price, so the entire personality lives in how the score breathes.

Two behavioral consequences follow. TRAMA wakes up late by design: a fresh breakout must string together several new extremes before the factor climbs, so the line joins trends rather than anticipating them, and its pronounced flattening is arguably the more original signal, a visible, quantitative statement that regularity has died. Since its release it has become one of the most widely used adaptive averages on the platform, a staple base for [slope-filter](https://www.luxalgo.com/library/concept/ma-slope-filter/) regimes and one of the cleaner range detectors in the [adaptive-lookback](https://www.luxalgo.com/library/concept/adaptive-lookback-ma/) family.

## How to identify TRAMA's behavior

One length, one recursion, one very recognizable habit: hugging trends and flatlining ranges.

1. Set the single lookback length; it governs both the extreme detection window and the averaging of regularity events.
2. Each bar, record whether the rolling highest high or lowest low changed; these binary events are the raw regularity data.
3. Average the events over the window and square the result to get the bar's smoothing constant.
4. Update the line: previous value plus the constant times the gap to current price, an EMA whose alpha breathes with regularity.
5. Read the two states: a line tracking price closely says extremes are printing regularly, and a flat line parked mid-range says they have stopped.

## How traders use it

- As a trend filter: a rising TRAMA with price above it frames long bias, and its pronounced flattening warns that conditions have turned rangebound and trend entries lack the support of regular new extremes.
- As dynamic support and resistance: pullbacks to a rising (or bounces to a falling) TRAMA are watched for reactions in the trend's direction, since the line stalls near recent equilibrium rather than chasing every fluctuation.
- As a crossover component: paired with price or a faster average, it tends to fire fewer signals in flat conditions than fixed-length crossovers, though it remains a lagging, smoothed line and cannot call turns early.
- As a quantitative range detector: the line's slope collapsing toward zero is a readable no-trade flag, a graded input for a [trend regime label](https://www.luxalgo.com/library/concept/trend-regime-label/) that fixed-length averages can only approximate.
- As an envelope midline: bands drawn around TRAMA in the [MA envelope](https://www.luxalgo.com/library/concept/ma-envelope/) style inherit its adaptivity, framing stretch tightly while the trend is regular and going appropriately quiet when the line flattens.

## TRAMA vs other adaptive averages

- **KAMA** (https://www.luxalgo.com/library/concept/kama/): KAMA adapts through the efficiency ratio, net travel divided by total travel, so it reacts to path quality. TRAMA counts new extremes, reacting to trend regularity. A grinding trend with few fresh extremes can satisfy KAMA while leaving TRAMA flat, which is exactly the difference in philosophy.
- **VIDYA** (https://www.luxalgo.com/library/concept/vidya/): VIDYA scales its alpha with a volatility index, speeding up whenever movement expands, directional or not. TRAMA only accelerates when movement makes new highs or lows, so volatile chop wakes VIDYA while TRAMA sleeps through it, usually to TRAMA's advantage in ranges.
- **EMA** (https://www.luxalgo.com/library/concept/ema/): The EMA's alpha is a constant; TRAMA's is a squared regularity score that lives between zero and the EMA's responsiveness. In persistent trends the two converge; in ranges the EMA keeps wiggling through price while TRAMA parks, which is the entire argument for the adaptive layer.

## FAQ

### How is TRAMA different from KAMA or other adaptive moving averages?

The adaptation input differs. [KAMA](https://www.luxalgo.com/library/concept/kama/) scales its smoothing with the efficiency ratio, net movement divided by total movement, and [VIDYA](https://www.luxalgo.com/library/concept/vidya/) scales with a volatility index. TRAMA instead counts how often price sets a new highest high or lowest low over the lookback, then squares the average of those events, so it responds specifically to trend regularity: repeated new extremes speed it up, and their absence flattens it.

### What settings does TRAMA use?

One lookback length controls everything: the window for detecting new highest highs and lowest lows, and the window for averaging those events into the smoothing factor. Longer lengths make the line smoother and slower to re-engage after ranges; shorter lengths track price sooner but flatten less decisively. There is no universally best length, so match it to the timeframe and instrument you trade.

### Why is the regularity score squared?

To make the two states decisive. Squaring a number between 0 and 1 shrinks small values far more than large ones, so sporadic new extremes produce a near-zero smoothing constant and a firmly flat line, while persistent extremes keep responsiveness high. Without the square, middling regularity would produce middling tracking, and the line would lose the clean trend-versus-range personality that is its point.

### Does TRAMA repaint?

No. The recursion runs on confirmed data, each bar's value using only current and past prices, so history never redraws. The live bar's value updates tick by tick until the close, which is standard for any indicator computed on a forming bar. Its honest limitation is lag rather than hindsight: the regularity score needs several bars of evidence before the line commits to a new state.

### Why does a flat TRAMA act as support and resistance?

When extremes stop printing, the recursion nearly freezes, leaving the line parked close to the last stretch of accepted prices, which is where a consolidation's equilibrium sits. Returns to that vicinity meet the memory of recent balance, so reactions there are common. It is a tendency with a mechanism behind it, not a promise, and it works best when the broader trend context agrees with the touch.

### What markets and timeframes suit TRAMA?

Any market with alternating trend and range phases, which is most of them; the length just needs matching to the rhythm traded. Its flattening behavior earns the most value in range-prone instruments, where fixed averages whipsaw, and its late wake-up costs the most in markets that reverse violently without printing a regular sequence of extremes first. As always, the parameter transfers poorly across instruments without a check.

## Implementations in the Library

- Trend Regularity Adaptive Moving Average (LuxAlgo): https://www.luxalgo.com/library/indicator/trend-regularity-adaptive-moving-average/

## Related concepts

- SMA: https://www.luxalgo.com/library/concept/sma/
- EMA: https://www.luxalgo.com/library/concept/ema/
- Adaptive-lookback MA: https://www.luxalgo.com/library/concept/adaptive-lookback-ma/
- MA Envelope: https://www.luxalgo.com/library/concept/ma-envelope/
- SWMA: https://www.luxalgo.com/library/concept/swma/
- RMA: https://www.luxalgo.com/library/concept/rma/
- HMA: https://www.luxalgo.com/library/concept/hma/
- KAMA: https://www.luxalgo.com/library/concept/kama/
- JMA: https://www.luxalgo.com/library/concept/jma/
- ZLEMA: https://www.luxalgo.com/library/concept/zlema/

---

Source: https://www.luxalgo.com/library/concept/trama/ (LuxAlgo Library, the encyclopedia of trading & technical analysis). Free to use with attribution: https://www.luxalgo.com/library/license/