login to an account using EA - page 3

 

MetaTrader enables logging into many accounts.

 
Tomac1:
I have 49 instances of MetaTrader at VPS and its very hard for it. There are no possible to open more than fifty MetaTraders.

Why? Reduce max bars on chart, and have the terminal restart once per day.

  1. Schedule reboot once per day. "shutdown -r -t 5"
  2. or have each terminal restart periodically.
    untested
    #define HR2400          86400                   // 24 * 3600
    datetime TimeOfDay(datetime when){  return( when % HR2400          );       }
    datetime DateOfDay(datetime when){  return( when - TimeOfDay(when) );       }
    datetime lastRestart;
    int init(){ lastRestart = TimeCurrent(); ... }
    int start(){
       :
       if (TimeCurrent() - lastRestart > HR2400) RestartTerminal();
    }
    bool restartTerminal(){
        if (!Shell("cmd.exe"," /C restartTerminal.bat")) return(false);
        return(CloseTerminal());
    }
    #include <WinUser32.mqh>
    #import "user32.dll"
      int GetAncestor(int, int);
    #import
     bool Shell(string file, string parameters=""){
        #define DEFDIRECTORY NULL
        #define OPERATION "open"    // or print
        #define SW_SHOWNORMAL       1
        int r=ShellExecuteA(0, OPERATION, file, parameters, DEFDIRECTORY, SW_SHOWNORMAL);
        if (r <= 32){   Alert("Shell failed: ", r); return(false);  }
        return(true);
    }
    bool CloseTerminal() { // https://forum.mql4.com/32327#324911
        if (IsStopped()) return(false);         // https://forum.mql4.com/32837 WH-DL
        int main = GetAncestor(WindowHandle(Symbol(), Period()), 2);//GA_ROOT
        PostMessageA(main, WM_CLOSE,0,0);
        return(true);
    }
    /* restartTerminal.bat
    @echo off
    set term="%ProgramFiles(x86)%\Interbank FX Trader 4\terminal.exe"
    set seconds=10& rem Wait until terminal exits
    ping -n %seconds% localhost >nul||exit/b 1
    start "terminal" %term%
    */
    Untested
 
WHRoeder:

Why? Reduce max bars on chart, and have the terminal restart once per day.

  1. Schedule reboot once per day. "shutdown -r -t 5"
  2. or have each terminal restart periodically.
    untested
    Untested
Yes, thank you for code. Its good idea but Im missing auto login with switching the users.
 

Is there something like this available in mql5?
And/or how can I use winuser32 in mql5?



Mykola Bilak:

found here - https://forum.mql4.com/ru/10784

script for subsequent logins to accounts in Favorites tab of Naviagator window of MT4


you should modify the code to your needs


Поместите нужные вам торговые счета (можно разных ДЦ) в закладку Избранное окна Навигатор.

Запустите скрипт, указав количество торговых счетов в закладке Избранное окна Навигатор.


Примечание: работе скрипта не мешают гуляние по окнам (настройки терминала, свойства графика, архив котировок и т.д.) и присутствие нескольких запущенных терминалов.

Reason: