checking connection in expert

 

hello

I had developed an EA for some customers. then, some of them claimed that when this EA is running on one chart(say EURUSD), it has long lags for executing commands on another symbol (say GBPJPY). they are correct becasue tick intervals of the two symbols is different.

So, I decided toi put every thing in a loop wiith sleepin interval of 5 seconds, then regardless of tick, command is executed on 5sec intervals. There is no problem now, but I want to check if connection with server is ok when trading command is executed.

I'm doing like this now:

int start()
{
while (true)
{
AccountFreeMarginCheck( "EURUSD", OP_BUY, 0.01);
int i=GetLastError();
while(i==134)
{
Sleep(10000);
AccountFreeMarginCheck("EURUSD", OP_BUY, 0.01);
i=GetLastError();
}
Do();
Sleep(2500);
}
return(0);
}

but I'm not sure is this the correct way? for example some brokers don't accept 0.01 lot. could you please advice?

Regards

 
AR78 wrote >>

hello

I had developed an EA for some customers. then, some of them claimed that when this EA is running on one chart(say EURUSD), it has long lags for executing commands on another symbol (say GBPJPY). they are correct becasue tick intervals of the two symbols is different.

So, I decided toi put every thing in a loop wiith sleepin interval of 5 seconds, then regardless of tick, command is executed on 5sec intervals. There is no problem now, but I want to check if connection with server is ok when trading command is executed.

I'm doing like this now:

int start()
{
while (true)
{
AccountFreeMarginCheck( "EURUSD", OP_BUY, 0.01);
int i=GetLastError();
while(i==134)
{
Sleep(10000);
AccountFreeMarginCheck("EURUSD", OP_BUY, 0.01);
i=GetLastError();
}
Do();
Sleep(2500);
}
return(0);
}

but I'm not sure is this the correct way? for example some brokers don't accept 0.01 lot. could you please advice?

Regards

You can use the function MarketInfo() with MODE_MINLOT to retrieve the information of min lots of your brokers.

 

Thanks,

I'm not sure if this technic is good for checking connection, Is this whole checked inside of client terminal or in server? Could you please confirm? or any better Idea which I can make sure server is answering or not answering?

regards

Reason: