OPEN-SOURCE SCRIPT
Sigma Distance From Moving Average

This is an indicator I've wanted to build for a while. The advent of AI and vibe coding circa 2026 made it feasible.
This is an iteration of the previous indicator I shared - % distance from moving average - which, as explained in the self-described title, displays the % distance an asset's current price sits above or below whatever moving average you enter on whatever timeframe you choose.
This new version expresses this distance as a z score rather than a %. The high level is we're going one level deeper - knowing how far an asset's current price is from its moving average is interesting, but what's more interesting is knowing how often this asset reaches this level above/below its moving average. Some assets are volatile, others less so. For something that moves a lot, being 15-20% above its 50 day moving average isn't all that rare. For something that doesn't move a lot, that might be a once in a ten thousand occurrence - we want to be able to quantify this. That's what this one does.
Enjoy!
This is an iteration of the previous indicator I shared - % distance from moving average - which, as explained in the self-described title, displays the % distance an asset's current price sits above or below whatever moving average you enter on whatever timeframe you choose.
This new version expresses this distance as a z score rather than a %. The high level is we're going one level deeper - knowing how far an asset's current price is from its moving average is interesting, but what's more interesting is knowing how often this asset reaches this level above/below its moving average. Some assets are volatile, others less so. For something that moves a lot, being 15-20% above its 50 day moving average isn't all that rare. For something that doesn't move a lot, that might be a once in a ten thousand occurrence - we want to be able to quantify this. That's what this one does.
Enjoy!
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.