Looking back: prev

prev(x) is x on the bar before; prev(x, n) is n bars back.

For AI tools: this page as Markdown · the whole language in one file

  • prev(x) is x one bar ago, prev(x, 5) five bars ago (Pine's x[1] and x[5]).
  • The count must be fixed: a number or a setting, not something that changes from bar to bar.
  • Before there is an earlier bar the value is empty; fallback(prev(x), y) fills it.
1rose = close > prev(close)2momentum = close - prev(close, 10)3plot(momentum, "Momentum")4mark(rose and prev(rose) and prev(rose, 2), "3", where = below)

See also: prev, Values that carry over: starts, fallback