Lipi Reference Lipi

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 test that selects which bar to read from.
source required series float The series whose value is read.
occurrence required simple int Which past occurrence to use. A simple int, so it cannot change from bar to bar.

Return Type

series float

Example


          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)