Script to close all trades according to different terminal

Hi,

I have two different accounts, each with different broker setup in different terminals.

Traded on account A are not copied or related to account B.

I need a script that will sync a close positions between them.

E.g. if on account A all positions were closed (manually, or by EA or by broker) than script will close all positions on account B.
Also, if on account B all positions were closed (manually, or by EA or by broker) than script will close all positions on account A.

Again, i dont need a trade copier, but a sync close script.

Anyone can help with this, maybe there is an existing MT4 script?