![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
I just encountered the same problem, and it is destroying the logic of my EA.
I've been running an EA with a local broker for 3 months with no issues. I added the EA to a broker i'm using internationally, and this problem is repeatedly occuring. The bad part, is the logic in my EA will add a trade when the "fake" condition occurs, sometimes causing me to have an 3-4 more trades than I intend. I can't hope that they fix this bug asap.
I just encountered the same problem, and it is destroying the logic of my EA.
I've been running an EA with a local broker for 3 months with no issues. I added the EA to a broker i'm using internationally, and this problem is repeatedly occuring. The bad part, is the logic in my EA will add a trade when the "fake" condition occurs, sometimes causing me to have an 3-4 more trades than I intend. I can't hope that they fix this bug asap.
According to geektrader this issue should be fixed by now, see below. Have you tried build 445 ? make sure you backup your previous build before updating to 445 . . .
Thanks for your help Raptor, I will consider this for the code, however, that this is a unsync bug that can happen during fast market movements (this is where my EA trades) was just confirmed by Metaquotes after given them the log of MT4 Terminal against the MT4 Server log. They say, it´s clear that MT4 Server had opened the order while MT4 Terminal still was in the assumption that it is a pending "buy stop" order since the ticket numbers also did exactly match, otherwise MT4 Terminal wouldn´t have returned "buy stop" for that ticketnumber which was already opened 8 seconds ago at the broker. And it will be fixed in the next release;) Thank you anyway.
You can NOT delete pending order when the market is closer to open price than MarketInfo(chart.symbol, MODE_STOPLEVEL)*Point
You can NOT close open orders when the market is closer to TP or SL than stop level
You can NOT set stops closer then stop level from the market
Hi,
In rare cases I am getting a "invalid parameters" error for OrderDelete() which only needs the orderticket to do it´s job. This is for OP_BUYSTOP or OP_SELLSTOP order types. Before each run for OrderDelete(), I am browsing through OrdersTotal(), check them for OrderType() (only processing OP_BUYSTOP and OP_SELLSTOP types), get the ticket and then run OrderDelete(ticket). Still I get:
03:36:42 'XXXX': delete pending order #7720748 buy stop 0.65 EURJPY at 102.907 sl: 102.867 tp: 103.407
03:36:42 'XXXX': deleting of pending order #7720748 buy stop 0.65 EURJPY at 102.907 sl: 102.867 tp: 103.407 failed [Invalid parameters]
Now one of the reasons could be that the BUYSTOP order got active directly at the time the EA tries to delete it, but, the EA checks that on the next run (above mentioned loop) and then tried to delete this order again because according to OrderTotal() it was still a pending BUY_STOP order. It again got a Invalid Parameters error. However, I´ve checked with the broker and he sent me the MT4 Server log for this order. Interesting is: at the time the EA tries to delete the order, it was already opened at the MT4 server, and so all subsequent tries to delete it of course failed, but still MT4 client was reporting that this order is still a pending OP_BUYSTOP order, for over 20 seconds (in which the EA tried to delete the order all the time, but always getting invalid parameters error).
So to me this looks like a unsync bug between MT4 Terminal and MT4 Server, since OrdersTotal() was still returning that this ticket is a OP_BUYSTOP and not an open BUY Order, while at the broker server it was a buy order already for over 20 seconds. And the OrderDelete() function in my EA works fine in 99% of the cases, but then, a few times, the above described error happens and MT4 Terminal simply doesn´t get told by the MT4 Server that the order is already active.
Anyone else experienced that? How can I report it to Metaquotes?
Sorry for not looking real close, but looked like you are going from low index number (first=0) to high index number (orders total). As a suggestion, always go from most to 0 as in: for(int idx=(OrdersTotal()-1); idx>-1; idx--). If going the other way, the idx referencing a particular order changes after a delete - you can reach the end of the list of orders without looking at all your orders.
Correct except for US brokers (FIFO)
In the presence of multiple orders (one EA multiple charts, multiple EAs, manual trading), while you are waiting for the current operation (closing, deleting, modifying) to complete, any number of other operations on other orders could have concurrently happened and changed the position indexing:
Loops and Closing or Deleting Orders - MQL4 programming forum
CloseOrders by FIFO Rules - Strategy Tester - MQL4 programming forum - Page 2 #16
MetaTrader 5 platform beta build 2155: MQL5 scope, global Strategy Tester and built-in Virtual Hosting updates - Best Expert Advisors - General - MQL5 programming forum #1.11 ACCOUNT_FIFO_CLOSE
What are Function return values ? How do I use them ? - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles