TESTER not reflects DEMO usage...

 

Hi,

I'm facing really weird problems with a client of my EA. Let me explain:

1- Camarilla PIVOT:

I can run Strategy Tester without any problem using this resource (see attached source) for entire year... but when using in DEMO (realtime DEMO account), the EA reports "Cannot get Array for PIVOT BUFFER" (in real, the error 4807 - Invalid Handler). How can the Indicator run for hours in DEMO and suddenly raise this error?  And why does not this error raise in TESTER mode for months?


2- Custom LOG name

I'm using a custom LOG file to set some messages. This file is created in the default location (C:\Users\...\AppData\Roaming\MetaQuotes\Tester\...\Agent-127.0.0.1-3000\MQL5\Files) but I'm using a custom name to separate the LOG of each pair.  My code is:

    string HOJE = TimeToString(TimeCurrent(), TIME_DATE);
    LogFile = _Symbol + "." + HOJE + "_log.txt";

which results in something like "USDGBP.2020.10.12_log.txt" . In TESTER mode I get all files without any problem, but, when running in DEMO mode, I receive "ERROR OPENING LOG FILE" , which means "Inalid Handle".

The code to write each LOG file is


void Write_to_Log(string mensagem)
{

   if(Write2Log == true)
     {
       string Linha = TimeToString(TimeCurrent())  + " > " + mensagem;
    
       LogFile_Handle=FileOpen(LogFile,FILE_READ|FILE_WRITE|FILE_UNICODE|FILE_TXT);
       if(LogFile_Handle==INVALID_HANDLE){
          Alert("Error opening LOG-FILE");
          return;
       }
       FileSeek(LogFile_Handle,0,SEEK_END);
       FileWrite(LogFile_Handle, Linha);
       FileClose(LogFile_Handle);
     }


}


So, do you know WHY am I getting different behaviours between TESTER and DEMO mode?

I tried DEMO in FBS and ICM Brokers with the same results.

I appreciate for any help.

The Fundamentals of Testing in MetaTrader 5
The Fundamentals of Testing in MetaTrader 5
  • www.mql5.com
The idea of ​​automated trading is appealing by the fact that the trading robot can work non-stop for 24 hours a day, seven days a week. The robot does not get tired, doubtful or scared, it's is totally free from any psychological problems. It is sufficient enough to clearly formalize the trading rules and implement them in the algorithms, and...
Files: