Instructions/probuilder · probacktest · proorder · proscreener

CROSSES OVER

CROSSES OVER in ProBuilder returns true on the bar where one series moves from below to above another, the standard trigger for bullish crossover signals.

Syntax

probuilder
a CROSSES OVER b

Parameters

NameTypeDefaultDescription
anumeric seriesrequiredThe series being tested for an upward crossing.
bnumeric series or constantrequiredThe series or fixed level that a must cross above.

Formula

a CROSSES OVER b is true when both conditions hold on the same bar:

code
a[1] <= b[1]  and  a > b

On the previous bar a was at or below b, and on the current bar a is strictly above b.

How it works

CROSSES OVER compares two values across consecutive bars and returns a boolean. It fires only on the single bar where the relationship flips from below to above. On every following bar where a simply stays above b, the expression is false. This makes it an event detector rather than a state test, which is the key difference from writing a > b.

Both operands can be any numeric expression: an indicator call, a price constant such as close, a user variable, or a fixed number. Crossing a constant level is common, for example RSI[14](close) CROSSES OVER 50.

Because the test involves the current bar, a signal evaluated on a live, unfinished bar can appear and disappear as prices move. Strategies that must only act on confirmed signals typically test shifted values, such as a[1] CROSSES OVER b[1], so the crossing is measured on completed bars.

Examples

Example 1, EMA crossover signal (Indicator)

probuilder
a = ExponentialAverage[20](close)
b = ExponentialAverage[50](close)
signal = 0
// Test the crossing on completed bars to avoid repainting
IF a[1] CROSSES OVER b[1] THEN
  signal = 1
ELSE
  signal = 0
ENDIF
RETURN signal AS "Bullish Signal"

The indicator plots 1 on the bar after a 20-period EMA crosses above a 50-period EMA, and 0 everywhere else. Shifting both operands by one bar means the signal is based on closed data only.

Example 2, Long entry on a moving average cross (ProOrder)

probuilder
fast = Average[20](close)
slow = Average[50](close)
// Open a long position on the upward cross
IF fast CROSSES OVER slow AND NOT LONGONMARKET THEN
  BUY 1 CONTRACT AT MARKET
ENDIF
SET STOP PLOSS 50

The strategy buys one contract on the bar where the fast average crosses above the slow average, provided no long position is already open, and attaches a 50-point stop.

Example 3, RSI leaving oversold territory (ProScreener)

probuilder
myRSI = RSI[14](close)
// Match instruments where RSI has just crossed above 30
cond = myRSI CROSSES OVER 30
SCREENER[cond] (myRSI AS "RSI value")

The screener lists instruments whose 14-period RSI crossed above the 30 level on the current bar, showing the RSI value in the results column.

Common errors and gotchas

  • Confusing a crossing with a state. a CROSSES OVER b is true for exactly one bar. Code that expects it to stay true while a remains above b should use a > b instead.
  • Repainting on the live bar. Evaluated on the forming bar, the condition can toggle as ticks arrive. Testing a[1] CROSSES OVER b[1] confirms the cross on closed bars at the cost of one bar of delay.
  • Touch without crossing. If a rises to exactly equal b and then falls back, no crossover fires, since the current-bar value must be strictly greater. Signals that should include touches need an explicit comparison.
  • Flat series never cross. When both operands are identical or move in lockstep, for example the same average applied to the same input, the expression never returns true. Verify the two series are genuinely different.
  • CROSSES UNDER, the mirror operator for downward crossings.
  • IF, conditional block that usually wraps a crossover test.
  • THEN, required between the condition and the block body.
  • ExponentialAverage, EMA series commonly used in crossover systems.
  • Average, simple moving average, another frequent crossover input.
  • AND, combines a crossover with additional filters.
  • OR, accepts any of several crossover conditions.
  • BarsSince, counts bars elapsed since a condition such as a crossover was true.