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
ta.crossunder(source1, source2) → series boolArguments
| Parameter | Type | Description |
|---|---|---|
| source1 | series int/float | Series that must end below source2 on the current bar. |
| source2 | series int/float | Reference series. |
Returns
true if source1 crossed under source2 otherwise false.
Code Examples
//@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.
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.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.