crosses

Syntax

<value1> crosses above <value2>

<value1> crosses below <value2>

<value1> crosses <value2>

Description

This reserved word is used as a human-readable version of the Crosses function. It tests if value1 gets higher or lower than value2.

Example

plot Avg = Average(close, 10);
plot ArrowUp = close crosses above Avg;
plot ArrowDown = close crosses below Avg;
plot Cross = close crosses Avg;
ArrowUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
ArrowDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
Cross.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);

This code plots up arrows indicating the bars at which the close price gets above its 10 period average, and down arrows where the close price gets below its 10 period average. The same result can be achieved by using the Crosses function:

plot Avg = Average(close, 10);
plot ArrowUp = Crosses(close, Avg, CrossingDirection.ABOVE);
plot ArrowDown = Crosses(close, Avg, CrossingDirection.BELOW);
plot Cross = Crosses(close, Avg, CrossingDirection.ANY);
ArrowUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
ArrowDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
Cross.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);

Example

plot Avg = Average(close, 10);
plot Cross = close crosses Avg;
Cross.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);

This code plots arrows indicating the bars at which the Close price gets higher or lower than its 10 period average. The equivalent code is:

plot Avg = Average(close, 10);
plot Cross = close crosses above Avg or close crosses below Avg;
Cross.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);