Lipi Reference Lipi

Functions

talib.valuewhen()

indicator("Value When Example", overlay=true) smaFast = talib.sma(close, 9) smaSlow = talib.sma(close, 21) crossoverCondition = talib.crossover(smaFast, smaSlow) lastCrossoverClose = talib.valuewhen(crossoverCondition, close, 0) plot(lastCrossoverClose, color=color.red, title="Last Crossover Close")

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


          Returns the value of the source series on the bar where the condition was true on the nth most recent occurrence.