Meaning of function IsTradeAllowed()

 

Hi,

I have written an ea which has the following code-lines in his start function:

  if(IsTradeAllowed()==false) 
      {
         Alert("You have to activate your ea first or there is a disconnection between the server connection!");
         return;
      }

Now it is sometimes the problem, that I get this error-Message before I want to open or close a trade with that ea.

The ea is activated and the internet connection exists.

How could this happen?!?!!

 

Did you read the documentation ? I guess you will answer . . "Yes of course I did ! ! " so why aren't you checking to see if the trade context is busy ?

IsTradeAllowed "Returns TRUE if the expert is allowed to trade and a thread for trading is not occupied, otherwise returns FALSE."

 

Thank you very much!!

Can you tell me in what situations a thread for trading is not occupied?!

Do you think I should delete this function from my EA because it makes more bad than good?

 
sunshineh:

Thank you very much!!

Can you tell me in what situations a thread for trading is not occupied?!

When it's not being used . . . have a read of this article it will help: Trade Context Busy

Of course it might just be that thou have a lousy Broker, check the Journal (if you are running live or Demo) to see if you have many Login messages or DataCenter connecting failed [2] or connect failed [No connection]


Reason: