TESTER delets import Files

 

Dear all

I have a General question. I wrote an EA which loads a File during the initialization and checks every hour the File again. It works normaly, but if I start the EA in the StrategyTester, the tester deletes all Files in the folder without reading them. Does somebody know why? 

It is an .txt file which is stored in the MQL5\Files Folder

I use the function FileOpen

 

It just not works on Tester! 

 

Thanks in advance

 

Simon 

 
1531691:

Dear all

I have a General question. I wrote an EA which loads a File during the initialization and checks every hour the File again. It works normaly, but if I start the EA in the StrategyTester, the tester deletes all Files in the folder without reading them. Does somebody know why? 

It is an .txt file which is stored in the MQL5\Files Folder

I use the function FileOpen

 

It just not works on Tester! ...

Did you use #property tester_file ?

All (not yet) about Strategy Tester, Optimization and Cloud
All (not yet) about Strategy Tester, Optimization and Cloud
  • www.mql5.com
How ticks are generated : The Algorithm of Ticks’ Generation.
 
angevoyageur:

Did you use #property tester_file ?

Hmmmm... Not yet ;-)

I'll check it out. 
Tanks so far!
 
angevoyageur:

Did you use #property tester_file ?

1531691:
Hmmmm... Not yet ;-)
I'll check it out. 

Tanks so far!

 

So I' tried... the Tester doesn't delete anymore my files... but he can't open it. I'ts really strange because in normal mode it opens, reads and works with it, but in Testert nothing at all works!

I'm using now #property_file, I stored all data files in the Common Folder...

  

 

 

 
1531691:

Please don't answer inside the quote.

It should work. Maybe there is a problem with your code. Can you post some code to reproduce your issue ?

 

Ok... it's quite a lot of code... so i will just post the readfunction

//+------------------------------------------------------------------+
//| Read File                                                        |
//+------------------------------------------------------------------+     
string CNewsTradeConditions::ReadFile()
   {
   //Print("Hallo");
      ArrayResize(EURCHF, 100);
      ArrayResize(EURGBP, 100);
      ArrayResize(EURJPY, 100);
      ArrayResize(EURUSD, 100);
      ArrayResize(CHFJPY, 100);
      ArrayResize(GBPJPY, 100);
      ArrayResize(GBPUSD, 100);
      ArrayResize(USDCHF, 100);
      ArrayResize(USDJPY, 100);   
      ArrayResize(AUDUSD, 100);
      ArrayResize(USDCAD, 100);
      ArrayResize(NZDUSD, 100);
       
      pCountEURCHF=0; pCountEURGBP=0; pCountEURJPY=0; pCountEURUSD=0; pCountCHFJPY=0; pCountGBPJPY=0; pCountGBPUSD=0; pCountUSDCHF=0; pCountUSDJPY=0; pCountAUDUSD=0; pCountUSDCAD=0; pCountNZDUSD=0;
      for(int i = 0; i < 50; i++)
         {
            pLabel = "News "+i;
            ObjectDelete(0,pLabel);
            pLabel = "VLINE_News" + pNewsNumber;
            ObjectDelete(0, pLabel);
         }
      //--- Set Variables
      pNewsNumber = 0;
      pCountNews = 0;
      pCountReleases = 0;
      string pFileName;
      pX = 1;
      MqlDateTime pToday;
      TimeCurrent(pToday);
      pImportFile = "News_"+IntegerToString(pToday.year,4)+IntegerToString(pToday.mon,2)+IntegerToString(pToday.day,2)+".txt";
      #property tester_file "News_"+IntegerToString(pToday.year,4)+IntegerToString(pToday.mon,2)+IntegerToString(pToday.day,2)+".txt"
      for(int i = 0; i < 14; i ++)
         {
            if(StringGetCharacter(pImportFile, i) == 32)
               {
                  StringSetCharacter(pImportFile, i, 48);
               }         
         }
      Alert(pImportFile);
         {
                  
                  if(pX==1)
                     {
                       Alert("Before FIle: ", pImportFile);
                       pFileHandle = pText.Open(pImportFile, FILE_READ|FILE_TXT|FILE_ANSI,"\r\n");
                       Alert("After FIle: ", pImportFile);
                       Alert(pFileHandle);
                       Alert("_________________B_L_U_M___________________");
                       pError = GetLastError();
                       Alert(pError);
                       while(!FileIsEnding(pFileHandle))
                           {
                              pMyString = FileReadString(pFileHandle,-1);
                              
                              //--- printing all the Strings
                              pNewsTime[pNewsNumber]     =     StringToTime(StringSubstr(pMyString, 0, 16));
                              pNewsSymbol[pNewsNumber]   =     StringSubstr(pMyString, 16, 6);
                              pNewsPriority[pNewsNumber] =     StringSubstr(pMyString, 22, 4);
                              
                              if(pNewsNumber >= 0)
                                 {
                                    if((pReleaseSymbol[pCountReleases] == pNewsSymbol[pCountNews]) && (pReleaseTime[pCountReleases] == pNewsTime[pCountNews]))
                                       {
                                          pReleasePriority[pCountReleases] = pReleasePriority[pCountReleases] + pNewsPriority[pCountNews];
                                       }
                                    else
                                       {
                                          pCountReleases = pCountReleases + 1;
                                          pReleaseTime[pCountReleases]     = pNewsTime[pCountNews];
                                          pReleaseSymbol[pCountReleases]   = pNewsSymbol[pCountNews];
                                          pReleasePriority[pCountReleases] = pNewsPriority[pCountNews];                  
                                       }
                                 }
                              else
                                 {
                                    pCountReleases = 1;
                                    pReleaseTime[pCountReleases]     = pNewsTime[pCountNews];
                                    pReleaseSymbol[pCountReleases]   = pNewsSymbol[pCountNews];
                                    pReleasePriority[pCountReleases] = pNewsPriority[pCountNews];
                                 }
                               
                              pLabel = "News" + pCountNews;
                              ObjectDelete(MyChartID[12], pLabel);
                              ObjectCreate(MyChartID[12], pLabel, OBJ_LABEL, 0, 0, 0);
                              ObjectSetInteger(MyChartID[12], pLabel, OBJPROP_COLOR, clrWhite); 
                              
                              pInfo = pMyString;
                              ObjectSetInteger(MyChartID[12], pLabel, OBJPROP_XDISTANCE, 50);
                              ObjectSetInteger(MyChartID[12], pLabel, OBJPROP_YDISTANCE, 20 + (pCountNews + 1)*15);
                              ObjectSetString(MyChartID[12], pLabel, OBJPROP_TEXT, pInfo);

                              pCountNews = pCountNews + 1;
                              pNewsNumber = pNewsNumber + 1;          
                           }
                           
                        FileClose(pFileHandle);      
                     }
                  pX++;
               } 
               
              
 
1531691:

Ok... it's quite a lot of code... so i will just post the readfunction

Ok, not very useful. I ask you a code so I can reproduce your issue.

Anyway, what is the result of running this code, what is printed in the log ? Please give some details if you need help.

 

The Result is:

 

Files:
20140416.log  78054 kb
 

I think the main Problem is, that in TESTER the file couldn't be found, beacause my filehandle is always -1 and in the normal mode it is 1. 

 
1531691:

I think the main Problem is, that in TESTER the file couldn't be found, beacause my filehandle is always -1 and in the normal mode it is 1. 

Please show the relevant code ! You have a problem with open a file and you don't show the code where you open the file.

I'm using now #property_file, I stored all data files in the Common Folder...

It's

#property tester_file "your file"

What is the content of this method ?

                       pFileHandle = pText.Open(pImportFile, FILE_READ|FILE_TXT|FILE_ANSI,"\r\n");

How do you know you are using common folder ?

 
angevoyageur:

Please show the relevant code ! You have a problem with open a file and you don't show the code where you open the file.

It's

What is the content of this method ?

How do you know you are using common folder ?

 

Oh my GOD yes... I forgot the FILE_COMMON Flag!

THANK YOU!!!

I was looking for everything else exept that!

WOW thank you so much!

 

Sorry for giving you so less Information. To clarify the pText is an object from type CFileTxt and the method open is in the Standard Library defined.

 

Thank you!