Is any one know how to synchronise the trades on every tick!!!

 

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 

 

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.
 
get symbol name of open position and compare with symbol on chart.
 
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. 

 
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 ,