Functions
talib.valuewhen()
Reads `source` from the bar on which `condition` was true, going back as far as `occurrence` says. `occurrence` is a simple int, not a series, so it is fixed for the run of the script and cannot be varied bar by bar.
Syntax
talib.valuewhen(series bool condition, series float source, simple int occurrence) → series float
Arguments
condition required series bool The condition to search for. source required series float The value to be returned from the bar where the condition is met. occurrence required simple int The occurrence of the condition. The numbering starts from 0 and goes back in time, so '0' is the most recent occurrence of condition, '1' is the second most recent and so forth. Must be an integer >= 0. Return Type
series float Example
//@lipi=2
indicator("talib.valuewhen Example", overlay=true)
cond = talib.crossover(close, talib.sma(close, 20))
v = talib.valuewhen(cond, close, 0)
plot(v, title="valuewhen", color=color.orange)