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.
talib.valuewhen(series bool condition, series float source, simple int occurrence) → series float| Parameter | Type | Required | Description |
|---|---|---|---|
condition | series bool | yes | The test that selects which bar to read from. |
source | series float | yes | The series whose value is read. |
occurrence | simple int | yes | Which past occurrence to use. A simple int, so it cannot change from bar to bar. |
Returns series float — A series float: the value taken from the selected bar.
indicator("Close at the start of the session")
plot(talib.valuewhen(session.isfirst, close, 1))See also talib.alma · talib.atr · talib.barssince
Part of the function index.
Ready to put this into practice?
Try GoCharting Premium
Unlock advanced orderflow, market profile, options desk, and real-time data — everything you just read about, live in your charts.