PriceStats
Simple price-statistics helpers for trend, volatility and position in range. Each function works on every bar and returns one number. normalize(src, len): where src sits in its len-bar low-high range, scaled 0 to 100. atrPct(len): ATR as a percentage of close, so volatility can be compared across stocks. trendEfficiency(src, len): net move divided by total path travelled, from 0 (choppy) to 1 (clean trend). rangePos(len): where the close sits inside the len-bar high-low range, 0 to 100. How to use: import g_T9PHE3Z1/PriceStats/2 as ps eff = ps.trendEfficiency(close, 20) vol = ps.atrPct(14) pos = ps.rangePos(50) Call each function once per bar at the top level of your script (not inside if or for). Values were checked against hand-written versions of the same formulas.