Between

Between ( double parameter , double value1 , double value2 );

Description

Tests if the specified parameter is within the range of value1 and value2 inclusively. The function returns 1 (true) if the data is between the two parameter values, and 0 (false) if the data is outside of the two parameter values.

Input parameters

Parameter Default value Description
parameter - Defines parameter to test.
value1 - Defines the first endpoint of the range.
value2 - Defines the second endpoint of the range.

Example

declare lower;
input lowLimit = 140.0;
input highLimit = 160.0;
plot Between1 = Between(close, lowLimit, highLimit);
plot Between2 = close >= lowLimit and close <= highLimit;

The code will return 1 if the closing price is between lowLimit and highLimit, and 0 if the closing price is below lowLimit or above highLimit. The example also shows the alternative solution to the between function implemented using the double inequality.