Hello everyone
On my request, a friend wrote “trading robot”. Everything would be fine, but there is a problem or error. We don’t know how to fix it.
The problem is as follows-the Expert Advisor is given a pair of options for opening a trade. It is worth checking for magicid, that is, if the transaction is already open,
then do not open a new one. But there are such moments (when the connection to the server jumps or the market is closed/opened), the robot sends a request to
open a trade, but does not receive a response. Sends again-again silence. And now the connection is restored and all requests sent to
open a deal and not waiting for a response are opened. why does the magicid check not work? 30-40 open trades in one direction per day
1-2 seconds is very, very fraught. maybe we did something crooked? Good people, please tell me what is wrong and how to fix it?
trendhunter
no, i remembered how it was. It was a long time ago, I was making my first steps in MQL5. I did it with the help of an article here on the site. And there it was written?
what is trade. setasyncmode(true).
Here is this true I made false and everything is fine.
ya_programmer
perhaps you have an asynchronous mode of opening transactions, use synchronous
make a check for the number of open trades and prohibit opening more than necessary
alexeyvik
maybe i’m tired of complaining))) or convinced of the failure of the strategy.
trendhunter
Not disabled. I once made a robot for a person, I did not specify this asynchrony at all. And it sometimes opened a lot of
orders for him. Although all the checks for quantity and all that have been done. I implemented trade. setasyncmode(false)
and it helped.
alexeyvik
this probably won’t help. judging by the inexperience of the performer, he had not heard of this. and by default, asychrony is disabled.
edprivy
Eugene, thank you for your answer. And how do I make the robot wait for a response before sending the next request? I don’t write the robot, I know it writes, but
it works in other languages. Please tell me what he needs to insert into the code to get rid of this problem.
Thank you in advance.
trendhunter
Wait for the server response code before sending the next request. And just in case, turn off asynchrony or whatever it is right