Hello, everyone..
What is the best way to check if there have been any orders closed from midnight to the current time on the same day?
The next day the check should start from 0 again.I am thinking of using a OrdersHistoryTotal (0)..
It is not clear what you mean by "a OrdersHistoryTotal (0)"
It is also not clear what "the best way" is to do anything. A way would be to to search the entire order history, possibly neglecting trades with the wrong magic number, and/or and the wrong symbol. Then reject any which closed earlier than today. Count any that are left. So this is an OrderSelect using MODE_HISTORY. The time of the start of the day should be iTime with a period of D1 and a shift of 0.
Sorry, a zero in the brackets is a typo
I am using OrdersTotal and OrderSelect to find and count any currently open orders with a particular Magic number and this works fine. I also need to identify if there have been orders closed with the same Magic number today (don't have to count them, though)..My EA uses ticks, hence I am not sure if iTime can be used...
What is the best way to check if there have been any orders closed from midnight to the current time on the same day?
The next day the check should start from 0 again.I am thinking of using a OrdersHistoryTotal (0)..
datetime now = Time[0], bod = now - now % 86400; for(int iPos=OrdersHistoryTotal()-1; iPos >= 0; iPos--) if ( OrderSelect(iPos, SELECT_BY_POS, MODE_HISTORY) // Only orders w/ && OrderMagicNumber() == Magic.Number // my magic number && OrderSymbol() == chart.symbol // and my pair. && OrderType() <= OP_SELL//Avoid cr/bal https://www.mql5.com/en/forum/126192 && OrderCloseTime() >= bod ){see also Order History sort by closing date - MQL4 forum
resin17:
My EA uses ticks, hence I am not sure if iTime can be used...
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello, everyone..
What is the best way to check if there have been any orders closed from midnight to the current time on the same day?
The next day the check should start from 0 again.I am thinking of using a OrdersHistoryTotal (0)..
Thank you for any recommendations.
R