- You need to initialize BuyTotal and BuyLots before entering the loop.
- The if(…) break is just wrong; delete it.
- OrderCloseTime will always be zero; delete it.
William Roeder:
- You need to initialize BuyTotal and BuyLots before entering the loop.
- The if(…) break is just wrong; delete it.
- OrderCloseTime will always be zero; delete it.
Thank you very much William. I will do so.
Ernest Klokow:
Thank you very much William. I will do so.
Initializing the BuyLots variable did the job!
(I deleted the BuyTotal also since it was not required for the "if" statement.
Thanks again!

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
I am trying to count the total lots for all open Buy trades but the EA keeps on going through the loop and does not stop adding the lots together.
So in the first round it calculates the total lots correct but then keeps on adding that amount of lots over and over.
I want to stop it once it has gone through the loop one time.
Here is the code: