OPEN-SOURCE SCRIPT
RSI Smoothing: Wilder vs EMA

Two RSI(14) lines built from the same up and down moves, smoothed two ways, so you can see where they disagree.
Blue is Wilder's RSI, the one the built-in RSI and ta.rsi() use. It averages with a weight of 1/14 on the newest bar. Orange uses a conventional EMA, which puts 2/15 on the newest bar, nearly twice as much. Wilder's 14 behaves like an EMA of about 27, and its average lag is 13 bars against 6.5 for the EMA version.
Markers show threshold crosses: circles for Wilder, triangles for the EMA version, at the bottom for crosses below the lower line and at the top for crosses above the upper line. Where a circle and a triangle don't line up, a rule written as "RSI(14) crosses 30" fires on different bars depending on which smoothing your platform or library uses.
The table counts crosses over the loaded bars for each version, how many landed on the same bar, and each smoother's average lag. The same counts are in the Data Window.
How big the gap can be: on BITFINEX:BTCUSD daily closes from 2021-10-31 to 2026-10-03, Wilder's RSI(14) crossed below 30 on 22 days and the EMA version on 55, and they crossed on the same bar 3 times. That figure comes from a separate offline count; the table on your chart counts whatever bars are loaded.
Use it to check which smoothing a rule was tested with before trusting a result that moved between platforms, and write the smoothing next to the length when you record a rule: RSI(14, Wilder) is a specification, RSI(14) is a label.
Inputs: length, source, lower and upper thresholds, and a switch for the table.
Notes: computed from the chart's own bars only, with no request.security and no other timeframe, so there is no lookahead to get wrong. Like any RSI, the value on the bar that is still forming moves until it closes, and the EMA version's first bars differ from Wilder's while both averages warm up. It compares two calculations; it does not tell you when to trade, and nothing here is investment advice.
Blue is Wilder's RSI, the one the built-in RSI and ta.rsi() use. It averages with a weight of 1/14 on the newest bar. Orange uses a conventional EMA, which puts 2/15 on the newest bar, nearly twice as much. Wilder's 14 behaves like an EMA of about 27, and its average lag is 13 bars against 6.5 for the EMA version.
Markers show threshold crosses: circles for Wilder, triangles for the EMA version, at the bottom for crosses below the lower line and at the top for crosses above the upper line. Where a circle and a triangle don't line up, a rule written as "RSI(14) crosses 30" fires on different bars depending on which smoothing your platform or library uses.
The table counts crosses over the loaded bars for each version, how many landed on the same bar, and each smoother's average lag. The same counts are in the Data Window.
How big the gap can be: on BITFINEX:BTCUSD daily closes from 2021-10-31 to 2026-10-03, Wilder's RSI(14) crossed below 30 on 22 days and the EMA version on 55, and they crossed on the same bar 3 times. That figure comes from a separate offline count; the table on your chart counts whatever bars are loaded.
Use it to check which smoothing a rule was tested with before trusting a result that moved between platforms, and write the smoothing next to the length when you record a rule: RSI(14, Wilder) is a specification, RSI(14) is a label.
Inputs: length, source, lower and upper thresholds, and a switch for the table.
Notes: computed from the chart's own bars only, with no request.security and no other timeframe, so there is no lookahead to get wrong. Like any RSI, the value on the bar that is still forming moves until it closes, and the EMA version's first bars differ from Wilder's while both averages warm up. It compares two calculations; it does not tell you when to trade, and nothing here is investment advice.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Ten checks before you believe a backtest — the free one-page checklist: quanticator.app/tv · No-repaint HTF Template Pack (Pine v6, $39): jordonharrell.gumroad.com/l/norepaint-htf-template-pack
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Ten checks before you believe a backtest — the free one-page checklist: quanticator.app/tv · No-repaint HTF Template Pack (Pine v6, $39): jordonharrell.gumroad.com/l/norepaint-htf-template-pack
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.