CrossBelow()

View as Markdown

Definition

Evaluates a cross below condition over the specified bar look-back period.

This method does not return true if both series being compared have equal values on the current or previous bar with a lookbackPeriod of 1.

Method Return Value

This method returns true if a cross below condition occurred; otherwise, false.

Syntax

CrossBelow(ISeries\<double\> series1, ISeries\<double\> series2, int lookBackPeriod)

CrossBelow(ISeries\<double\> series1, double value, int lookBackPeriod)

Parameters

ParameterDescription
lookBackPeriodNumber of bars back to check the cross below condition
series1 & series2Any Series<double> type object such as an indicator, Close, High, Low, etc…
valueAny double value

Examples

1protected override void OnBarUpdate()
2{
3 // Go long if CCI crossed below -250 within the last bar
4 if (CrossBelow(CCI(14), -250, 1))
5 EnterLong();
6
7 // Go short if 10 EMA crosses below 20 EMA within the last bar
8 if (CrossBelow(EMA(10), EMA(20), 1))
9 EnterShort();
10
11 // Go short we have a down bar and the 10 EMA crosses below 20 EMA within the last 5 bars
12 if (Close[0] < Open[0] && CrossBelow(EMA(10), EMA(20), 5))
13 EnterShort();
14}