Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1166
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Can you please tell me how to set order selection by symbol for OrdersTotal()?
Right now, if there is an open order on one pair, it won't open on others.
Can you please tell me how to set order selection by symbol for OrdersTotal()?
Now, if there is an open order on one pair, it does not open on others.
Look at kodobase, there is an example in every EA
Look in kodobase, there is an example in every advisor
I am not a programmer(
It's a bit complicated for me.
I'm not a programmer(
It's a bit complicated for me.
it's not complicated.
to write a basic EA, here is all the functionalityhttps://www.mql5.com/ru/forum/131859
For your purposes OrdersTotal() is the total number of open orders (numbered from 0 ) in the terminal, then you need to select them one by one (go through the loop) using OrderSelect() and manipulate the necessary orders
Can you please tell me how to set order selection by symbol for OrdersTotal()?
Right now, if there is an open order on one pair, it does not open on others.
I need to periodically check (count myself) my orders as needed.
I have in every EA a loop (a huge method) which is called before important actions:
for(int pos=OrdersTotal()-1; pos>=0;pos--) {
if (!OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)) {
selectFailed=true; /* не удалось "выбрать" ордер - статистика может быть неверной */
continue;
}
if (OrderCloseTime()!=0) { /* ордер закрыт но ещё не удалён из списка*/ continue; }
if (OrderMagicNumber()==0) { /* ордер выставлен юзером */ } continue;
else if (OrderMagicNumber()!=_Magic) { /* ордер выставлен другим советником */ continue; }
if (OrderSymbol()!=_Symbol) { /* ордер с правильным Magic но на другом символе */ continue; }
/// обработка рабочих ордеров, с правильным Magic на символе советника (то есть наш ордер)
/// проверяются несработки, считается кол-во, статистика, позиции и прочее
}
check for an order on the symbol is highlighted
periodically, as needed, to check (self-check) their orders.
I have a loop (a huge method) in each EA, which is called before important actions:
for(int pos=OrdersTotal()-1; pos>=0;pos--) {
if (!OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)) {
selectFailed=true; /* не удалось "выбрать" ордер - статистика может быть неверной */
continue;
}
if (OrderCloseTime()!=0) { /* ордер закрыт но ещё не удалён из списка*/ continue; }
if (OrderMagicNumber()==0) { /* ордер выставлен юзером */ } continue;
else if (OrderMagicNumber()!=_Magic) { /* ордер выставлен другим советником */ continue; }
if (OrderSymbol()!=_Symbol) { /* ордер с правильным Magic но на другом символе */ continue; }
/// обработка рабочих ордеров, с правильным Magic на символе советника (то есть наш ордер)
/// проверяются несработки, считается кол-во, статистика, позиции и прочее
}
check the order by the symbol is highlighted
On a side note, I understand that the tickers of historical orders may get lost. The question is if the order tickers(SELECT_BY_TICKET) in MT4 and tickers of deals and positions in MT5 may change.
And also, may the order be changed after the OrderSelect on the ticket. For example the next day. The EA is not disabled.
If the pending order has become a market order, you can view it by its type. If the market order has closed, then we look at the time of order closing, not equal to zero OrderCloseTime()!=0
If the pending order has closed by its lifetime, then how do we track it by the order ticket.
And a question, the lifetime is also in market orders(MT4), does it work?
Can you please tell me how to set order selection by symbol for OrdersTotal()?
Now, if there is an open order on one pair, it does not open on others.
The question is already solved. Thank you all.
Hello Dear Sirs! I don't understand what's wrong, why it writes Alert: time3-time1 = wrong datetime?
because the number is negative :-)
by this logic time1 is __always __more than time3
because the number is negative :-)
by the given logic time1 is __always __more than time3
Thank you! Sometimes the brain goes off.