Master this ultra-responsive and virtually lag-free moving average in TradingView's Pinescript for razor-sharp trend identification and powerful reversal signals.
The Triple Exponential Moving Average (TEMA), introduced by Patrick Mulloy, is an advanced moving average that builds upon the concept of DEMA to reduce lag even further. It's designed to provide an even faster and smoother response to price changes than traditional EMAs and even DEMAs, aiming to get closer to the current price without sacrificing too much smoothing.
In Pinescript, TEMA is a powerful tool for traders who demand highly responsive trend-following indicators for quick market analysis and agile trade execution, especially in fast-moving markets.
The calculation of TEMA involves three EMAs of the same specified `length`:
//@version=5
indicator("My Triple EMA Indicator", overlay=true)
// Input for TEMA length
length = input.int(20, title="TEMA Length", minval=1)
// Calculate TEMA using the built-in function
temaValue = ta.tema(close, length)
// Plot the TEMA line
plot(temaValue, title="TEMA", color=color.blue, linewidth=2)
TEMA is celebrated for its ability to reduce lag significantly, making it one of the most responsive moving averages available.
//@version=5
strategy("TEMA Trend Color Strategy", overlay=true)
// Input for TEMA length
length = input.int(20, title="TEMA Length", minval=1)
// Calculate TEMA
temaValue = ta.tema(close, length)
// Determine TEMA color based on its direction
temaColor = temaValue > temaValue[1] ? color.green : color.red
// Plot the TEMA line with dynamic color
plot(temaValue, title="TEMA", color=temaColor, linewidth=2)
// Example entry logic: buy when TEMA turns green, sell when TEMA turns red
longCondition = temaValue > temaValue[1] and temaValue[1] <= temaValue[2] // TEMA turns up
shortCondition = temaValue < temaValue[1] and temaValue[1] >= temaValue[2] // TEMA turns down
if (longCondition)
strategy.entry("Long", strategy.long)
if (shortCondition)
strategy.entry("Short", strategy.short)
//@version=5
strategy("TEMA Crossover Strategy", overlay=true)
// Inputs for TEMA lengths
fastTemaLength = input.int(10, title="Fast TEMA Length", minval=1)
slowTemaLength = input.int(30, title="Slow TEMA Length", minval=1)
// Calculate TEMAs
fastTema = ta.tema(close, fastTemaLength)
slowTema = ta.tema(close, slowTemaLength)
// Plot the TEMAs
plot(fastTema, title="Fast TEMA", color=color.blue, linewidth=2)
plot(slowTema, title="Slow TEMA", color=color.orange, linewidth=2)
// Crossover conditions (Fast TEMA crossing Slow TEMA)
longCondition = ta.crossover(fastTema, slowTema)
shortCondition = ta.crossunder(fastTema, slowTema)
// Strategy entries/exits
if (longCondition)
strategy.entry("Long", strategy.long)
if (shortCondition)
strategy.entry("Short", strategy.short)
//@version=5
indicator("TEMA Support/Resistance", overlay=true)
length = input.int(20, title="TEMA Length", minval=1)
temaValue = ta.tema(close, length)
plot(temaValue, title="TEMA", color=color.blue, linewidth=2)
// Highlight potential support/resistance interactions (conceptual - adjust thresholds)
// These conditions check for price being very close to TEMA, implying a touch or test
isSupportTouch = close > temaValue * 0.995 and close < temaValue * 1.005 and temaValue[1] < close[1] // Price touches TEMA from below or just above
isResistanceTouch = close < temaValue * 1.005 and close > temaValue * 0.995 and temaValue[1] > close[1] // Price touches TEMA from above or just below
plotshape(isSupportTouch, title="Potential Support", location=location.belowbar, color=color.green, style=shape.circle, size=size.tiny)
plotshape(isResistanceTouch, title="Potential Resistance", location=location.abovebar, color=color.red, style=shape.circle, size=size.tiny)
To get the most from the Triple Exponential Moving Average in Pinescript:
TEMA is designed for speed. This means it might still produce more signals than a heavily smoothed average. Always confirm signals to avoid overtrading.
The Triple Exponential Moving Average (TEMA) represents a significant leap forward in reducing lag in moving averages within Pinescript for TradingView. Its sophisticated calculation provides an exceptionally responsive and smooth line, making it ideal for traders who prioritize timely trend identification and dynamic signal generation. By understanding TEMA's unique characteristics, intelligently tuning its parameters, and integrating it strategically with other analytical tools, you can leverage its power to gain a sharper perspective on market movements and enhance your trading decisions.
Get a high-performance Pinescript analysis tool for actionable market insights, designed for traders on the move.
This strategy runs in live mode on TradingView, helping you identify potential opportunities.
Get Pinescript Strategy