TRIX
One-bar change of a triple-smoothed exponential average of log price, scaled as on TradingView, with a signal line and a zero line.
- TRIX
- Built into Spectral
- Updates every tick
- trix
- triple exponential
- moving average
- signal line
- momentum
- oscillator
MIT-0: free to use, change and share, no attribution needed. What you build from it is yours.
Already in Spectral: add it from the Indicators toolbox. The file here is the same indicator written as a custom indicator, to change or learn from. Installed, it appears next to the built-in one, marked Custom.

Overview
TRIX (Jack Hutson) smooths the logarithm of price three times with an exponential average of Length bars and shows the one-bar change of the result, multiplied by 10,000: roughly the triple-smoothed price's change per bar in hundredths of a percent. The triple smoothing removes most short swings, so TRIX tracks the underlying trend's speed. The signal line is an exponential average of TRIX.
How to read it
Above zero the triple-smoothed price is rising, below zero falling; the zero cross marks a turn in that trend. TRIX crossing its signal line is the earlier, more frequent signal of momentum changing.
Divergences, where price makes a new high or low and TRIX does not, show the trend losing speed. Because it is heavily smoothed, TRIX turns late but rarely whipsaws.
Settings and limitations
Length defaults to 18 bars, as on TradingView, with a 9-bar signal; 15 is the other common length. The averages start at the first bar, so the earliest values are unreliable; they settle after about three times Length bars.
Notes
Matches TRIX on TradingView: 10,000 x the one-bar change of the triple exponential average of the logarithm of price. The classic percent form (StockCharts and some other platforms) is 1/100 of it with the same shape. TradingView draws no signal line; here it is an exponential average of TRIX.
Settings
Each setting appears in the indicator's settings panel in Spectral, next to a color setting for every output.
| Setting | Type | Default | Range or options | What it does |
|---|---|---|---|---|
| Length | Whole number | 18 | 1 – 500 | Bars in each of the three exponential averages. |
| Signal length | Whole number | 9 | 1 – 500 | Bars in the exponential average of TRIX that forms the signal line. |
| Source | Price source | close | open, high, low, close, hlc3 | Price TRIX is calculated from. |
What it draws
Lines
- TRIXsolid · 1.5 px · primary
#B7A1C8 - Signalsolid · 1 px
#C4A46A
Levels
- Zero linedotted · 1 px
#788493
Source
Save it as trix.js and add it with Indicators → Custom indicators → Add file…. The format is explained in the custom indicators guide.
// Copyright (c) 2026 Spectral
// SPDX-License-Identifier: MIT-0
// Free to use, copy, modify and share: https://spectral.trade/docs/custom-indicators/LICENSE.txt
/** @type {import('./spectral-indicator').IndicatorV2} */
export default {
schemaVersion: 2,
id: 'trix',
name: 'TRIX',
shortName: 'TRIX',
version: '1.0.0',
author: 'Spectral',
description: 'One-bar change of a triple-smoothed exponential average of log price, scaled as on TradingView, with a signal line and a zero line.',
pane: 'oscillator',
live: { lookback: 1 },
inputs: {
length: { type: 'integer', label: 'Length', default: 18, min: 1, max: 500, description: 'Bars in each of the three exponential averages.' },
signalLength: { type: 'integer', label: 'Signal length', default: 9, min: 1, max: 500, description: 'Bars in the exponential average of TRIX that forms the signal line.' },
source: { type: 'source', label: 'Source', default: 'close', description: 'Price TRIX is calculated from.' },
},
plots: {
trix: { label: 'TRIX', color: '#B7A1C8', lineWidth: 1.5, primary: true },
signal: { label: 'Signal', color: '#C4A46A', lineWidth: 1 },
},
levels: {
zero: { label: 'Zero line', color: '#788493', lineStyle: 'dotted' },
},
docs: {
overview: 'TRIX (Jack Hutson) smooths the logarithm of price three times with an exponential average of Length bars and shows the one-bar change of the result, multiplied by 10,000: roughly the triple-smoothed price\'s change per bar in hundredths of a percent. The triple smoothing removes most short swings, so TRIX tracks the underlying trend\'s speed. The signal line is an exponential average of TRIX.',
howToRead: 'Above zero the triple-smoothed price is rising, below zero falling; the zero cross marks a turn in that trend. TRIX crossing its signal line is the earlier, more frequent signal of momentum changing.\n\nDivergences, where price makes a new high or low and TRIX does not, show the trend losing speed. Because it is heavily smoothed, TRIX turns late but rarely whipsaws.',
settings: 'Length defaults to 18 bars, as on TradingView, with a 9-bar signal; 15 is the other common length. The averages start at the first bar, so the earliest values are unreliable; they settle after about three times Length bars.',
notes: 'Matches TRIX on TradingView: 10,000 x the one-bar change of the triple exponential average of the logarithm of price. The classic percent form (StockCharts and some other platforms) is 1/100 of it with the same shape. TradingView draws no signal line; here it is an exponential average of TRIX.',
},
calculate(ctx) {
const { bars, inputs, ta } = ctx;
const logPrice = ta.source(bars, inputs.source).map((price) => (price > 0 ? Math.log(price) : null));
const triple = ta.ema(ta.ema(ta.ema(logPrice, inputs.length), inputs.length), inputs.length);
const trix = triple.map((value, index) => {
const previous = index > 0 ? triple[index - 1] : null;
return value === null || previous === null ? null : 10000 * (value - previous);
});
return { plots: { trix, signal: ta.ema(trix, inputs.signalLength) }, levels: { zero: 0 } };
},
};Adapt it with an LLM
Paste this into your assistant and replace the second-to-last line with the change you want.
Start from this Spectral custom indicator: https://spectral.trade/indicators/trix.js Format reference: https://spectral.trade/docs/custom-indicators.llm.md Keep the file format and every rule of the reference; give the result a new id, name, shortName and version, and update docs and input descriptions to match. Keep its live updates exact and fast (section "Fast live updates" of the reference): carry values from bar to bar only through ctx.ta, and raise live.lookback if the change reads further back; Spectral rejects a file whose live updates differ from a full recalculation or are too slow. Change I want: <describe the change> Answer with the complete file in one code block, ready to save as <id>.js.


