I have this code in a loop:
if (OrdersTotal() > 0) { monitorTrade(); } if (OrdersTotal() == 0) { orderOpen("buy"); return; }
I expected the EA to never open more than one single order at a time, but it sends many until I disable it.
I put the output of OrdersTotal() in a label and saw that the number of orders were indicated as 0 although several had been opened.
I placed a single order out of the loop and the label still indicated 0, not 1.
Even with the boolean value flip inserted right in the loop, the EA still posts multiple orders.
So I have two problems:
1) Why is OrdersTotal() not working as expected?
2) Why is my global variable isOrderRunning not being acknowledged?
Hello,
Use PositionsTotal() to see how many trades are currently running.
OrdersTotal() is used to see how many pending orders have been placed.
Kind regards.

- www.mql5.com
I have this code in a loop:
I expected the EA to never open more than one single order at a time, but it sends many until I disable it.
I put the output of OrdersTotal() in a label and saw that the number of orders were indicated as 0 although several had been opened.
I placed a single order out of the loop and the label still indicated 0, not 1.
That is not even what I wanted in the first place. I'm used to doing it like this:
And the actual loop is:
But that fails too. I mean, the EA will keep opening more than one order if I don't disable it.
I flip the boolean value from inside the orderOpen function after confirmation that the order has been sent successfully (which I still don't know how to do), but for the sake of testing I changed the loop to this:
Even with the boolean value flip inserted right in the loop, the EA still posts multiple orders.
So I have two problems:
1) Why is OrdersTotal() not working as expected?
2) Why is my global variable isOrderRunning not being acknowledged?

- 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 have this code in a loop:
I expected the EA to never open more than one single order at a time, but it sends many until I disable it.
I put the output of OrdersTotal() in a label and saw that the number of orders were indicated as 0 although several had been opened.
I placed a single order out of the loop and the label still indicated 0, not 1.
That is not even what I wanted in the first place. I'm used to doing it like this:
And the actual loop is:
But that fails too. I mean, the EA will keep opening more than one order if I don't disable it.
I flip the boolean value from inside the orderOpen function after confirmation that the order has been sent successfully (which I still don't know how to do), but for the sake of testing I changed the loop to this:
Even with the boolean value flip inserted right in the loop, the EA still posts multiple orders.
So I have two problems:
1) Why is OrdersTotal() not working as expected?
2) Why is my global variable isOrderRunning not being acknowledged?