Download MetaTrader 5

Odd behaviour of WHILE operator - page 4

To add comments, please log in or register
Are you used to trading from your smartphone? Mobile version of MetaTrader 5 will suit you best!
Ian Venner
Ian Venner 2014.04.16 16:01  

That's it!

Shame on me... :-)

Moreover it's not the first time I use WHILE but I started thinking in reverse and never came out of MY OWN loop :-/

And so the deVries' suggestion of replacing || with && turns right.

A lot of other things to take care of came out from this topic, i.e. whit the IF( == ) works.

Thank you all for your patience and the time you spent to make me understand.

We all have done similar things lol...

Yes you could do as deVries said or you could just add a break to get out of the while loop after it draws the object.

Having said that if you use break you could make a little bit more efficient code because there would be no need for the first while condition.

Also as GumRai said, calling EMPTY_VALUE is a better comparison value than calling iHigh().

extern int SwingBarCount=100;
//| Script program start function                                    |
int start()
   int SwingHighShift=0;
   string StringHighStatus="False";
   int SwingHigh=0;
      if(iFractals(NULL,0,MODE_UPPER,SwingHighShift)!=EMPTY_VALUE && iFractals(NULL,0,MODE_UPPER,SwingHighShift)>Close[0])
      else SwingHighShift++;
To add comments, please log in or register