View Single Post
  #6 (permalink)  
Old 11-03-2005, 01:36 PM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Arrow

Quote:
Originally Posted by newdigital
What are the GlobalVariableCheck, GlobalVariableSet, GlobalVariableGet, GlobalVariableDel and GlobalVariableDeleteAll.

In which cases we are using that?
GlobalVariables are a special kind of variables which accessed in the MetaTrader client terminal level, so they are different form the global variables which you declare them in your code at the functions level (review the Scope section in Variables lesson).

I'll give you example of using GlobalVariables , Assume you have 2 EAs running in your client terminal and both of them want to Send Order (OrderSend() function), if they called the OrderSend() at the same time MetaTrader will raise an error, to solve this situation , you may write in your EAs a code like that:


while (GlobalVariableCheck("InTrade")) {
Sleep(1000);
}

GlobalVariableSet("InTrade", 1); // set lock indicator
res= OrderSend(....);
GlobalVariableDel("InTrade"); // clear lock indicator

Here the OrderSend() function will work only if the GlobalVariable InTrade has been set.
Note: You have to write this code in the both of the 2 EAs which are trading at the same time.

This is something called semaphore and it's an example of using GlobalVariables.
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Reply With Quote