Docs

hold

Keep the price from the last signal bar, such as the close at the last cross.

itm
hold(condition, source)

The value of the source on the most recent bar where the condition was true. It is the same as ta.valuewhen with an occurrence of 0. The value stays in place until the condition is true again.

Parameters

A series parameter takes a value on every bar. A constant parameter must be known before the first bar, such as a number or an input.

NameKindTypeDefaultRangeDescription
conditionSeriesbool--When to take the value.
sourceSeriesnumber--The series to hold.

Output

NameType
valuenumber

Warm-up and missing values

Warm-up
1 bar.
Missing values
na until the condition has been true once. An na source on a bar where the condition is true is held as na.

Example

itm
hold(ta.crossover(close, ma), close)
itm
up = ta.crossover(close, ta.sma(close, 20))
plot(hold(up, close), "Close at last cross")