Pine Script (TradingView)
This is a TradingView Pine Script example for this indicator. Paste it into the TradingView Pine Editor, add it to your chart, and adjust inputs for your market and timeframe.
//@version=6
indicator("TRIX Indicator", overlay=false)
length = input.int(15, "TRIX Length")
e1 = ta.ema(close, length)
e2 = ta.ema(e1, length)
e3 = ta.ema(e2, length)
trix = (e3 - e3[1]) / e3[1] * 100
sig = ta.ema(trix, 9)
longSignal = ta.crossover(trix, sig)
shortSignal = ta.crossunder(trix, sig)
plotshape(longSignal, style=shape.triangleup, location=location.bottom, color=color.green, size=size.small)
plotshape(shortSignal, style=shape.triangledown, location=location.top, color=color.red, size=size.small)
hline(0, "Zero", color=color.gray, linestyle=hline.style_dotted)
plot(trix, "TRIX", color=color.purple)
plot(sig, "Signal", color=color.orange)