Download MetaTrader 5

IsConnected() - page 4

To add comments, please log in or register
qjol 2010.09.27 15:57  

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

bernd 2010.09.27 17:53  

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:

Look for the 4226 event in the windows event log.

Phil 2012.02.04 03:03  
This is the only correct way to force a start() from within init() in an EA. You are not allowed to do this in an indicator since there start() will run in the GUI thread.

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?

Alain Verleyen
Alain Verleyen 2013.01.19 15:06  

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

Pavel Soukup
Pavel Soukup 2015.12.29 11:16  

Hi guys,

Do you know any of you, why not work script fake ticks - (page 2) this thread for build 600++?

My OS is Vista. Thank you.

GoS 2015.12.30 19:13  

Hi guys,

Do you know any of you, why not work script fake ticks - (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);
iamsuman2 2016.10.28 23:47  

  why is it use 2 and 1 in parameter

PostMessageA(hwnd, msg, 2, 1)
Ex Ovo Omnia
Ex Ovo Omnia 2016.10.29 06:03  

  why is it use 2 and 1 in parameter

It is out of scope of MQL, chet the function here

To add comments, please log in or register