Returns computes the percentage change between the current close
and the close period bars ago. Same shape as
ROC; the name reflects how the
quantity is used in performance / factor models.
Formula
returns[t] = (close[t] - close[t-N]) / close[t-N]Params
period- lookback in bars. Required.
Output
Single column named after your indicator (e.g. 5-bar return).
Usage
Building block. Examples:
- Momentum filter:
returns > 0over a 20-bar window as a long bias. - Drawdown gate: skip entries when
returns_60 < -0.05(recent 5% drawdown).
Returns vs ROC
Returns is in fractional units (0.05 = 5%); ROC is in percentage units (5 = 5%). Pick the one that matches the rest of your conditions and stick with it.
Pitfalls
Same as ROC - single-bar shocks dominate short windows and create noisy signals.
