roc static method

List<double?> roc(
  1. List<TaBar> points, {
  2. int period = 12,
})

Implementation

static List<double?> roc(List<TaBar> points, {int period = 12}) {
  final n = points.length;
  final out = List<double?>.filled(n, null);
  for (int i = period; i < n; i++) {
    final past = points[i - period].close;
    if (past != 0) out[i] = (points[i].close - past) / past * 100;
  }
  return out;
}