TradingView indicator guides

SMI Ergodic Indicator: TSI Scale and Signal-Line Logic

This example plots ta.tsi(close, 5, 20) and its five-bar EMA signal line. The copied script uses the raw ratio scale, from −1 to +1 when defined, rather than multiplying by 100. It is a two-line momentum reference with fixed parameters, not an automated trading strategy.

Inspect the Pine Script

The formula and its units

TradingView’s SMI Ergodic definition divides double-smoothed signed price changes by double-smoothed absolute changes, then adds an EMA signal. The ta.tsi reference specifies a result in the range −1 to +1. This code performs no additional scaling.

Let delta = close − close[1]. Apply EMA smoothing with the two chosen lengths to delta and to abs(delta), and divide the resulting signed series by the absolute series. Signal = EMA(ratio, signalLength). Some TSI presentations multiply both lines by 100; a raw value of 0.25 then displays as 25. Neither value means a 25% price return or a 25% probability of a successful trade.

With compatible initialization, nonnegative EMA weights and a positive denominator, the absolute smoothed numerator cannot exceed the smoothed absolute changes. A zero denominator leaves the ratio undefined. The snippet delegates initialization and missing-data behavior to ta.tsi; it does not supply its own zero-denominator fallback.

Regular Stochastic Momentum Index instead measures smoothed distance from a high/low range midpoint. These similarly named indicators are not interchangeable. Also, a signal line is not exclusive to SMII: TradingView’s TSI guide discusses signal-line crossings too.

Recompute a short synthetic sequence

For transparent arithmetic, use length 3 for both smoothing stages and the signal, making each EMA update half new value plus half previous value. Assume all signed and absolute EMA states begin at 1 and the signal begins at 1. These are explicit initial conditions for an illustration, not a claim about the built-in function’s first chart bar.

Hypothetical price-change sequence; no market data or trades
ChangeDouble EMA of changeDouble EMA of absolute changeRatioSignal
−10.510.50.75
−10100.375
+20.3751.250.30.3375
00.37510.3750.35625

The first negative change leaves the ratio positive. On the final unchanged close, the ratio rises and moves above its signal because the denominator falls while the numerator stays fixed. A signal crossing therefore does not establish that the current price change accelerated or even that price moved upward.

For a compatible history of changes with only one positive sign, signed and absolute smoothing can match and produce +1. That endpoint is not inherently rare. Multiplying every price by the same positive factor scales numerator and denominator together, preserving the ratio. It does not preserve market liquidity, execution costs or future risk.

Separate line position, crossings and orders

A positive ratio means the smoothed signed numerator is positive when the denominator is valid. A ratio above its signal describes its relationship to a smoothed version of itself. The ratio can be negative while above the signal, or positive while below it. These are different conditions.

To define an upward crossing, require the current ratio to exceed its signal and the previous ratio to be at or below the previous signal. Remaining above for several bars is a state, not a new crossing on every bar. The supplied code plots the lines only: it does not detect crossings, label divergences, declare alert conditions or place orders.

Both lines can change on an open bar because close changes. If adding alerts, specify whether they require a confirmed bar, then distinguish alert timing from a simulated or actual fill. If adding divergence logic, define pivot confirmation and do not backdate its availability to the pivot bar.

Parameter changes need a defined comparison

The copied function call is longLength 20, shortLength 5 and signalLength 5. There are no input declarations in this snippet, so these numbers must be edited in source. Pineify’s separate Visual Editor configuration exposes those three parameters; it does not make this fixed snippet’s settings adjustable automatically.

Changing signalLength changes the orange line without changing the underlying blue ratio. Setting signalLength to 1 makes the signal equal to the ratio on valid observations, eliminating strict line-to-line crossings. Larger values do not guarantee a fixed percentage reduction in crossings or improved win rate.

EMA periods are decay parameters, not hard windows containing only that many bars. Adding 20 + 5 + 5 is not a proof of a 30-bar delay, and 20 five-minute bars do not describe the full historical support of EMA20. Initialization, data gaps and the ratio’s denominator matter. Compare equal histories, session settings and source data rather than declaring one market or timeframe universally best.

  1. Match raw versus multiplied-by-100 scales before comparing implementations or thresholds.
  2. Inspect initial, flat-price and one-sided-change sequences before testing market data.
  3. For a strategy, specify confirmation, entry and exit rules, costs, sizing and a separate evaluation period.
  4. Report measured results with reproducible data; no performance percentages are established by this example.

Pine Script v6: implementation and limits

The complete example below preserves the direct ta.tsi call and EMA signal. It has no input declarations, confirmation gate, alerts, divergence detection or strategy orders.

Pine Script v6
//@version=6
indicator(title="SMI Ergodic Indicator", overlay=false, max_labels_count=500)

// SMII calculation using TSI with ergodic double-smoothing
p_ta_smii(simple int longLength, simple int shortLength, simple int signalLength) =>
    erg = ta.tsi(close, shortLength, longLength)
    sig = ta.ema(erg, signalLength)
    [erg, sig]

// Default parameters: longLength=20, shortLength=5, signalLength=5
[p_ind_1_erg, p_ind_1_signal] = p_ta_smii(20, 5, 5)

plot(p_ind_1_erg, "SMII", color=color.new(#2962FF, 0), linewidth=1)
plot(p_ind_1_signal, "Signal", color=color.new(#FF6D00, 0), linewidth=1)
hline(0, "Zero Line", color=#787B86)

Specify a checkable adaptation in Pineify

Ask the Pine Script AI Coding Agent for explicit parameter inputs, documented scale and optional confirmed-bar alerts. Verify the resulting source and compare values in TradingView before defining a strategy. The Visual Editor and AI Coding Agent are separate workflows; available access depends on the current product plan.

Open Pine Script AI Coding Agent

Educational indicator analysis. No measured trading performance is established here. Syntax validation does not prove formula equivalence, execution assumptions or profitability.

Implementation questions

No. ta.tsi returns a ratio on the −1 to +1 scale when defined, and the snippet does not multiply by 100. Rescale both the ratio and signal consistently when comparing another implementation.

Yes. In the synthetic final row the smoothed numerator stays at 0.375 while its denominator falls from 1.25 to 1, so the ratio rises from 0.3 to 0.375.

No. This script smooths signed and absolute price changes. Regular SMI smooths the distance from a high/low range midpoint and the range width.

No. It plots two fixed-parameter lines and a zero reference. Inputs, confirmed-bar alerts and strategy orders would require explicit additions.

No. It creates another comparison series. A complete strategy still needs reproducible execution rules and evaluation, and losses remain possible.