This forum is in read-only mode now. You may discuss your questions on forums of MQL4.community and MQL5.community

Question re. for loop structure


Back to topics list
avatar
7
dacosta123 2005.05.31 18:32 
Hi is the following for loop allowed?
If not, do i skip inside the loop in that case?

for (int i=limit; i>=0; i=i-barsPerDay) {
...
}

tia,

Fermin DCG
avatar
4464
Slawa 2005.05.31 20:01 
there is legal construction. what the problem?
avatar
7
dacosta123 2005.05.31 20:35 
there is legal construction. what the problem?


That's what i thought.
The reason for asking was that the cpu went to 100% and all was not fine.

I'll retry and see whether the error persists and 'report back'

thx
avatar
23
Matias 2005.06.01 03:55 
dacosta
I guess the only reason for your cpu going to 100% is that barsPerDay is less than zero,
in that case, the loop take forever to exit.
Check that.

Matias
avatar
7
dacosta123 2005.06.01 08:51 
dacosta
I guess the only reason for your cpu going to 100% is that barsPerDay is less than zero,
in that case, the loop take forever to exit.
Check that.

Matias

Obviously it was my misstake ;-) and indeed it had to do with going below zero.
In an attempt to hack around it i build in a decrement statement at the end that i forgot to remove (and did not not check for 0).

Thx 4 your input

Fermin DCG
Back to topics list  
Download MetaTrader 5 (450 Kb, web installer) — a new terminal for financial markets