TradingCharts

What it does

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.

How to use it

  • Open the charts and go to Indicators › My scripts › Shared with me (or search the Community library) and press Add to chart.
  • Open it in the ChartScript Editor to read the code; Create a copy makes your own editable version.

Version history

  • v2 — 21 Nov, 10:52 am · compiler 0.3.69
  • v1 — 21 Nov, 10:42 am · compiler 0.3.69

#library#volatility#atr#trend-efficiency#normalize#range#helpers