valuewhen

forge.tafunctionSince Forge API 1
Signaturepython
forge.ta.valuewhen(condition: ArrayLike,source: ArrayLike,occurrence: int = 0) -> np.ndarray

The source on the bar where the condition last held, or the occurrence-th time before.

Parameters

NameTypeDefault
conditionArrayLike
sourceArrayLike
occurrenceint0

occurrence 0 is the most recent bar where the condition held, at or before the current bar. There is no value until the condition has held occurrence + 1 times, or when the source is missing on that bar. Example: ta.valuewhen(ta.crossover(fast, slow), high).