Sidechair

ta.crossunder()

Browse the reference

Returns true on the bar where source1 moves from at or above source2 to below it.

Try it in the editor

ta.crossunder is true when source1 < source2 on this bar and source1 >= source2 on the previous bar. The second argument can be a level, a number or another series.

The result is true for one bar per cross, and false on the first bar and wherever an na is involved.

Syntax

Pine Script
ta.crossunder(source1: series int/float, source2: series int/float) -> series bool

Arguments

NameTypeDefaultDescription
source1series int/floatrequiredThe series expected to move down through the other.
source2series int/floatrequiredThe series or level being crossed.

Returns

series bool: true on the crossing bar, otherwise false.

Remarks

  • Use ta.cross when the direction does not matter.

Example

Pine ScriptRSI falls below 70Open in editor
//@version=6
indicator("RSI exit", overlay = false)
r = ta.rsi(close, 14)
plot(r, "RSI", color = color.purple)
hline(70)
bgcolor(ta.crossunder(r, 70) ? color.new(color.red, 80) : na)

See also

Runs on Sidechair