The SMI Ergodic Indicator is the same as the True Strength Index (TSI) developed by
William Blau, except the SMI includes a signal line. The SMI uses double moving averages
of price minus previous price over 2 time frames. The signal line, which is an EMA of the
SMI, is plotted to help trigger trading signals. Adjustable guides are also given to fine
tune these signals. The user may change the input (close), method ( EMA ), period lengths
and guide values.
Below is converted to VAI Script from TradingView Script in this link https://www.tradingview.com/script/JskW6Z1C-SMI-Ergodic-Oscillator-Strategy/
//VAI SMIO Script
//fastPeriod = 4
//slowPeriod = 8
//SmthLen = 3
set TopBand = 0.5
set LowBand = -0.5
set xPrice = close
set xPrice1 = xPrice - ref(xPrice,1)
set xPrice2x = xPrice - ref(xPrice,1)
set xPrice2 = abs(xPrice2x)
set xSMA_Rx = ema(xPrice1,4)
set xSMA_aRx = ema(xPrice2, 4)
set xSMA_R = ema(xSMA_Rx,8)
set xSMA_aR = ema(xSMA_aRx,8)
set xSMIx = xSMA_R / xSMA_aR
//If xSMA_aR = 0, I set result value to Zero instead of infinite
set SMI = if(xSMA_aR=0,0, xSMIx )
set EMA_SMI = ema(SMI, 3)
set Below =Crossover( EMA_SMI, LowBand)
set Top = Crossover(EMA_SMI, TopBand)
Set x = Top or Below
//plot positions on Price area as X
//Plot as SELL to dispaly label on top
plot(x ,sell,orange,main)
//plot Below and Top on SMIO area
plot(Below ,buy,red,smio:EMA_SMI)
plot(Top ,sell,green,smio:EMA_SMI)
plotrange(TopBand ,LowBand ,any, smio)
//Plot the SMI Lines
plot(EMA_SMI, line, any, smio)
plot(SMI, line, any, smio)
