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
Biblioteka Pine
W zgodzie z duchem TradingView autor opublikował ten kod Pine jako bibliotekę open-source, aby inni programiści Pine z naszej społeczności mogli go ponownie wykorzystać. Ukłony dla autora. Można korzystać z tej biblioteki prywatnie lub w innych publikacjach open-source, jednak ponowne wykorzystanie tego kodu w publikacjach podlega 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.
Biblioteka Pine
W zgodzie z duchem TradingView autor opublikował ten kod Pine jako bibliotekę open-source, aby inni programiści Pine z naszej społeczności mogli go ponownie wykorzystać. Ukłony dla autora. Można korzystać z tej biblioteki prywatnie lub w innych publikacjach open-source, jednak ponowne wykorzystanie tego kodu w publikacjach podlega 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.