indicator · on price · open source
Ehlers Instantaneous Trendline
Running…
Loading chart…
About
Ehlers Instantaneous Trendline (ITrend) — a low-lag trend line from a 3-pole IIR filter; smoother than an EMA at the same length but adapts to volatility through alpha.
- Buy when price crosses above the trigger (the 2-bar-prior price projection).
- The line flips direction faster than a 50-EMA.
Source code
//@version=5
indicator("Ehlers Instantaneous Trendline", overlay=true)
alpha = input.float(0.07, "Alpha", minval=0.01, maxval=0.5, step=0.01)
src = (high + low) / 2
price = (src + 2 * src[1] + 2 * src[2] + src[3]) / 6
var float iTrend = price
iTrend := (3 * alpha - 3 * alpha * alpha) * price + (3 * alpha * alpha - 6 * alpha * alpha * alpha + 3 * alpha * alpha * alpha) * price[1] + (3 * alpha * alpha * alpha) * price[2] + nz(iTrend[1], price)
trigger = 2 * price - price[2]
p_ITrend = plot(iTrend, "ITrend", color=color.blue, linewidth=2)
p_Trigger = plot(trigger, "Trigger", color=color.red)
alertcondition(ta.crossover(close, iTrend), "Above ITrend", "Close crossed above the instantaneous trendline")
alertcondition(ta.crossunder(close, iTrend), "Below ITrend", "Close crossed below the instantaneous trendline")
No comments yet.
Sign in to comment.