How to write BETWEEN x and y in mql5 ?

Hi!

I've been writing a code but its getting loong, i cant find a way to make it smaller, i need candle[1] to be different  than all candles between [2] and [9] (just an example). How do i do that without having to write candle[1] != candle[2] &&... one by one?

`if (candle[1] != candle[2] && candle[1] != candle[3] && candle[1] != candle[4] && candle[1] != candle[5]`

Leonardo Fernandez:

Hi!

I've been writing a code but its getting loong, i cant find a way to make it smaller, i need candle[1] to be different  than all candles between [2] and [9] (just an example). How do i do that without having to write candle[1] != candle[2] &&... one by one?

```   int candle[9];
//code to fill candle array
bool isEqual=false;
int size=ArraySize(candle);
for(int x=2; x<size; x++)
{
if(candle[1]==candle[x])
{
isEqual=true;
break;
}
}
if(isEqual)
{
//Do whatever when an equal value is found
}
else
{
//Do whatever when an equal value is NOT found
}```

Not compiled or tested.

Leonardo Fernandez: i need candle[1] to be different  than all candles between [2] and [9] (just an example). How do i do that without having to write candle[1] != candle[2] &&... one by one?
1. Doubles are rarely equal. Understand the links in:
The == operand. - MQL4 programming forum #2 2013.06.07

2. Write a loop like Keith showed.
Reason: