Download MetaTrader 5

Spread recording fail

To add comments, please log in or register
Have you made a screenshot in MetaTrader? Share it with friends!
pontuso5
376
pontuso5 2014.01.07 13:54 

Hi

I use this indicator Spread_Recorder.mq4

http://www.forexfactory.com/showthread.php?t=195290


It has worked perfect with different brokers, but i just opened a new account with another broker and id stops to work.?


I says: invalid filename for FileOpen function

And i allso have created a folder in files/ that is named correctly "Spread_Recording"


Anyone know why?

Files:
Simon Gniadkowski
Moderator
17999
Simon Gniadkowski 2014.01.07 14:06  
pontuso:

Hi

Anyone know why?

Sounds like a UAC issue . . .
pontuso5
376
pontuso5 2014.01.07 14:25  

It works with the same terminal but with DEMO account?


Can my broker block this FileOpen function?

Simon Gniadkowski
Moderator
17999
Simon Gniadkowski 2014.01.07 14:27  
pontuso:

It works with the same terminal but with DEMO account?


Can my broker block this FileOpen function?

Search for UAC on this forum and read . . .
pontuso5
376
pontuso5 2014.01.08 10:29  

Ok so what i understand if i turn off the UAC controls in windows it should work.

But when i do that, i will still get the same error.


And the MT4 is also installed directly in to C:/


Anything else you think it could be?

Simon Gniadkowski
Moderator
17999
Simon Gniadkowski 2014.01.08 10:32  
pontuso:

Ok so what i understand if i turn off the UAC controls in windows it should work.

But when i do that, i will still get the same error.


And the MT4 is also installed directly in to C:/


Anything else you think it could be?

Please copy and paste the error lines from the log file . . . not from the experts tab.
pontuso5
376
pontuso5 2014.01.08 10:48  
11:12:27 Spread_Recorder EURUSD..,H1: loaded successfully
11:12:29 Spread_Recorder: invalid filename for FileOpen function
11:12:29 Spread_Recorder: invalid filename for FileOpen function
11:12:29 Spread_Recorder EURUSD..,H1: initialized
11:12:48 Spread_Recorder: invalid filename for FileOpen function
11:12:48 Spread_Recorder: invalid filename for FileOpen function
11:12:49 Spread_Recorder: invalid filename for FileOpen function
11:12:50 Spread_Recorder EURUSD..,H1: deinitialized
11:12:50 Spread_Recorder EURUSD..,H1: uninit reason 1
11:12:50 Spread_Recorder EURUSD..,H1: removed
Simon Gniadkowski
Moderator
17999
Simon Gniadkowski 2014.01.08 11:05  
pontuso:
11:12:27 Spread_Recorder EURUSD..,H1: loaded successfully
11:12:29 Spread_Recorder: invalid filename for FileOpen function
11:12:29 Spread_Recorder: invalid filename for FileOpen function
11:12:29 Spread_Recorder EURUSD..,H1: initialized
11:12:48 Spread_Recorder: invalid filename for FileOpen function
11:12:48 Spread_Recorder: invalid filename for FileOpen function
11:12:49 Spread_Recorder: invalid filename for FileOpen function
11:12:50 Spread_Recorder EURUSD..,H1: deinitialized
11:12:50 Spread_Recorder EURUSD..,H1: uninit reason 1
11:12:50 Spread_Recorder EURUSD..,H1: removed

Users wonder why I keep going on about checking function return values and reporting errors . . . What filename is invalid ? if the original coder had checked the return value, determined the error and printed the filename we would have a better idea of what was wrong . . .


Please make this addition or try the attached version, marked // added by RaptorUK

void WriteToLogFile(string input)
{
   string filename = "Spread_Recording/"+Symbol()+"-Spread_Recorder-"+Day()+"-"+Month()+"-"+Year()+".log";
   input = TimeHour(TimeCurrent())+":"+TimeMinute(TimeCurrent())+":"+TimeSeconds(TimeCurrent())+" - "+input;
   int handle = FileOpen(filename,FILE_READ|FILE_WRITE);
   if (handle>1)
   {
      FileSeek(handle, 0, SEEK_END); // go to end of file
      FileWrite(handle, input);
      FileClose(handle);
   }
   
   else     //  added by RaptorUK
      {
      Print("FileOpen failed, trying to open: ", filename, " error# ", GetLastError());
      
      }
Simon Gniadkowski
Moderator
17999
Simon Gniadkowski 2014.01.08 11:07  
By the way, if t=you have the file open in another application MT4 may fail trying to open it . . .
pontuso5
376
pontuso5 2014.01.08 11:48  

Ok thanks for the correction!

I get this error. ERR_WRONG_FILE_NAME (4101)

12:38:50 Spread_Recordera_1_: invalid filename for FileOpen function

12:38:50 Spread_Recordera_1_ EURUSD..,H1: FileOpen failed, trying to open: Spread_Recording/EURUSD..-Spread_Recorder-8-1-2014.log error# 4101


I have seen that the demo account symbol name is "EURUSD.m" and the real account symbol is named "EURUSD.." can this might cause the error?

pontuso5
376
pontuso5 2014.01.08 11:48  
RaptorUK:
By the way, if t=you have the file open in another application MT4 may fail trying to open it . . .


And im not having the file open in another application, what i can see.
12
To add comments, please log in or register