ta.cross()Cross
Returns true on bars where two series cross each other (either direction), compared bar-to-bar.
Syntax
ta.cross(source1, source2) → series boolArguments
| Parameter | Type | Description |
|---|---|---|
| source1 | series int/float | First series. |
| source2 | series int/float | Second series. |
Returns
true if two series have crossed each other, otherwise false.
Code Examples
//@version=6
indicator("ta.cross")
fast = ta.sma(close, 9)
slow = ta.sma(close, 21)
plot(fast)
plot(slow)
plotshape(ta.cross(fast, slow), title="Cross", style=shape.triangleup, location=location.belowbar, size=size.tiny)Trading Applications
Detect any crossing between two series
Build custom crossover-based strategies
Identify indicator intersections
Use as a trigger for alerts
Related Functions
Frequently Asked Questions
Generate ta.cross() Code with AI
Draft Pine Script using ta.cross() with Pineify's AI Coding Agent, then review the arguments and test the result on your chart. Usage depends on your plan and available credits.
Related Pine Script Functions
ta.crossover() - Crossover
Learn how to use ta.crossover() in Pine Script. Detect bullish crossovers for golden cross and buy signals.
ta.crossunder() - Crossunder
Learn how to use ta.crossunder() in Pine Script. Detect bearish crossunders for death cross and sell signals.
ta.change() - Change
Learn how to use ta.change() in Pine Script. Calculate bar-to-bar differences for price, time, and boolean series.
ta.rising() - Rising
Learn how to use ta.rising() in Pine Script. Test if a series is consistently rising over a given period.
ta.falling() - Falling
Learn how to use ta.falling() in Pine Script. Test if a series is consistently falling over a given period.