value_when
Syntax Format
value_when(condition, series, occurrence)
Overview
The value_when
function provides the series value when the given condition was met (= true) on the n-number most recent occurrence. This function can be used in scripts, when getting a certain historical data, which answers certain criteria, for further analysis.
Parameters
Parameter | Type | Purpose |
---|---|---|
condition | boolean or series[boolean] | Given condition |
series | series | Series, to which the condition will be applied |
occurrence | integer | The occurrence of the condition |
Returns: series
.
Example
condition = close > open
uptrend = value_when(condition, close, 4)