How do MT4 EAs handle trade errors?

 

I've read a lot about re-quotes and failed orders with different brokers, but I'm wondering how these are handled by EAs in MT4... if a price quote is outside the specified slippage will it just keep trying until it gets the price it wants, or will the trade be abandoned? What if the order is rejected for some server glitch or other... does MT4 keep trying to get the order accepted?

Many EAs rely on being able to place, modify or close a position when the proper time comes, and it seems to me it would be a disaster if it just bails out under error conditions. I'm just wondering if some EA guru could explain just how these situations get handled...

THX.

Edit/Delete Message

 

I feel the trade will just be abandoned... I am not sure if "looping" helps in this case... But, even you try to loop it... The next question is to loop for how many tries... Don't forget the time is clicking and the next tick is coming too... Perhaps, if it failed, then just wait for the next trade... Don't forget, there is always the next chance to make profits!

 
Baiwan:
I feel the trade will just be abandoned... I am not sure if "looping" helps in this case... But, even you try to loop it... The next question is to loop for how many tries... Don't forget the time is clicking and the next tick is coming too... Perhaps, if it failed, then just wait for the next trade... Don't forget, there is always the next chance to make profits!

It is quite simple - you can acces errors with GetLastError() function, check it's code and make a choice what to do (eg, try to send order again, or mabye call RefreshRates before you send order again), You can also use while loop - so the ea will try to place the order until it will place it on the server, of course you can make maxretries param to avoid metatrader crash.

 
Kalenzo:
It is quite simple - you can acces errors with GetLastError() function, check it's code and make a choice what to do (eg, try to send order again, or mabye call RefreshRates before you send order again), You can also use while loop - so the ea will try to place the order until it will place it on the server, of course you can make maxretries param to avoid metatrader crash.

Brilliant!

 

Help critical error: mt4 keeps crashing

I have been running every demo I have in MT4 and they are all crashing. What is this error and what do I need to do to prevent it?

There has been a critical error

Time : 2008.02.21 22:31

Program : Client Terminal

Version : 4.00 (build: 211, 15 Oct 2007)

Owner : AleccohFx (AleccohFx)

OS : Windows XP Professional 5.1 Service Pack 2 (Build 2600)

Processors : 2, type 586, level 15

Memory : 1039532/595384 kb

Exception : C0000005

Address : 004614F7

Access Type : read

Access Addr : B27FCE51

Registers : EAX=0275F818 CS=001b EIP=004614F7 EFLGS=00010206

: EBX=00000000 SS=0023 ESP=00125C1C EBP=00125C54

: ECX=B27FCE51 DS=0023 ESI=0045E27C FS=003b

: EDX=000000CB ES=0023 EDI=0276A774 GS=0000

Stack Trace : 00453B1E 00000000 00000000 00000000

: 00000000 00000000 00000000 00000000

: 00000000 00000000 00000000 00000000

: 00000000 00000000 00000000 00000000

Modules :

1 : 00400000 007D3000 F:\Program Files\AleccohFX\terminal.exe

2 : 20000000 002C5000 C:\WINDOWS\system32\xpsp2res.dll

3 : 5AD70000 00038000 C:\WINDOWS\system32\UxTheme.dll

4 : 5B860000 00055000 C:\WINDOWS\system32\NETAPI32.dll

5 : 5FD00000 0000D000 C:\WINDOWS\system32\MFC42LOC.DLL

6 : 629C0000 00009000 C:\WINDOWS\system32\LPK.DLL

7 : 6F000000 00063000 C:\WINDOWS\SYSTEM32\SYSFER.DLL

8 : 71AA0000 00008000 C:\WINDOWS\system32\WS2HELP.dll

9 : 71AB0000 00017000 C:\WINDOWS\system32\WS2_32.dll

10 : 73DD0000 000FE000 C:\WINDOWS\system32\MFC42.DLL

11 : 74720000 0004C000 C:\WINDOWS\system32\MSCTF.dll

12 : 74D90000 0006B000 C:\WINDOWS\system32\USP10.dll

13 : 755C0000 0002E000 C:\WINDOWS\system32\msctfime.ime

14 : 76380000 00005000 C:\WINDOWS\system32\MSIMG32.dll

15 : 76390000 0001D000 C:\WINDOWS\system32\IMM32.DLL

16 : 763B0000 00049000 C:\WINDOWS\system32\comdlg32.dll

17 : 76B40000 0002D000 C:\WINDOWS\system32\WINMM.dll

18 : 77120000 0008C000 C:\WINDOWS\system32\OLEAUT32.dll

19 : 773D0000 00103000 C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2982_x-ww_ac3f9c03\comctl32.dll

20 : 774E0000 0013D000 C:\WINDOWS\system32\ole32.dll

21 : 77C10000 00058000 C:\WINDOWS\system32\msvcrt.dll

22 : 77DD0000 0009B000 C:\WINDOWS\system32\ADVAPI32.dll

23 : 77E70000 00091000 C:\WINDOWS\system32\RPCRT4.dll

24 : 77F10000 00047000 C:\WINDOWS\system32\GDI32.dll

25 : 77F60000 00076000 C:\WINDOWS\system32\SHLWAPI.dll

26 : 7C800000 000F5000 C:\WINDOWS\system32\kernel32.dll

27 : 7C900000 000B0000 C:\WINDOWS\system32\ntdll.dll

28 : 7C9C0000 00816000 C:\WINDOWS\system32\SHELL32.dll

29 : 7E410000 00091000 C:\WINDOWS\system32\USER32.DLL

Call stack :

0045E200:32F7 [004614F7] ?ExecuteStaticAsm@CExpertInterior

00453980:019E [00453B1E] ?InitFunctionInt@CExpertInterior

 
 

I see the dll now. Its a skin for creating an ubuntu theme. How do you reccomend wiping its path? Can I just delete that dll or will it leave traces everywhere and cause more problems?

 

i loop 5 times with 200 millisecond sleep(). you dont want to catch the price too far away from where you wanted it.

 
 

I find the best way to handle these types of errors is to intrinsically code the retry into the EA logic, by this I mean instead of looping around a million times just check the number of open trades on the next tick (call to start), if the trade did not process for some reason there will be no open trades and it's time to try again. If you have trade signals which only last one tick, your probably going to have other problems.

 

FSC? I googled this and nothing, please give me the full name of the process..

Reason: