PINE LIBRARY
MRScoringLibrary

Library "MRScoringLibrary"
Mean-reversion graduated scoring: z-score any indicator into -3 to +3 integer scale.
mrScore(src, lookback, alreadyZ, invert)
Converts any continuous indicator value into a graduated
mean-reversion score from -3 (deep overbought) to +3 (deep oversold).
Parameters:
src (float): Raw indicator value (or z-score if alreadyZ=true)
lookback (int): Rolling lookback for z-score calc (ignored if alreadyZ=true)
alreadyZ (bool): True if src is already a z-score — skips internal z-scoring
invert (bool): True if HIGH indicator value = oversold (flips mapping)
Returns: Integer score: +3 to -3
zScore(src, lookback)
Returns the raw z-score without mapping to graduated scale.
Useful for plotting or custom threshold logic.
Parameters:
src (float): Raw indicator value
lookback (int): Rolling lookback period
Returns: Float z-score
mrScoreCustom(src, lookback, alreadyZ, invert, sd1, sd2, sd3)
Same as mrScore but with configurable SD band edges.
For indicators where standard 1/2/3 SD bands don't fit well
(e.g., an indicator only becomes useful at 1.5 SD).
Parameters:
src (float): Raw indicator value (or z-score if alreadyZ=true)
lookback (int): Rolling lookback for z-score calc
alreadyZ (bool): True if src is already a z-score
invert (bool): True if HIGH value = oversold
sd1 (float): Inner band threshold (default would be 1.0)
sd2 (float): Middle band threshold (default would be 2.0)
sd3 (float): Outer band threshold (default would be 3.0)
Returns: Integer score: +3 to -3
Mean-reversion graduated scoring: z-score any indicator into -3 to +3 integer scale.
mrScore(src, lookback, alreadyZ, invert)
Converts any continuous indicator value into a graduated
mean-reversion score from -3 (deep overbought) to +3 (deep oversold).
Parameters:
src (float): Raw indicator value (or z-score if alreadyZ=true)
lookback (int): Rolling lookback for z-score calc (ignored if alreadyZ=true)
alreadyZ (bool): True if src is already a z-score — skips internal z-scoring
invert (bool): True if HIGH indicator value = oversold (flips mapping)
Returns: Integer score: +3 to -3
zScore(src, lookback)
Returns the raw z-score without mapping to graduated scale.
Useful for plotting or custom threshold logic.
Parameters:
src (float): Raw indicator value
lookback (int): Rolling lookback period
Returns: Float z-score
mrScoreCustom(src, lookback, alreadyZ, invert, sd1, sd2, sd3)
Same as mrScore but with configurable SD band edges.
For indicators where standard 1/2/3 SD bands don't fit well
(e.g., an indicator only becomes useful at 1.5 SD).
Parameters:
src (float): Raw indicator value (or z-score if alreadyZ=true)
lookback (int): Rolling lookback for z-score calc
alreadyZ (bool): True if src is already a z-score
invert (bool): True if HIGH value = oversold
sd1 (float): Inner band threshold (default would be 1.0)
sd2 (float): Middle band threshold (default would be 2.0)
sd3 (float): Outer band threshold (default would be 3.0)
Returns: Integer score: +3 to -3
ספריית Pine
ברוח האמיתית של TradingView, המחבר לפרסם את הקוד של Pine הזה כספרייה בקוד פתוח, כך שמתכנתים אחרים בקהילתנו יעשו שימוש חוזר. כל הכבוד למחבר! ניתן להשתמש בספרייה הזו באופן פרטי או בומים בקוד פתוח, אך השימוש בחוזר בקוד הזה בפרסומים כפוף ל-כללי הבית.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.
ספריית Pine
ברוח האמיתית של TradingView, המחבר לפרסם את הקוד של Pine הזה כספרייה בקוד פתוח, כך שמתכנתים אחרים בקהילתנו יעשו שימוש חוזר. כל הכבוד למחבר! ניתן להשתמש בספרייה הזו באופן פרטי או בומים בקוד פתוח, אך השימוש בחוזר בקוד הזה בפרסומים כפוף ל-כללי הבית.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.