Pine Script Tillson T3

Master this advanced, low-lag, and smooth moving average in TradingView's Pine Script for precise trend identification and robust signals.

Posted: Expertise: Intermediate/Advanced

What is the Tillson T3 Moving Average?

The Tillson T3 Moving Average, developed by Tim Tillson, is an advanced moving average that is renowned for its combination of smoothness and responsiveness. It achieves this by applying a specific type of moving average (Generalized Double Exponential Moving Average or GDEMA) six times, with a volumetric factor, resulting in a highly filtered and low-lagging trend indicator. The goal of T3 is to provide a cleaner visual representation of the trend, minimizing whipsaws often seen in traditional moving averages while still reacting promptly to significant price changes.

In Pine Script, T3 is a sophisticated tool for traders who seek a highly optimized moving average that offers clarity in trend direction without compromising too much on timeliness.

Components and Calculation

The calculation of T3 is quite intricate, as it involves a series of nested Exponential Moving Averages (EMAs) and a volume factor. The core idea is based on the GDEMA, which is a weighted average of an EMA and a double EMA (DEMA).

The formula for GDEMA is: `GDEMA(price, period, volumeFactor) = (1 + volumeFactor) * EMA(price, period) - volumeFactor * EMA(EMA(price, period), period)`

The T3 indicator applies this GDEMA calculation recursively six times. Each successive application further smooths the line while attempting to minimize lag due to the volumetric factor (often denoted as `vFactor` or `a`).

//@version=5 // Helper function to calculate GDEMA, which T3 relies on
      gdema(src, len, vFactor) => ema1 = ta.ema(src, len) ema2 = 
      ta.ema(ema1, len) (1 + vFactor) * ema1 - vFactor * ema2
      // The actual T3 calculation (simplified for clarity, using custom gdema function)
      // For demonstration, a conceptual breakdown; ta.t3 handles the nesting.
      // T3 = gdema(gdema(gdema(gdema(gdema(gdema(source, len, vFactor), len, vFactor), len, vFactor), len, vFactor), len, vFactor), len, vFactor)
    

Fortunately, Pine Script provides a direct built-in function to compute T3, abstracting away the complex nested calculations.

Basic Tillson T3 Implementation in Pine Script

Pine Script v5 provides the convenient built-in function `ta.t3()` for the Tillson T3 Moving Average.

//@version5 indicator("My Tillson T3 Indicator", overlay=true)
  // Inputs for T3 parameters
  length = input.int(10, title="T3 Length", minval=1) vFactor = input.float(0.7, title="Volume Factor (vFactor)", minval=0.0, maxval=1.0)
  // Often called 'a' or 'factor'
  // Calculate T3 using the built-in function
  t3Value = ta.t3(close, length, vFactor)
  // Plot the T3 line
  plot(t3Value, title="T3", color=color.blue, linewidth=2) 
Standard Parameters: Common settings for T3 are a `length` of 10 and a `vFactor` (volume factor) of 0.7. Adjusting these can significantly impact its behavior.

Practical Tillson T3 Strategies

1. T3 as a Trend Direction Filter (Color Change)

T3's smooth nature and responsiveness make it ideal for identifying the prevailing trend direction with minimal false signals. Coloring the T3 line based on its slope is a common and effective visual strategy.

//@version=5 strategy("T3 Trend Color Strategy", overlay=true)
  // Inputs for T3
  length = input.int(10, title="T3 Length", minval=1) vFactor = input.float(0.7, title="Volume Factor", minval=0.0, maxval=1.0)
  // Calculate T3
  t3Value = ta.t3(close, length, vFactor)
  // Determine T3 color based on its direction
  t3Color = t3Value > t3Value[1] ? color.green : color.red
  // Plot the T3 line with dynamic color
  plot(t3Value, title="T3", color=t3Color, linewidth=2)
  // Example entry logic: buy when T3 turns green, sell when T3 turns red
  longCondition = t3Value > t3Value[1] and t3Value[1] <= t3Value[2]
  // T3 turns up 
  shortCondition = t3Value < t3Value[1] and t3Value[1] >= t3Value[2]
  // T3 turns down
  if (longCondition) strategy.entry("Long", strategy.long) if (shortCondition) strategy.entry("Short", strategy.short) 

2. T3 Crossover Strategy (with Price or another T3)

Crossovers involving T3 are often considered strong signals due to its unique smoothing and lag reduction. This can be price crossing the T3 line, or two T3s of different lengths crossing each other.


      //@version=5
      strategy("T3 Crossover Strategy", overlay=true)
      // Inputs for T3 lengths
      fastT3Length = input.int(10, title="Fast T3 Length", minval=1) slowT3Length = input.int(20, title="Slow T3 Length", minval=1) vFactor = input.float(0.7, title="Volume Factor", minval=0.0, maxval=1.0)
      // Calculate T3s
      fastT3 = ta.t3(close, fastT3Length, vFactor) slowT3 = ta.t3(close, slowT3Length, vFactor)
      // Plot the T3s
      plot(fastT3, title="Fast T3", color=color.blue, linewidth=2) plot(slowT3, title="Slow T3", color=color.orange, linewidth=2)
      // Crossover conditions (Fast T3 crossing Slow T3)
      longCondition = ta.crossover(fastT3, slowT3) shortCondition = ta.crossunder(fastT3, slowT3)
      // Strategy entries/exits
      if (longCondition) strategy.entry("Long", strategy.long) if (shortCondition) strategy.entry("Short", strategy.short) 

3. T3 for Dynamic Support and Resistance

Given its smoothness and responsiveness, T3 can effectively act as dynamic support in uptrends and dynamic resistance in downtrends. Price interaction with the T3 line can offer insights into the trend's health and potential turning points.


      //@version=5
      indicator("T3 Dynamic S/R", overlay=true) length = input.int(10, title="T3 Length", minval=1) vFactor = input.float(0.7, title="Volume Factor", minval=0.0, maxval=1.0) t3Value = ta.t3(close, length, vFactor) plot(t3Value, title="T3", color=color.blue, linewidth=2)
      // Highlight potential support/resistance interactions (conceptual - adjust thresholds)
      // These conditions check for price being very close to T3, implying a test or bounce
      isSupportTouch = close > t3Value * 0.995 and close < t3Value * 1.005 and t3Value[1] < close[1]
      // Price touches T3 from below or just above
      isResistanceTouch = close < t3Value * 1.005
      and close > t3Value * 0.995 and t3Value[1] > close[1]
      // Price touches T3 from above or just below plotshape(isSupportTouch, title="Potential Support", location=location.belowbar, color=color.lime, style=shape.circle, size=size.tiny) plotshape(isResistanceTouch, title="Potential Resistance", location=location.abovebar, color=color.fuchsia, style=shape.circle, size=size.tiny) 

Optimizing T3 Performance

To get the most from the Tillson T3 Moving Average in Pine Script:

Balance is Key: The beauty of T3 lies in its balance between lag reduction and smoothing. Fine-tuning the `vFactor` is critical to achieve optimal performance for your specific trading style and asset.

Common T3 Pitfalls

Conclusion

The Tillson T3 Moving Average is an innovative and highly effective indicator in Pine Script for TradingView. Its sophisticated design delivers an exceptionally smooth and responsive line, making it a valuable tool for accurate trend identification and dynamic signal generation. By understanding T3's unique calculation, intelligently tuning its parameters, and integrating it strategically within your comprehensive trading approach, you can leverage its power to gain a clearer and more precise perspective on market movements and enhance your trading decisions.