OPEN-SOURCE SCRIPT

Non-Lagging Indicator: EMA + TSI BY UTTAM PARAMANIK

//version=5
indicator("Non-Lagging Indicator: EMA + TSI", overlay=true)

// Parameters for the EMA
fastLength = input.int(9, title="Fast EMA Period", minval=1)
slowLength = input.int(21, title="Slow EMA Period", minval=1)

// Parameters for the TSI
tsiFastLength = input.int(13, title="TSI Fast Length", minval=1)
tsiSlowLength = input.int(25, title="TSI Slow Length", minval=1)
tsiSignalLength = input.int(7, title="TSI Signal Length", minval=1)

// EMA Calculation
fastEMA = ta.ema(close, fastLength)
slowEMA = ta.ema(close, slowLength)

// TSI Calculation
delta = close - close[1]
doubleSmoothDelta = ta.ema(ta.ema(delta, tsiFastLength), tsiSlowLength)
doubleSmoothAbsDelta = ta.ema(ta.ema(math.abs(delta), tsiFastLength), tsiSlowLength)
tsi = 100 * doubleSmoothDelta / doubleSmoothAbsDelta
tsiSignal = ta.ema(tsi, tsiSignalLength)

// Plot EMAs
plot(fastEMA, color=color.blue, title="Fast EMA")
plot(slowEMA, color=color.orange, title="Slow EMA")

// Plot TSI and Signal
plot(tsi, color=color.green, title="True Strength Indicator")
plot(tsiSignal, color=color.red, title="TSI Signal")

// Buy and Sell Conditions
buyCondition = ta.crossover(fastEMA, slowEMA) and ta.crossover(tsi, tsiSignal)
sellCondition = ta.crossunder(fastEMA, slowEMA) and ta.crossunder(tsi, tsiSignal)

// Plot Buy and Sell Signals
plotshape(buyCondition, color=color.green, style=shape.labelup, location=location.belowbar, text="BUY")
plotshape(sellCondition, color=color.red, style=shape.labeldown, location=location.abovebar, text="SELL")
Bands and ChannelsCandlestick analysisChart patterns

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer