Quit the OnTick when it's too early, like so maybe:
if(TimeCurrent()<StringToTime("15:45")) return;
Maybe there's a bug in your code. Spooky things like this:
for (int i=1; i>=OrdersTotal(); i++)
If OrdersTotal() returns 0 then i here runs from 1 to INT_MAX before it wraps to a negative value. That means ~2
billion senseless calls of OrderSelect() on
every
tick.
The while loops where orders are to be closed/opened don't look right either. And endless while that breaks at the end of the body is like no while loop at all.
You'll probably want to clean up some things before going on.
Besides this belongs to the MQL 4 section.
Maybe there's a bug in your code. Spooky things like this:
If OrdersTotal() returns 0 then i here runs from 1 to INT_MAX before it wraps to a negative value. That means ~2
billion senseless calls of OrderSelect() on
every
tick.
The while loops where orders are to be closed/opened don't look right either. And endless while that breaks at the end of the body is like no while loop at all.
You'll probably want to clean up some things before going on.
Besides this belongs to the MQL 4 section.
Thanks for the feedback!
On a second view, I think the return in the closing loop is the culprit.
Because then you do not get to the opening loop... but again, I wouldn't use a loop for this at all.
Unless you want to repeat the closing in case of any failure.
This is tricky to code, you need to check for certain error conditions, and if you do not do this right you might loop endlessly. Better no loops here.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Thanks in advance!