Returns true on any bar where the two series cross, in either direction.
ta.cross is ta.crossover(source1, source2) or ta.crossunder(source1, source2). It does not say which way the cross went.
To find the direction, compare the two series on the same bar, or call ta.crossover and ta.crossunder separately.
Syntax
ta.cross(source1: series int/float, source2: series int/float) -> series boolArguments
| Name | Type | Default | Description |
|---|---|---|---|
| source1 | series int/ | required | The first series. The call is true on the bar where it meets or passes source2. |
| source2 | series int/ | required | The second series or a level. |
Returns
series bool: true on a bar where the series crossed in either direction.
Remarks
- The first bar is always false, since there is no earlier value to compare.
Example
//@version=6
indicator("Close crosses SMA", overlay = true)
avg = ta.sma(close, 20)
plot(avg, "SMA 20", color = color.orange)
plotchar(ta.cross(close, avg), "Cross", "x", location.top, color.blue, size = size.tiny)See also
Runs on Sidechair