hold
Keep the price from the last signal bar, such as the close at the last cross.
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.
| Name | Kind | Type | Default | Range | Description |
|---|---|---|---|---|---|
condition | Series | bool | - | - | When to take the value. |
source | Series | number | - | - | The series to hold. |
Output
| Name | Type |
|---|---|
value | number |
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
hold(ta.crossover(close, ma), close)up = ta.crossover(close, ta.sma(close, 20))
plot(hold(up, close), "Close at last cross")