Your English is fine. Don't write code like that its confusing. For every && make a new nest. For every || make a new if on the same level. The difference is due to Doubles not being static. Could be better to run within Start or Create an Indicator.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello, I'm new to MQL world and I'm trying to learn something by practice approach. Today the subject were ARRAY and I made an experiment: I tryed do write an algorithm that consider every couple of bars and counts the similar and the different ones. For similar couples I mean the ones where open price is smaller or bigger than close price for both...so (red-red) (green-green) are similar but (green-red) (red-green) are different.
This is the algorithm I put down:
int init()
{
int equal, i;
while (i<Bars-1){
i++;
if (((Open[i]>Close[i] && Open[i+1]>Close[i+1]) || (Open[i]<Close[i] && Open[i+1]<Close[i+1])))equal++;
}
Alert("equal: "+equal+" -- different: "+(i-equal));
return(0);
}
Is this code correct for reaching my scope? Was it better to put it in the start() function? Why different couples are every time a little bit more than equal ones?
OT (I'm from italy): is my english grammar correct ?