Download MetaTrader 5
To add comments, please log in or register
How to buy a product in MetaTrader AppStore? Read the article!
Xiaoshen Li
31
Xiaoshen Li 2011.08.26 03:34 

Dear All:

In MetaTrader 4 platform, in the terminal tab "expert", all the messages are also automatically saved in expert/logs/20110825.log (suppose today is 2011-08-25). But recently, I found that is not the case any more: the new messages which show up in termianl tab "expert" are not appended to the 20110825.log file automatically.

If I right mouse click those messages in "expert" tab and select "Open", the Windows Explorer will open. Now, 20110825.log content was updated and contains all the newest messages. In another words, each time new message shows up in "expert" tab, I need to right click the mouse and select "Open" to have the new message appended to the log file. If I don't do that, the log file will not automatically have the new message appended. I am very confused.

By the way, I use Cygwin to go to the directory expert/logs and find and read the log file. The Windows Explorer shows logs/ as empty. -- second mystery.

Thank you very much.

whroeder1
13641
whroeder1 2011.08.26 06:16  
xsli2:
I am very confused.

The normal complaint is that some lines are missing in the journal. They are all in the file, just skipped in the journal tab when written too fast.

Missing lines in the file is usually because you installed in \program files* on Vista/Win7

Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2011.08.26 09:28  
I have found that the logs are not updated line by line, sometimes the only way I can get the log complete is to exit MT4, it then flushes the rest of the entries and completes the log.
Xiaoshen Li
31
Xiaoshen Li 2011.08.27 00:05  

Thank you for your reply. I believe it has to do files/folder permission, User Account Control. One way to fix it is to install MT4 not at the default location(C:/Program Files (x86)/), since User Account Control will affects it, instead install MT4 at, e.g. C:/MT4/

I will give a shot today.

This link has several solutions to solve this problem:

http://4xtrader.net/how-to-run-metatrader-on-windows-7-or-vista/

whroeder1
13641
whroeder1 2011.08.27 16:32  
Tamas Csabina
25
Tamas Csabina 2013.09.02 22:55  

Hi,

Sorry to bring this old topic up, but I just faced the same problem: the log files are not updated, just like the original poster explained.

My setup:

Win7x64bit.

I have MetaTrader4 installed on a different (non-system) partition, where every user have write rights.

I have UAC completely disabled.

Still, the logfile is only being updated with the 'contents' of the Experts tab, if I right-click and select Open.



Please advice what to do.

Tamas Csabina
25
Tamas Csabina 2013.09.03 20:54  

Hi,

As a workaround I came up with the idea of an EA, that executes a small script during every newbar creation. And this script is opening and closing the Logfiles locations, which action is updating the contents of the logfiles.

All source codes that I have used are from this forum. I hope the original posters doesn't mind if don't include a link to their posts...

//+------------------------------------------------------------------+
//|                                                   LogUpdater.mq4 |
//|                        Copyright 2013, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#include <WinUser32.mqh>
#import "user32.dll"
  int GetAncestor(int hWnd, int gaFlags);
#import
//+------------------------------------------------------------------+

#define MAX 9
//+------------------------------------------------------------------+

int curIndex;
datetime times[MAX];
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init() {
    curIndex = utils.periodToPeriodIndex(Period());
    times[curIndex] = Time[0];
    for(int i=curIndex+1; i<MAX; i++)
        times[i] = times[curIndex]- MathMod(times[curIndex], utils.periodIndexToPeriod(i)*60);

    return(0);
}

//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit() {
    return(0);
}

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start() {
    if (times[curIndex] != Time[0]) {
        times[curIndex] = Time[0];
        onBar(Period());
        for (int i=curIndex+1; i<MAX; i++) {
            int period = utils.periodIndexToPeriod(i),
            seconds = period*60,
            time0 = times[curIndex] - MathMod(times[curIndex], seconds);
            if (times[i] != time0) {
                times[i] = time0;
                onBar(period);
            }
        }
    }

    onTick();

    return(0);
}
//+------------------------------------------------------------------+

int utils.periodToPeriodIndex(int period) {
    switch(period) {
        case PERIOD_M1  : return(0); break;
        case PERIOD_M5  : return(1); break;
        case PERIOD_M15 : return(2); break;
        case PERIOD_M30 : return(3); break;
        case PERIOD_H1  : return(4); break;
        case PERIOD_H4  : return(5); break;
        case PERIOD_D1  : return(6); break;
        case 20         : return(7); break;
        case 55         : return(8); break;
  }
}
//+------------------------------------------------------------------+

int utils.periodIndexToPeriod(int index) {
    switch(index) {
        case 0: return(PERIOD_M1); break;
        case 1: return(PERIOD_M5); break;
        case 2: return(PERIOD_M15); break;
        case 3: return(PERIOD_M30); break;
        case 4: return(PERIOD_H1); break;
        case 5: return(PERIOD_H4); break;
        case 6: return(PERIOD_D1); break;
        case 7: return(20); break;
        case 8: return(55); break;
  }
}
//+------------------------------------------------------------------+

void onTick() {
//    Print("onTick() is called.");
}
//+------------------------------------------------------------------+

void onBar(int period) {
//    Print("onBar() is called with period: " + period);
    int hwnd = GetAncestor(WindowHandle(Symbol(), Period()), 2); // find the Terminal handle no.

    PostMessageA(hwnd, WM_COMMAND , 33101, 0);                   // open the folder contains the log files
     
    while (FindIfDirOpened() == 0) {                             // check if the folder opened
       Sleep(100);
       FindIfDirOpened();
    }

    PostMessageA(FindIfDirOpened(), WM_CLOSE, 0, 0);             //close the folder
}
//+------------------------------------------------------------------+

int FindIfDirOpened() {
    string log = "logs";
    string i;
    int handle = FindWindowA(i, log);

    return(handle);
}
//+------------------------------------------------------------------+
adrian benavides
135
adrian benavides 2013.12.09 21:44  

can anyone explain me what this means: PostMessageA(hwnd, WM_COMMAND, 33101, 0); // open the folder contains the log files

with that values, it only opens de Journal log file, what about de experts log? what is the function of 33101 number?

whroeder1
13641
whroeder1 2013.12.10 01:33  
/
To add comments, please log in or register