strategy · on price · open source

Triple EMA (TEMA 9) crossover strategy

Triple EMA crossover: a low-lag TEMA(9) crossing a 21 EMA. Buy the bullish cross, exit the bearish cross. Plain-English rules, code and a costed backtest. Deepwick Script runs a subset of Pine Script.

v1Updated 3 Oct 2026▲ 0 users
Running…
Loading chart…

What the Triple EMA (TEMA) Crossover strategy does

Low-lag Triple EMA crossover: TEMA removes the lag of the underlying three-stage EMA cascade. Faster turns than EMA or SMA at the same length.

  • Best as the fast leg of a crossover pair against a slower EMA.
  • Lower Fast for tighter entries; raise Slow to anchor the trend filter.
  • Pair with an ADX > 20 filter to skip chop.

Entry and exit rules

    Language reference: Deepwick Script.

    Default inputs

    InputDefaultMinMax
    Fast TEMA Length9550
    Slow EMA Length2120200
    Stop Loss %20.510
    Take Profit %6020

    How Deepwick fills this strategy

    • Market orders fill at the next bar's open.
    • Stops and limits follow the bar's path: open → nearer extreme → farther extreme → close.
    • Gaps fill at the open.
    • Commission is charged on every fill, and slippage applies to market and stop fills, as set in strategy().

    More on how backtests work

    Source code

    Deepwick Script, a subset of Pine Script · read-only

    //@version=6
    strategy("Triple EMA Crossover", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=10, commission_type=strategy.commission.percent, commission_value=0.05)
    fastLen = input.int(9, "Fast TEMA Length", minval=5, maxval=50, step=1)
    slowLen = input.int(21, "Slow EMA Length", minval=20, maxval=200, step=1)
    stopPct = input.float(2, "Stop Loss %", minval=0.5, maxval=10, step=0.1)
    tpPct = input.float(6, "Take Profit %", minval=0, maxval=20, step=0.1)
    colorAccent = input.color("color.fuchsia", "Color  Accent")
    colorLine = input.color("color.blue", "Color  Line")
    colorUp = input.color("color.green", "Color  Up")
    colorDown = input.color("color.red", "Color  Down")
    e1 = ta.ema(close, fastLen)
    e2 = ta.ema(e1, fastLen)
    e3 = ta.ema(e2, fastLen)
    tema = 3 * e1 - 3 * e2 + e3
    slowE = ta.ema(close, slowLen)
    longSignal = strategy.position_size == 0 and ta.crossover(tema, slowE)
    exitSignal = strategy.position_size > 0 and ta.crossunder(tema, slowE)
    if longSignal
        strategy.entry("Long", strategy.long)
    if strategy.position_size > 0
        strategy.exit("Risk", stop=stopPct > 0 ? strategy.position_avg_price * (1 - stopPct / 100) : na, limit=tpPct > 0 ? strategy.position_avg_price * (1 + tpPct / 100) : na)
    if exitSignal
        strategy.close("Long", comment="TEMA cross down")
    p_TEMA = plot(tema, "TEMA", color=colorAccent, linewidth=2)
    p_Slow_EMA = plot(slowE, "Slow EMA", color=colorLine, linewidth=2)
    plotshape(longSignal, "Long", style=shape.triangleup, location=location.belowbar, color=colorUp, text="L")
    plotshape(exitSignal, "Exit", style=shape.triangledown, location=location.abovebar, color=colorDown, text="X")
    alertcondition(longSignal, "TEMA long entry", "TEMA crossed above slow EMA")
    alertcondition(exitSignal, "TEMA exit", "TEMA crossed below slow EMA")
    

    Run it in Deepwick

    1. Open a chart of any crypto pair or CFD.
    2. Click “Scripts” and add this strategy.
    3. Press Run and read the trades in the Strategy Tester.
    Start free

    FAQ

    Is this the '3 EMA strategy'?

    Not exactly. The popular '3 EMA strategy' uses three separate EMAs as a ribbon. This script uses one triple-smoothed EMA (TEMA) against a single 21 EMA.

    What does TEMA change compared with a plain EMA cross?

    TEMA removes much of the lag, so crosses come earlier. Compare this page's table with the 9/21 EMA crossover page on the same symbol and costs.

    Can I make it a three-EMA ribbon?

    Yes: add a third ta.ema() and require the fast > middle > slow order for entries. Rerun the backtest with the same costs to compare.

    Comments

    No comments yet.

    Sign in to comment.