Docs

ta.clip

Hold a series between a lower and an upper bound.

itm
ta.clip(source, lo, hi)

min(max(source, lo), hi): the source held inside two bounds, which may themselves be series. The upper clamp is applied last, so an inverted pair (lo above hi) gives hi rather than an error. The bounds are numbers you choose. ta.winsorize takes them from the data.

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
sourceSeriesnumber--The series to bound.
loSeriesnumber--The lower bound.
hiSeriesnumber--The upper bound.

Output

NameType
valuenumber

Warm-up and missing values

Warm-up
None.
Missing values
na when the source or either bound is na. Pointwise: no window, no warm-up.

Example

itm
ta.clip(ta.ret(close), -0.1, 0.1)
itm
plot(ta.clip(ta.ret(close), -0.1, 0.1), "Clipped return")