@Slawa: Multiple instances of MT4

 
Slawa, how does MT4 determine that another instance is already running?

When in a Windows session, if you try to run another instance of terminal.exe from the same directory, it activates the first instance and terminates the second. This is fine, no problem - that's how it should work.

However, I have written a utility to start multiple terminal.exe instances (in different directories) when Windows Server 2003 VPS starts up (before user login). From watching the startup processes (from my VPS manager console), it appears that, even though the terminal.exe executables are in different directories, they are starting up then shutting down, almost like they think they are running from the same directory. As a result, only 2 or 3 instances end up running, even though I'm trying to start 10.

This exact same startup process/utility works fine once I'm logged into Windows (I get all 10 sessions), but it doesn't work on system startup before login.

Ideas?
 
This problem is known. You need for some delay (about 3-5 seconds) between instances launch.
 
Here is what I figured out in connection with this:
I wanted to run MT4s at VPS startup, before logging in but in the name of a user, it all terminated.
Now, if I run a Win32 application (notepad, or calculator) before MT4, wait some seconds, and after this, MT4s stay on in the background, working fine.
This situation was the same on two different VPS systems (both were running Server2003 though)
 
THANK YOU!

So, did you have to run the Win32 app before *each* MT4 session, or just before the first one? And, can you kill the Win32 app at the end?

Again, thanks alot. I'm going to try that.

Alan
 
Zap:

I still cannot get this to work. I have 10 MT4 sessions I want to start when the VPS reboots (which it does too often :P). Here is what I'm doing:

1. My start-up managing application is a Scheduled Task set to run on system startup
2. Restart VPS.
3. After Virtuozzo status reaches "Running", my managing app starts.
4. Then, every 60 seconds, the app starts notepad.exe, waits 10 seconds, then starts an MT4 session. I leave the notepad.exe processes running.
5. the first two MT4 sessions start fine, but for the 3rd and subsequent, I see them show up in the Processes list for about 3 seconds, then they disappear.

How did you get this to work? Help is greatly appreciated because the VPS reboots without warning, halting all MT4 sessions. Grrr.

Thanks!
Alan
 
Ok, here is what I do (also for VPS restarts):

-I have a batch file named c:\start.bat, containing:

start calc.exe
timeout /T 3 /NOBREAK
start c:\MT4-live\terminal.exe
timeout /T 3 /NOBREAK
start c:\MT4-demo\terminal.exe
timeout /T 3 /NOBREAK
start c:\MT4-demo2\terminal.exe

(you can write this in notepad)

-At Scheduled Task I have scheduled to run c:\start.bat at system startup under a different administrator account. (I guess admin is needed) eg. MT-RESTARTED with high-level password.

Result: when you log on via RDP with user MT-ADMIN, you won't see anything running, but when checkin running processes, you will see these on the list:
calc.exe MT-RESTARTED
terminal.exe MT-RESTARTED
terminal.exe MT-RESTARTED
terminal.exe MT-RESTARTED

This means these are running in the background, without grapichal interface, but as I experienced without any problems. Now if I need GUI, I close all of these instances and start them again under MT-ADMIN. Always make sure that only one instance is running, otherwise you'll get duplicated trades.

AND! Look for a better VPS provider, the better ones shouldn't restart but once in three/four months.
 
I have another solution which doesn't require having additional programs like calc.exe stuck running in the background. I wrote a very simple program named sleep.exe. The program has only one purpose and that is to wait one minute and then close itself.

I wrote a batch file (metatrader.bat) can be launched at startup, it waits 4 minutes while the computer or VPS is launching all of its startup programs. Then it opens the first MT4 terminal, waits a minute and then opens the second MT4 terminal. It repeats the process until all the terminals are up and running. Then the Command prompt window that the batch file and sleep.exe was running in is closed using the exit command.


cls


ECHO ON
REM Please wait, attempting to start Metatrader Program...


cd\
sleep
sleep
sleep
sleep
cd program files
cd Interbank FX Trader 4
start terminal

cd\

sleep
cd program files
cd Interbank FX Trader 4 Mini
start terminal

cd\

sleep
cd program files
cd Interbank FX Trader 4 Demo
start terminal

cd\

sleep
cd program files
cd MetaTrader Championship
start terminal


ECHO OFF
exit




The metatrader.bat batch file can be downloaded from http://www.glennbacon.com/files/metatrader.bat
The sleep.exe program can be downloaded from http://www.glennbacon.com/files/sleep.exe

To use the two files on your Windows computer save the files to c:\ . After you save the files to c:\ edit the metatrader.bat file by right clicking on the file and choose 'Open with' and select Notepad as the program to edit the file (after you choose Notepad to edit the file in the future you can just right click on the file and then click on Edit). Change 'Interbank FX Trader 4' to the directory name of where your terminal was installed. For example if you installed Alpari MT4 terminal in its default directory, you would need to change 'Interbank FX Trader 4' to 'MetaTrader - Alpari UK' (without the quotes).

How to launch the metatrader.bat at startup. Right click on the metatrader.bat file and then click on Create Shortcut. You should now have a new file named metatrader - Shortcut. Next we want to cut and paste our metatrader - Shortcut file to our Startup folder. This can be down by clicking on Start -> Programs (if Vista, All Programs) and right click on Startup and choose Open or Explore. Now you can cut and paste metatrader - Shortcut file to the Startup folder.

Now whenever your computer restarts it will automatically launch each MT4 terminal.




 
Thanks Robinhood, but I need clarification:

Does this start the MT4 sessions before you log into your VPS? I can get all 10 of them to start no problem after login (with pauses in between, etc).

What I need is the MT4 sessions to start without needing to login to the VPS. The problem is when the VPS reboots and I'm not around. The system will stay at the login screen until I actually sign in. Only THEN does the Startup folder get executed. I can't afford that loss of time. I know how to run things before the login, but the MT4 sessions aren't starting properly. 2 or 3 open and the rest open and close immediately.
 
Perhaps the company that is hosting your VPS can help you with having it automatically log you in when it restarts or maybe someone on the forum can answer this question better than me because I am not currently using a VPS to run my terminals.


Thanks Robinhood, but I need clarification:

Does this start the MT4 sessions before you log into your VPS? I can get all 10 of them to start no problem after login (with pauses in between, etc).

What I need is the MT4 sessions to start without needing to login to the VPS. The problem is when the VPS reboots and I'm not around. The system will stay at the login screen until I actually sign in. Only THEN does the Startup folder get executed. I can't afford that loss of time. I know how to run things before the login, but the MT4 sessions aren't starting properly. 2 or 3 open and the rest open and close immediately.


Reason: