MRTestingLibrary

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
Perpustakaan Pine
Dalam semangat TradingView sebenar, penulis telah menerbitkan kod Pine ini sebagai perpustakaan sumber terbuka supaya pengaturcara Pine lain dari komuniti kami boleh menggunakannya semula. Sorakan kepada penulis! Anda boleh menggunakan perpustakaan ini secara peribadi atau dalam penerbitan sumber terbuka lain, tetapi penggunaan semula kod ini dalam penerbitan adalah dikawal selia oleh Peraturan Dalaman.
Penafian
Perpustakaan Pine
Dalam semangat TradingView sebenar, penulis telah menerbitkan kod Pine ini sebagai perpustakaan sumber terbuka supaya pengaturcara Pine lain dari komuniti kami boleh menggunakannya semula. Sorakan kepada penulis! Anda boleh menggunakan perpustakaan ini secara peribadi atau dalam penerbitan sumber terbuka lain, tetapi penggunaan semula kod ini dalam penerbitan adalah dikawal selia oleh Peraturan Dalaman.