interesting.
How are you going to change your trade if you lost connection?
Are you using a VPS? If so, Why do you need to know if the internet connection is lost?
I think you also want to use PositionTotal() which will give you the positions that are open. An Order is a finished position.
You might want to read this article.
Orders, Positions and Deals in MetaTrader 5 - MQL5 Articles
Hope this helps.
Chris

- www.mql5.com
Hi the OrdersTotal() function is not getting open orders on startup. I am trying to check for open orders in case of a lost internet connection or restart of the EA due to power issues. But the code below is returning 0 for open orders...
The start of an EA is performed by several parallel threads. So it can happen that you EA sends the order OrdersTotal() to the server and moves on without waiting for the answer. You need to repeat it in OnTick().
thanks all it works if I put PositionsTotal() in the OnTick() function, now trying to get the order type whether buy or sell
and save it to a ticket.
There is no order type; there is only a position type.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi the OrdersTotal() function is not getting open orders on startup. I am trying to check for open orders in case of a lost internet connection or restart of the EA due to power issues. But the code below is returning 0 for open orders...