Core / Reference
alerta.ta.valuewhen
TradingView-compatible spelling: ta.valuewhen, runs without warnings
Returns the value of `source` when `condition` was last true.
alerta.ta.valuewhen(condition, source, occurrence) → series anyParameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
condition | series bool | Yes | — | Condition to evaluate. |
source | series | Yes | — | Source series. |
occurrence | int | Not specified | 0 | 0 for most recent, 1 for previous, etc. |
Returns
series anyExample
alerta.ta.valuewhen
ph = pivothigh(high, 5, 5)lastHigh = valuewhen(ph !== null, high, 0)plot(lastHigh)Notes
- Until the condition has been true `occurrence + 1` times the result is `na`. Used as a price level for a box or line, keep `na` rather than replacing it with 0: a level of 0 stretches the drawing down to zero.
Names and aliases
Guides and navigation are localized. Built-in reference descriptions and code examples are maintained in English.