Does EA have a chance to fail to close position?

 

Dear experienced traders, 


When we use MT4 manual, we will have a chance to fail to close position and we will hear a voice is like "Wooo...".

Does EA have same chance to fail to close position? 

What will happened if the EA fail to close position? Will the EA try to close the position again or never take care for the fail close position? 


I'm considering run EA in remote VPS to reduce cost so I asked this question. 

I think the EA might work same as when we do it manual. Tell me if I'm wrong. 


Thank you in advance and best wishes,

Sky

 
Sky L:

Dear experienced traders, 


When we use MT4 manual, we will have a chance to fail to close position and we will hear a voice is like "Wooo...".

Does EA have same chance to fail to close position? 

What will happened if the EA fail to close position? Will the EA try to close the position again or never take care for the fail close position? 


I'm considering run EA in remote VPS to reduce cost so I asked this question. 

I think the EA might work same as when we do it manual. Tell me if I'm wrong. 


Thank you in advance and best wishes,

Sky

Dear you,

Indeed an operation emitted manually or via an EA can fail due to any reason from bad connectivity to vps memory slowing down due to high activity. 

It's the author responsability to assume those kind of "unexpected" errors which aren't "errors" stricto sensu, I already talked you of in a previous post concerning drawdown (if I remember well ...) 

Sometimes you'll have a VPS with a ping of 10ms, but the order will by moment take 300ms to reach the broker ... it's part of the "game". 

There's a speed race between datas providers everywhere in the world to reduce the latency, there's even a movie on that ... 


 
Icham Aidibe:

Dear you,

Indeed an operation emitted manually or via an EA can fail due to any reason from bad connectivity to vps memory slowing down due to high activity. 

It's the author responsability to assume those kind of "unexpected" errors which aren't "errors" stricto sensu, I already talked you of in a previous post concerning drawdown (if I remember well ...) 

Sometimes you'll have a VPS with a ping of 10ms, but the order will by moment take 300ms to reach the broker ... it's part of the "game". 

There's a speed race between datas providers everywhere in the world to reduce the latency, there's even a movie on that ... 


Thank you, Icham. 

I heard this movie from another friend before, very good story. 

My friend told me she like the scene when a girl watering the best programmer's head.....

 
The microseconds the EA takes is irrelevant, compared to the 20-200 milliseconds the network takes, which is irrelevant compared to the minutes to do a trade because of the servers during news.

OrderSend sends the request, network delivers, placed in the server queue. Once it reaches the top of the queue, you get filled or not, and the result delivered back to the terminal. Normally it is the 20-200 milliseconds the network takes to deliver is the limiting factor, but it can take minutes to do a trade because of the servers during news.

 
William Roeder:
The microseconds the EA takes is irrelevant, compared to the 20-200 milliseconds the network takes, which is irrelevant compared to the minutes to do a trade because of the servers during news.

OrderSend sends the request, network delivers, placed in the server queue. Once it reaches the top of the queue, you get filled or not, and the result delivered back to the terminal. Normally it is the 20-200 milliseconds the network takes to deliver is the limiting factor, but it can take minutes to do a trade because of the servers during news.

Thank you for your continuing support, William. 

What I'm wondering is what will EA work like after they fail to close position. 

Do you know if the EA fail to close position, will the EA "try to close the position again" or "never take care for the fail close position"? 

"Does EA work different after they fail to close position" or "MT4 will take care of fail cases and all EA works same after they fail to close position"?

Thank you in advance and best wishes,

Sky 

 
Icham Aidibe:

Dear you,

Indeed an operation emitted manually or via an EA can fail due to any reason from bad connectivity to vps memory slowing down due to high activity. 

It's the author responsability to assume those kind of "unexpected" errors which aren't "errors" stricto sensu, I already talked you of in a previous post concerning drawdown (if I remember well ...) 

Sometimes you'll have a VPS with a ping of 10ms, but the order will by moment take 300ms to reach the broker ... it's part of the "game". 

There's a speed race between datas providers everywhere in the world to reduce the latency, there's even a movie on that ... 


Thank you for your continuing support, Icham.

I still can't understand how EA work like after they fail to close position. 

Do you know if the EA fail to close position, will the EA "try to close the position again" or "never take care for the fail close position"? 

"Does EA work different after they fail to close position" or "MT4 will take care of fail cases and all EA works same after they fail to close position"?

Thank you in advance and best wishes,

Sky 

 
Sky L:

Thank you for your continuing support, Icham.

I still can't understand how EA work like after they fail to close position. 

Do you know if the EA fail to close position, will the EA "try to close the position again" or "never take care for the fail close position"? 

"Does EA work different after they fail to close position" or "MT4 will take care of fail cases and all EA works same after they fail to close position"?

Thank you in advance and best wishes,

Sky 

This all depends upon how (well) it's coded.

It will do exactly what you tell it to do.

The server will return an answer that tells the EA whether the request was successful or not.

You can use that to send another request when it failed, or use the error code to find out why it failed.

There can be many reasons.

Then if your EA is coded in a way that it will try to close any positions for as long as the condition exists then it will keep trying to close the position for as long as the condition exists.

If it's coded poorly however this can result in an endless loop of requests and rejects, flooding the trading server with requests and it's possible that the server will disconnect you so you could code it in a way that it will try several times and if it doesn't succeed after that you can have it send a message to your mobile phone telling that something went wrong and so you have to check it out.

 
Marco vd Heijden:

This all depends upon how (well) it's coded.

It will do exactly what you tell it to do.

The server will return an answer that tells the EA whether the request was successful or not.

You can use that to send another request when it failed, or use the error code to find out why it failed.

There can be many reasons.

Then if your EA is coded in a way that it will try to close any positions for as long as the condition exists then it will keep trying to close the position for as long as the condition exists.

If it's coded poorly however this can result in an endless loop of requests and rejects, flooding the trading server with requests and it's possible that the server will disconnect you so you could code it in a way that it will try several times and if it doesn't succeed after that you can have it send a message to your mobile phone telling that something went wrong and so you have to check it out.

Thank you so much, Marco. 

So, about take care of the fail close position, it will depends on EA, but not depends on MT4. 

 
Sky L:

Thank you so much, Marco. 

So, about take care of the fail close position, it will depends on EA, but not depends on MT4. 

Yes that is correct.

But you can set a Trailingstop in MetaTrader manually.

And in that case it will be handled by the Terminal itself.

 
Marco vd Heijden:

Yes that is correct.

But you can set a Trailingstop in MetaTrader manually.

And in that case it will be handled by the Terminal itself.

Thank you, Marco. 

Actually I'm using some EA which designed by professional, and I don't really know how the EA calculate stop, so it might difficult for me to set all of them. 

 
Sky L: Do you know if the EA fail to close position, will the EA "try to close the position again" or "never take care for the fail close position"?
Depends on how it is coded.

EAs must be coded to recover.

If the power fails, OS crashes, terminal or chart is accidentally closed, on the next tick, any static/global ticket variables will have been lost. You will have an open order but don't know it, so the EA will never try to close it, trail SL, etc. How are you going to recover? Use a OrderSelect / Position select loop to recover, or persistent storage (GV+flush or files) of ticket numbers required.

On a network disconnection you might get ERR_NO_RESULT or ERR_TRADE_TIMEOUT. There is nothing to be done, but log the error, return and wait for a reconnection and a new tick. Then reevaluate.