Download MetaTrader 5

IsConnected()

To add comments, please log in or register
qjol
3245
qjol  

Can someone explain to me how IsConnected() can work after int start()

if anything is written after int start() is execute only after a new tick How can the EA get to it at all

thanks

Philippe
201
Philippe  

you can loop into start() to check new tick and...isconnected()

qjol
3245
qjol  
Matutin:

you can loop into start() to check new tick and...isconnected()


But what would help me to loop into start(), if a new tick didn't comes

for example if automaticly i restart the terminal & is no connection than the EA didn't comes to the loop

Nikolay Panev
1119
Nikolay Panev  
qjol:


But what would help me to loop into start(), if a new tick didn't comes

for example if automaticly i restart the terminal & is no connection than the EA didn't comes to the loop

Can help you in a script, not EA.
qjol
3245
qjol  
robofx.org:
Can help you in a script, not EA.

in a EA into init() ?
Nikolay Panev
1119
Nikolay Panev  
qjol:

in a EA into init() ?
Possible.
Viffer
614
Viffer  
qjol
3245
qjol  
robofx.org:
Possible.


sorry after int init() didnt't work i chack it out

#property copyright "Copyright © 2010, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#import "shell32.dll"
int ShellExecuteA(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd);
#import

int init()
  {
   Print ("starting count");
   Sleep(10000);
   Print ("chacking");
   if (!IsConnected())
   {
   Print ("restarting ap in 5 sec");
   Sleep(5000);
   ShellExecuteA(0, "Open", "d:\r_ap.bat", "", "", 1); 
   }

   return(0);
  }

Viffer
614
Viffer  

Expanding on my link above... I run a seperate EA to monitor connection status. It basically has all the code for my test coded inside start with a sleep at the end. Start is basically a big loop, when it finishes, it goes back to the beginning. But rather than wait for a tick to trigger the start, I call start() inside init(). In this way start() continues to loop with the sleep and init() never finishes so the code runs based on time intervals from sleep rather than waiting for a tick... the link above shows the principal...

hth

V

qjol
3245
qjol  
Viffer:

Expanding on my link above... I run a seperate EA to monitor connection status. It basically has all the code for my test coded inside start with a sleep at the end. Start is basically a big loop, when it finishes, it goes back to the beginning. But rather than wait for a tick to trigger the start, I call start() inside init(). In this way start() continues to loop with the sleep and init() never finishes so the code runs based on time intervals from sleep rather than waiting for a tick... the link above shows the principal...

hth

V


thanks
Philippe
201
Philippe  
qjol:


But what would help me to loop into start(), if a new tick didn't comes

for example if automaticly i restart the terminal & is no connection than the EA didn't comes to the loop


Just call start() from init () ...and you will be in start() even no tick coming !
To add comments, please log in or register