What is Trix?
The Trix (Triple Exponential Average) indicator is a momentum oscillator developed by Jack Hutson. It aims to filter out insignificant price movements (noise) by applying an exponential moving average (EMA) three times to the closing price. The result is a smooth line that oscillates around a zero line, helping traders identify trends, gauge momentum, and spot potential divergences.
Because of its triple smoothing, Trix is particularly effective at reducing short-term fluctuations, allowing traders to focus on the broader trend and less on minor price changes.
Components and Calculation
Trix is derived from a triple-smoothed Exponential Moving Average of the closing price. The calculation process involves three main steps:
- First EMA: Calculate an EMA of the closing price over a specified period (e.g., 15 periods).
- Second EMA: Calculate an EMA of the first EMA over the same period.
- Third EMA: Calculate an EMA of the second EMA over the same period.
- Trix Value: The percentage change of this third EMA from the previous bar. This effectively turns the smoothed moving average into a momentum oscillator.
Often, a signal line (typically a 9-period EMA of the Trix line) is also plotted to generate crossover signals, similar to how MACD works.
Basic Trix Implementation in Pine Script
Pine Script v5 provides a built-in `ta.trix()` function for easy implementation.
//@version=5
indicator("My Trix Indicator", overlay=false)
// Inputs for Trix parameters
length = input.int(15, title="Trix Length")
signalLength = input.int(9, title="Signal Length")
// Calculate Trix value using the built-in function
trixValue = ta.trix(close, length)
// Calculate the Signal Line (EMA of Trix)
trixSignal = ta.ema(trixValue, signalLength)
// Plot the Trix Line
plot(trixValue, title="Trix Line", color=color.blue, linewidth=2)
// Plot the Signal Line
plot(trixSignal, title="Signal Line", color=color.red, linewidth=1)
// Plot a horizontal line at zero for reference
hline(0, "Zero Line", color=color.gray, linestyle=hline.style_dotted)
Practical Trix Trading Strategies
1. Zero Line Crossover Strategy (Trend Direction)
One of the simplest ways to use Trix is by observing its crossovers with the zero line. This indicates a shift in the primary trend or momentum.
- Bullish Signal: Trix crosses above the zero line. Suggests an uptrend or increasing bullish momentum.
- Bearish Signal: Trix crosses below the zero line. Suggests a downtrend or increasing bearish momentum.
//@version=5
strategy("Trix Zero Line Strategy", overlay=true)
length = input.int(15, title="Trix Length")
signalLength = input.int(9, title="Signal Length")
trixValue = ta.trix(close, length)
trixSignal = ta.ema(trixValue, signalLength)
// Define conditions
longCondition = ta.crossover(trixValue, 0)
shortCondition = ta.crossunder(trixValue, 0)
// Strategy entries
if (longCondition)
strategy.entry("Long", strategy.long)
if (shortCondition)
strategy.entry("Short", strategy.short)
// Optional: Plot Trix in a separate pane for visualization
// plot(trixValue, "Trix Line", color.blue)
// plot(trixSignal, "Signal Line", color.red)
// hline(0, "Zero Line", color.gray)
2. Trix Signal Line Crossover Strategy (Entry/Exit Signals)
Similar to MACD, Trix also uses a signal line (an EMA of Trix) to generate more frequent and refined trading signals.
- Bullish Crossover: Trix Line crosses above its Signal Line. This is often used as a buy signal.
- Bearish Crossover: Trix Line crosses below its Signal Line. This is often used as a sell signal.
//@version=5
strategy("Trix Signal Crossover Strategy", overlay=true)
length = input.int(15, title="Trix Length")
signalLength = input.int(9, title="Signal Length")
trixValue = ta.trix(close, length)
trixSignal = ta.ema(trixValue, signalLength)
// Define conditions
longCondition = ta.crossover(trixValue, trixSignal)
shortCondition = ta.crossunder(trixValue, trixSignal)
// Strategy entries
if (longCondition)
strategy.entry("Long", strategy.long)
if (shortCondition)
strategy.entry("Short", strategy.short)
// Optional: Plot Trix in a separate pane for visualization
// plot(trixValue, "Trix Line", color.blue)
// plot(trixSignal, "Signal Line", color.red)
// hline(0, "Zero Line", color.gray)
3. Trix Divergence Strategy
Divergence between the Trix indicator and price action can signal potential reversals, indicating that the current trend is losing momentum.
- Bullish Divergence: Price makes a lower low, but Trix makes a higher low. Suggests weakening bearish momentum.
- Bearish Divergence: Price makes a higher high, but Trix makes a lower high. Suggests weakening bullish momentum.
//@version=5
indicator("Trix Divergence Scanner", overlay=true)
length = input.int(15, title="Trix Length")
signalLength = input.int(9, title="Signal Length")
trixValue = ta.trix(close, length)
trixSignal = ta.ema(trixValue, signalLength)
// Plot Trix and Signal lines for visual confirmation
plot(trixValue, "Trix Line", color.blue)
plot(trixSignal, "Signal Line", color.red)
hline(0, "Zero Line", color.gray)
// Simple divergence detection (conceptual, for advanced scripts this needs robust pivot detection)
// This is a simplified example and might need refinement for actual trading.
// Bullish Divergence Example
bullishDiv = (close[2] > close[1] and close[1] > close) and (trixValue[2] < trixValue[1] and trixValue[1] < trixValue)
// Bearish Divergence Example
bearishDiv = (close[2] < close[1] and close[1] < close) and (trixValue[2] > trixValue[1] and trixValue[1] > trixValue)
// Plot divergence signals on the price chart
plotshape(bullishDiv, title="Bullish Divergence", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(bearishDiv, title="Bearish Divergence", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)
// Alert for divergence
alertcondition(bullishDiv, "Bullish Trix Divergence", "Trix bullish divergence detected! Potential reversal.")
alertcondition(bearishDiv, "Bearish Trix Divergence", "Trix bearish divergence detected! Potential reversal.")
Optimizing Trix Performance
To enhance the effectiveness of the Trix indicator in Pine Script:
- Parameter Tuning: The `length` parameter significantly impacts Trix's responsiveness. A shorter length makes it more sensitive but prone to noise, while a longer length smooths it more but adds lag. Experiment with different lengths (e.g., 9, 15, 20) and `signalLength` for various assets and timeframes.
- Combine with Volume: Confirm Trix signals with volume. Strong breakouts or crossovers on high volume are generally more reliable.
- Multi-Timeframe Analysis: Use Trix on a higher timeframe to confirm the overall trend direction, and then look for signals on a lower timeframe for entries and exits.
- Filter Ranging Markets: Trix performs best in trending markets. In choppy or sideways markets, it can still produce false signals despite its smoothing. Consider using a trend filter (like ADX or SuperTrend) to confirm trend presence before acting on Trix signals.
Common Trix Pitfalls
- Lag: Due to its extensive smoothing, Trix can sometimes generate signals later than other, less-smoothed oscillators, potentially causing delayed entries/exits.
- Whipsaws in Consolidation: Despite noise reduction, Trix can still produce false signals in prolonged sideways or ranging markets, especially if the `length` is too short.
- Over-Reliance: No single indicator provides perfect signals. Trix should always be used in conjunction with other technical analysis tools and proper risk management.
- Misinterpretation of Flat Trix: A Trix line that is flat and hovering near zero indicates a lack of strong trend or momentum, making it a poor time for trend-following strategies.
Conclusion
The Trix indicator is a sophisticated and highly effective momentum oscillator in Pine Script for TradingView. Its triple-smoothing mechanism significantly reduces noise, allowing traders to identify underlying trends, gauge momentum, and spot crucial divergences with greater clarity. By mastering its components, understanding its signals, and integrating it thoughtfully into your multi-indicator strategies, you can leverage Trix to refine your market analysis and enhance your trading decisions.