highest_bars_ago

Bars ago when highest value occurred

highest_bars_ago(source, period)

Parameters

Highest Bars Ago - highest_bars_ago(source, period)

Returns bars ago when highest value occurred in lookback window.

  • source (field): Data series
  • period (int): Lookback period

Formula


Returns offset of maximum value:
  0 = highest at current bar
  N = highest N bars ago

Examples


// highest close right now (fresh 20-bar high)
highest_bars_ago(close, 20) == 0;

// highest occurred more than 10 bars ago (weakening)
highest_bars_ago(high, 50) > 10;

// highest within last 5 bars (recent strength)
highest_bars_ago(close, 20) < 5;

Returns

Non-negative integer (0 to period-1)

See Also