The if statement in there has no relevance whatsover on the "for" loop. The loop makes 4 cycles, that's it.
If you had if(bal bla) {code1; continue; } that would interfere with your for loop.
The 2 repeating loop controllers are continue; and break; they're quite selfexplanatory.
The if statement in there has no relevance whatsover on the "for" loop. The loop makes 4 cycles, that's it.
If you had if(bal bla) {code1; continue; } that would interfere with your for loop.
The 2 repeating loop controllers are continue; and break; they're quite selfexplanatory.
Thanks a lot forexCoder for clearing that up for me!
You probably don't need Refreshrates in your loop and could possibly add some confusion to whatever you are trying to achieve.
If you refreshrates and this then shifts the timeseries up mid loop then result is confused. The open and close values will be fixed for time you are running the EA and to get the result you are looking for should remain fixed IMO.
RefreshRates()
but it will only affect the current bar values, i.e. anything with [0] or [i] where i=0, and it will be a performance hit
So in the code posted, RefreshRates() will not change anything as i never gets to 0
Save it for when you need it just before order handling or before a price-level triggered decision, etc
-BB-
Thank you very much guys for pointing that out to me.
BarrowBoy your explanation of "anything with [0] or [i] where i=0," made the light come on!
I taking it out of this loop!
So in the code posted, RefreshRates() will not change anything as i never gets to 0
Hmm.
If I understood correctly, he meant that RefreshRates() changes and updates the Close[0] to the last known price. You want to say that it doesn't?
(Cough!) - what happens if the refreshrates happens at the same time a new bar is created?
EA is suspended during an OrderSend() OrderModify - if timing is slow or order errors occur then refreshrates is then needed to handle breakdown/slowdown in client - server comunication errors.
Stratergy for coping with communcation breakdown situation needs to be defined and coded. IMHO
If I understood correctly, he meant that RefreshRates() changes and updates the Close[0] to the last known price. You want to say that it doesn't?
Close[0] IS the last know price and refresh will do nothing, UNLESS, there's a server call (takes time) or long calculation, or non-returning EA (i.e. Sleep), etc.
Ticks come in (EURUSD) about 100/min or less. That's one per 50 milliseconds. Most codes will evaluate and return in sub-millisecond time. Nothing is changing.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am a beginner.
In the example of code below I have a "for" loop after the first "if" statement and another "if" statement further down.
Let us say in the first two loops the following test
is true. What happens if in the next loop (the third one) "Close" is not smaller than "Open" (making the "if" statement false), will the total of four loops be completed or will the code jump to the next statement or operator?
Here is the piece of code