It can be checked, just run the check in an infinite loop. how to start this loop when starting the terminal during a connection outage is a completely separate problem. Once you got your loop running it will do what is expected.
Your problem has nothing to do with the IsConnected() function. With the same argument you could also complain about Print() or Alert() or any other function that you cannot call because you could not start the entire code in the first place because of some completely different reason.
ok, Let me explain something Because I'm useing a lot Terminlas All along my cpu useage is rising up to 100 prcent that is why i need to turn off a few terminals
And when I turn them on (of course automatic) I saw a few times that they are not connected & the EA was running on them did not report that there is no connection,
that is y i started this topic & so far the only way that i found is like i said above whit an external program
Maybe it is related to the "feature" that was first introduced with Windows XP SP2 that it refuses to have more than only a handful of half-open connections at any time, mainly to annoy people who want to use networking intensive applications. AFAIK there exist methods to patch this annoying "feature" away and restore normal operability: http://blog.davidkaspar.com/archives/2005/04/windows-xp-sp2-and-event-id-4226.php
Look for the 4226 event in the windows event log.
This is nice but it doesn't always work because the tick may be gone even before initi() has returned, in which case the tick is discarded. To highlight this, if you add a 5ms pause after
PostMessageA(hwnd, msg, 2, 1); // enqueue a fake tick and let init() return
then start() will not be executed.
Is there a better solution to have start() execute on load of the expert advisor without requiring a real tick from the broker?
I little old but looking for a solution to the same problem I got on this topic.
In fact, assertion of qjol that "the only way to do this is whit a script; the problem is that there is no way to open the terminal with a script Loaded" is partially true. With a script ok, but there is a way to start a script with client terminal. This is documented in metatrader help (F1, Tools, Configuration at Startup). May be it's not same at the time of this topic was started.
So I developped a little script to do the job. Use this with a startup script, example :
; open chart and run expert and/or script
And lauch terminal with something like :
"...\Metatrader 4\terminal.exe" config\start.ini
Do you know any of you, why not work script fake ticks - https://forum.mql4.com/35406/page2#373539 (page 2) this thread for build 600++?
My OS is Vista. Thank you.
Since build > 600 you have to replace "A" for ansi with "W" for unicode
int PostMessageA(int hWnd,int Msg,int wParam,int lParam);
int RegisterWindowMessageA(string lpString);
To add comments, please log in or register