Download MetaTrader 5

My script is failing when the .CSV that I use with FileOpen is used by windows at the same

To add comments, please log in or register
Luis
226
Luis  

Whenever the file.csv Im using in script is being used by windows the system "freeze". What should I do?


//+------------------------------------------------------------------+
//|                                       Open_my_Charts.mq4     
//
//|    BeLikewater(forexfactory.com) email= nitx20@hotmail.com  | 
//+------------------------------------------------------------------+
#property copyright "Freeware"
#property strict
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   //Close all the charts except the first one
   while (ChartNext(ChartFirst())!=-1) 
   ChartClose(ChartFirst());
   
   

   
   int handle=FileOpen("OpenCharts.csv",FILE_SHARE_READ);  
   
   string simbolo,plantilla;
   long chart_num;
   int contador=0;
   
   //Read the first row
   FileReadString(handle);
   while(FileIsLineEnding(handle)!=TRUE)FileReadString(handle);
   
   //Open Charts
   while(!FileIsEnding(handle))
      {
      if(FileIsLineEnding(handle)==TRUE)contador=0;
      contador++;
      if (contador==1)simbolo=FileReadString(handle);
      if (contador==2)chart_num=ChartOpen(simbolo,StrToInteger(FileReadString(handle)));
      if (contador==3)ChartApplyTemplate(chart_num,FileReadString(handle));
      }  
      
   ChartClose(ChartFirst());
   FileClose(handle);
  }
//+------------------------------------------------------------------+  
Carl Schreiber
6788
Carl Schreiber  

I have (had?) a similar problem with LO: A csv-file opened by LO could not be (shared-) read by a (kernell32.dll-) Windows-function - the csv-file is blocked.

But I was told that LO-version 4.3 offers save copy which should not cause the problem.

To add comments, please log in or register