## crossUnder (vars Data, var border) : bool

Determines if the data1 series crosses over or under the data2 series, or over or under a fixed border value. Often used for trade signals.

### Parameters:

 Data1 First data series. Data2 Second data series. border border value.

### Returns:

true if the first series crosses the second, false otherwise.

### Modifies

rMomentum - Data movement in percent per time frame at the time of the crossing; indicates the 'speed' of the crossover.

### Algorithms:

`bool crossOver(var* data1,var* data2) { return (data1[0] > data2[0]) && (data1[1] < data2[1]); }bool crossUnder(var* data1,var* data2) { return (data1[0] < data2[0]) && (data1[1] > data2[1]); }bool crossOver(var* data,var border) { return (data[0] > border) && (data[1] < border); }bool crossUnder(var* data,var border) { return (data[0] < border) && (data[1] > border); }`

### Remarks:

• The data series must have a minimum length of 2.
• For a fuzzy logic version that also detects 'almost crossovers', use crossOverF / crossUnderF.
• For checking if a crossover occurred n bars before, use crossOver(Data1+n,Data2+n).
• For predicting a future crossover, or for detecting only 'strong crossovers', use the predict function.
•  !!  Identical values of the two series for one or several bars will not produce a crossover signal. If that is desired, define a function similar to those above, but with >= and <= comparisons instead of > and < for the first term.

### Example:

```function run()
{
vars Price = series(priceClose());
vars SMA100 = series(SMA(Price,100));
vars SMA30 = series(SMA(Price,30));

if(crossOver(SMA30,SMA100))
enterLong();
else if(crossUnder(SMA30,SMA100))
enterShort();
}
```