ta.crossover()
Crossover
The source1-series is defined as having crossed over source2-series if, on the current bar, the value of source1 is greater than source2, and on the previous bar, source1 was less than or equal to source2.
Syntax
ta.crossover(source1, source2) → series boolArguments
| Parameter | Type | Description |
|---|---|---|
| source1 | series int/float | Series that must end above source2 on the current bar. |
| source2 | series int/float | Reference series. |
Returns
true if source1 crossed over source2 otherwise false.
Code Examples
//@version=6
indicator("ta.crossover")
fast = ta.sma(close, 50)
slow = ta.sma(close, 200)
plot(fast, color=color.teal)
plot(slow, color=color.orange)
plotshape(ta.crossover(fast, slow), title="Crossover", style=shape.labelup, text="X", location=location.belowbar, size=size.small, color=color.green)Trading Applications
Detect golden cross (50 MA over 200 MA) signals
Build moving average crossover strategies
Trigger buy signals when fast indicator crosses above slow
Create alert conditions for bullish crossovers
Related Functions
Frequently Asked Questions
Generate ta.crossover() Code with AI
Skip the manual coding. Use Pineify's AI Coding Agent to generate Pine Script code using ta.crossover() and other built-in functions instantly.
Related Pine Script Functions
ta.crossunder() - Crossunder
Learn how to use ta.crossunder() in Pine Script. Detect bearish crossunders for death cross and sell signals.
ta.cross() - Cross
Learn how to use ta.cross() in Pine Script. Detect when two series cross each other in either direction.
ta.sma() - Simple Moving Average
Learn how to use ta.sma() in Pine Script. Syntax, parameters, code examples, and trading applications for the Simple Moving Average function.
ta.ema() - Exponential Moving Average
Learn how to use ta.ema() in Pine Script. Syntax, parameters, code examples, and trading applications for the Exponential Moving Average function.
ta.macd() - MACD
Learn how to use ta.macd() in Pine Script. Syntax, parameters, code examples for MACD line, signal line, and histogram.