Download MetaTrader 5
To add comments, please log in or register
Join MQL5 Cloud Network. Improve your rating!
Jitendra Parmar
1093
Jitendra Parmar 2012.10.08 19:22 

Hello All ,

 I am Jeet , I need to synchronise the trades  ,  I have my EA running on 4 to 5 currency pair , I want only one pair can trade at a time ,

my condition is if any pair let say EUR USD is open in position , no other Symbol should open trade containing EUR or USD in it .

Synchronization come into picture when no trade is open , and two currency pair generates the signal for trade ,  They sees that no trade is open and not any trade is with same symbol of currency as that of itself.

 any one know how to achieve synchronisation in trades.

 regards

 Jeet 

graziani
1953
graziani 2012.10.08 21:01  

Multithread environment is usually controlled by methods from POSIX library, which offers synchronization mechanisms for threads consisting of signals, pipes and semaphores.
Check if MQL5 is offering methods for such control. 

If not,  you can do it in a quiet simple way. You will use a exclusive access to a file  as a 'semaphore': 

while (FOREVER)
{	Try Open a file in exclusive way (no one else cant open it while it is opened);
	if (file opened)
	{	if (there are no active positions)
			open position;
		close file;
		break;
	}
}
Of course, instead of opening a file, you can write a semaphore by your self. If you don't want to spend additional time researching, file open is the easiest way.
Jinsong Zhang
15564
Jinsong Zhang 2012.10.09 05:26  
get symbol name of open position and compare with symbol on chart.
Jitendra Parmar
1093
Jitendra Parmar 2012.10.10 18:06  
graziani:

Multithread environment is usually controlled by methods from POSIX library, which offers synchronization mechanisms for threads consisting of signals, pipes and semaphores.
Check if MQL5 is offering methods for such control. 

If not,  you can do it in a quiet simple way. You will use a exclusive access to a file  as a 'semaphore': 

Of course, instead of opening a file, you can write a semaphore by your self. If you don't want to spend additional time researching, file open is the easiest way.

 thanks graziani ,

  I am not getting how to achieve this with 4 EAs running simultaneously on different chart and same terminal.... and each EA is generating signals for trade  independently ..... 

 please make it more clear. 

Jitendra Parmar
1093
Jitendra Parmar 2012.10.10 18:08  
song_song:
get symbol name of open position and compare with symbol on chart.

  song_song thanks,

  but  what I am trying to achieve is to synchronize of the trade not taken , 

   

 

/
To add comments, please log in or register