Concept
TRAMA
TRAMA, also known as trend regularity adaptive moving average, is a Trend concept. The Library holds 1 implementation, a working definition you can pull into Quant.
Trend Regularity Adaptive MA. LuxAlgo
Top TRAMA indicator
The top custom implementation, built on the original standard TRAMA formula.
1 total
From studying TRAMA to trading it: take the implementation below into Quant and backtest it instantly.
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 does. Because the flattened line tends to settle near consolidation equilibrium, traders also read it as dynamic support and resistance 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 regimes and one of the cleaner range detectors in the adaptive-lookback family.
How to identify TRAMA's behavior
One length, one recursion, one very recognizable habit: hugging trends and flatlining ranges.
- 1Set the single lookback length; it governs both the extreme detection window and the averaging of regularity events.
- 2Each bar, record whether the rolling highest high or lowest low changed; these binary events are the raw regularity data.
- 3Average the events over the window and square the result to get the bar's smoothing constant.
- 4Update the line: previous value plus the constant times the gap to current price, an EMA whose alpha breathes with regularity.
- 5Read 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 that fixed-length averages can only approximate.
- As an envelope midline: bands drawn around TRAMA in the 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: 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: 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: 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.
Concept family
Trend
100 concepts mapped · 100 in the Library
TRAMA FAQ
Turn TRAMA into a trading strategy.
Take the implementation from this page into Quant, then build on it, backtest it on real data, and keep refining it in conversation.
.png&w=3840&q=75)