Crossover & ComparisonPine Script v6

ta.crossunder()

Crossunder

The source1-series is defined as having crossed under source2-series if, on the current bar, source1 is less than source2, and on the previous bar, source1 was greater than or equal to source2.

Syntax

Syntax
ta.crossunder(source1, source2) → series bool

Arguments

ParameterTypeDescription
source1series int/floatSeries that must end below source2 on the current bar.
source2series int/floatReference series.

Returns

true if source1 crossed under source2 otherwise false.

Code Examples

Pine Script v6 Example
//@version=6
indicator("ta.crossunder")
fast = ta.sma(close, 50)
slow = ta.sma(close, 200)
plot(fast, color=color.teal)
plot(slow, color=color.orange)
plotshape(ta.crossunder(fast, slow), title="Crossunder", style=shape.labeldown, text="X", location=location.abovebar, size=size.small, color=color.red)

Trading Applications

Detect death cross (50 MA under 200 MA) signals

Build sell/short strategies based on crossunders

Trigger exit signals when fast indicator crosses below slow

Create alert conditions for bearish crossovers

Related Functions

Frequently Asked Questions

Generate ta.crossunder() Code with AI

Skip the manual coding. Use Pineify's AI Coding Agent to generate Pine Script code using ta.crossunder() and other built-in functions instantly.