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!
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.