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!
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.