Download MetaTrader 5

IsConnected() - page 4

To add comments, please log in or register
qjol
3243
qjol  
7bit:

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
986
bernd  

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.

Phil
134
Phil  
7bit:
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
Moderator
33506
Alain Verleyen  

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
  Symbol=EURUSD
  Period=H4
  Template=popular.tpl
  Expert=
  ExpertParameters=
  Script=CheckConnection
  ScriptParameters=

And lauch terminal with something like :

"...\Metatrader 4\terminal.exe" config\start.ini

Files:
Pavel Soukup
560
Pavel Soukup  

Hi guys,

Do you know any of you, why not work script fake ticks - https://www.mql5.com/en/forum/128803/page2#373539 (page 2) this thread for build 600++?

My OS is Vista. Thank you.

GoS
76
GoS  
endy5:

Hi guys,

Do you know any of you, why not work script fake ticks - https://www.mql5.com/en/forum/128803/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);
suman chatterjee
18
suman chatterjee  

  why is it use 2 and 1 in parameter

PostMessageA(hwnd, msg, 2, 1)
Ex Ovo Omnia
3358
Ex Ovo Omnia  
iamsuman2:

  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