dispatch the order on market, with omission the answer on demand about acceptance the broker's price

 

I wrote the expert in MQL using the OrderSend() function. The expert works ok in back tests. But the program does not work properly on real time. The expert makes only a few or one transaction in spite, that there was a lot of signals to make more transactions than have been done.


My question is: How to skip the answer on demand about acceptance the broker's price in real time using the MQL syntax without changing the Slippage level? I would like to set Slippage variable as 0 or 1 only. But many times, after signal to make OrderSend() function the price is bigger or smaller than my Slippage level. I suppose that this is cause, that transactions did not become contained. How to fix the problem in MQL code?


My second question is: How to maintain a stable connection to the server broker?

 

A1: Amend your EA to place a limit order. Or amend you EA to trap error 138 and act accordingly.

A2: Build a persistent/recoverable data capability into your EA. Use a reliable computer platform, network provider and broker. Or investigate a hosting service if this is not practical.


CB

 
cloudbreaker:

A1: Amend your EA to place a limit order. Or amend you EA to trap error 138 and act accordingly.

A2: Build a persistent/recoverable data capability into your EA. Use a reliable computer platform, network provider and broker. Or investigate a hosting service if this is not practical.


CB

Hi cloudbreaker,


You wrote: A1: Amend your EA to place a limit order. Or amend you EA to trap error 138 and act accordingly.


How to trap error 138 and act accordingly on Meta Trader? Could you please describe step by step how to do it on Meta Trader platform? What does the trap mean on MT4 ?


Rgds,

 
puncher:

Hi cloudbreaker,


You wrote: A1: Amend your EA to place a limit order. Or amend you EA to trap error 138 and act accordingly.


How to trap error 138 and act accordingly on Meta Trader? Could you please describe step by step how to do it on Meta Trader platform? What does the trap mean on MT4 ?


Rgds,

When you perform an OrderSend() function (or any trading function), its a good idea to subsequently check the return of the GetLastError() function. Note, however, that each time you call GetLastError() it is zeroed. So it will work once for you after each function you wish to check.


https://docs.mql4.com/check/GetLastError


CB


- Oh, and please do us a favour and lose the red font. Its very hard on the eyes. We're intelligent enough to be able to detect any important points you may make.