Orders from EA very occasionally get totally ignored

 

I've only just started in the forex market a few weeks ago and have written quite a few EAs in the last few weeks.


Discovered a problem last night with one of my EAs.


I have the same EA performing on 4 different symbols under the same MIG demo account.


Everything normally goes smoothly (I do use the IsTradeAllowed() function) but last night when the order was being placed nothing happened. No error. No response. Nada.

I ran the EA again within a few mins (no change to code) and the order was placed perfectly.

Seems like my order dropped into a black hole.


I am thinking of programming around this, but should this be necessary?


Does the client-server protocol not implement a guarantee (a la MQ-Series) that each trade will reach the server once and once only - given that this is a financial system ;-) ??


What is the accepted way for the EA programmer to deal with order placement timing out with no error response from either the client framework or the server?


Many thanks,

CB

 

there is absolutely no warranty.

client sends to server... does it get there?... client times out... returns from eg, OrderSend() back to your code.

client sends - it can never know IF server got it unless it gets comms back, yes?

YOU must check ALL trading function status returns and when appropriate GetLastError(). To do otherwise is falling off the edge imho.

You say "no error response" - what does this mean?

The Terminal will give you an error response... but your code has to ask for it and also react to each error code in the proscribed manner.

Many times this can mean sleeping for a bit (again, recommendations are given in docs) and then retrying.

Hence, a sleep - retry loop surrounding your trade function call.

Many times it is advised that you chuck the trade operation and call it a day either due to an hard error or sleep or return to terminal until recalled next tick - HOW your code deals with errors is totally up to you, the recommendations exist and will guide your every step IF you willing to do it.

Many do not do any error checks - so ok... is their equity, yes?

btw,

istradeallowed is only the tip of the iceberg when doing serious fault tolerant EA coding

 
fbj:

there is absolutely no warranty.

client sends to server... does it get there?... client times out... returns from eg, OrderSend() back to your code.

client sends - it can never know IF server got it unless it gets comms back, yes?

YOU must check ALL trading function status returns and when appropriate GetLastError(). To do otherwise is falling off the edge imho.

You say "no error response" - what does this mean?

The Terminal will give you an error response... but your code has to ask for it and also react to each error code in the proscribed manner.

Many times this can mean sleeping for a bit (again, recommendations are given in docs) and then retrying.

Hence, a sleep - retry loop surrounding your trade function call.

Many times it is advised that you chuck the trade operation and call it a day either due to an hard error or sleep or return to terminal until recalled next tick - HOW your code deals with errors is totally up to you, the recommendations exist and will guide your every step IF you willing to do it.

Many do not do any error checks - so ok... is their equity, yes?

btw,

istradeallowed is only the tip of the iceberg when doing serious fault tolerant EA coding


Many thanks for quick response.

Understood - application needs to assume the worst every time it performs a network operation which is asynchronous.

I realize that the IsTradeAllowed() function is only one tool in the box.

I do perform error checking and use the GetLastError(0) function but I think my problem is that I only do this if I've got a ticket number > 0 back from the OrderSend() function.

What I think I need to handle is the occasion where nothing comes back from the OrderSend() function.


Regds,

CB

Reason: