getValue method

  1. @override
T getValue(
  1. int index
)
override

Value of the indicator for the given index.

Implementation

@override
T getValue(int index) {
  _growResultsForIndex(index);

  if (results[index].quote.isInfinite) {
    final T result = calculate(index);
    if (!result.quote.isInfinite) {
      results[index] = result;
    } else {
      // Avoid falling into a loop, if by any chance an indicator calculates a value as `double.infinity`.
      results[index] = createResult(quote: double.nan, index: index);
    }
  }

  if (index > lastResultIndex) {
    lastResultIndex = index;
  }

  return results[index];
}