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
Bibliothèque Pine
Dans l'esprit TradingView, l'auteur a publié ce code Pine sous forme de bibliothèque open source afin que d'autres programmeurs Pine de notre communauté puissent le réutiliser. Bravo à l'auteur! Vous pouvez utiliser cette bibliothèque à titre privé ou dans d'autres publications open source, mais la réutilisation de ce code dans des publications est régie par 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.
Bibliothèque Pine
Dans l'esprit TradingView, l'auteur a publié ce code Pine sous forme de bibliothèque open source afin que d'autres programmeurs Pine de notre communauté puissent le réutiliser. Bravo à l'auteur! Vous pouvez utiliser cette bibliothèque à titre privé ou dans d'autres publications open source, mais la réutilisation de ce code dans des publications est régie par 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.