Skip to content
AlertaChartAlertaScript / docs
AlertaScript / alerta.ta.valuewhen
On this pageSignatureParametersReturnsExampleNotes

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 any

Parameters

NameTypeRequiredDefaultDescription
conditionseries boolYes—Condition to evaluate.
sourceseriesYes—Source series.
occurrenceintNot specified00 for most recent, 1 for previous, etc.

Returns

series any

Example

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.

AlertaScript

No results found.

Search by name, alias, or keyword.