Skip to main content

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​

ParameterTypePurpose
conditionboolean or series[boolean]Given condition
seriesseriesSeries, to which the condition will be applied
occurrenceintegerThe occurrence of the condition

Returns: series.

Example​

condition = close > open

uptrend = value_when(condition, close, 4)