Returns true on the bar where source1 moves from at or below source2 to above it.
ta.crossover is true when source1 > source2 on this bar and source1 <= source2 on the previous bar. Either argument can be a series or a plain number such as 70.
It is true for one bar per cross. On the first bar there is no previous value, and any na makes it false.
Syntax
ta.crossover(source1: series int/float, source2: series int/float) -> series boolArguments
| Name | Type | Default | Description |
|---|---|---|---|
| source1 | series int/ | required | The series expected to move up through the other. |
| source2 | series int/ | required | The series or level being crossed. |
Returns
series bool: true on the crossing bar, otherwise false.
Remarks
- Touching without passing through counts: when source1 equals source2 on the previous bar, the next bar above is a crossover.
- Call it on every bar. Inside an if block it compares values from bars where the block ran.
Example
//@version=6
indicator("Crossover marks", overlay = true)
fast = ta.sma(close, 10)
slow = ta.sma(close, 30)
plot(fast, "Fast", color = color.green)
plot(slow, "Slow", color = color.red)
plotshape(ta.crossover(fast, slow), "Cross up", shape.labelup, location.belowbar, color.green, text = "Up", textcolor = color.white)See also
Runs on Sidechair