PROBLEM CODE - page 2

 
burnssss:

I tried creating a expert, more or less similar code, and I write a file eg monthly data


But no more download data from 1970.

The code we used was as follows:

I already gave you a link that tells you why this doesn't work, did you read it ?

RaptorUK:

Please use the Forum search . . .

https://www.mql5.com/en/forum/147170

. . . and the documentation

 
RaptorUK:
No has respondido a mi pregunta simple, donde en el archivo es lo que desea colocar los nuevos datos? si se piensa que por unos minutos le ayudará. . .

A continuation of the old data? I do not understand that I have to use and where to continue performing data download
 
The combination FILEREAD / file_write I just made it and I keep doing the same. Something I'm not understanding
 
burnssss:
The combination FILEREAD / file_write I just made it and I keep doing the same. Something I'm not understanding
Each time you write a row of data to the file, each new row of data you want to be on a new row, you don't want it to overwrite the row you just wrote . . . before you write the new row of data you need to FileSeek() to the end of the file . . . then write your new row of data.
 
I'll try
 

I do not understand, is the same as before

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
export();
  }

//+------------------------------------------------------------------+
void export() 
{ 

string file="export_"+Symbol()+"_"+Period()+".csv"; 
int f=FileOpen(file,FILE_CSV|FILE_READ|FILE_WRITE, ';'); 
if(f>0)
{
     FileSeek(f, 0, SEEK_END);
   
    }



for(int i=Bars-1;i>=0;i--)
{
FileWrite(f,TimeToStr(Time,TIME_DATE|TIME_MINUTES),Open,High,Low,Close ,iFractals(Symbol(),0,1,i),iFractals(Symbol(),0,2,i),iCustom(Symbol(), 
0,"ZigZag",0,i),iCustom(Symbol(),0, "ZigZag",1,i));
Alert("Export "+Symbol()+" finished. Exported: "+Bars+" records"); 
FileClose(f);
  f=0;
}
}
 
burnssss:

I do not understand, is the same as before

Why are you closing the file inside the loop ? read your code through before testing it, make sure it makes sense . . .
 

In the code, I think I use the right steps. I think you should download all the data in a file. Csv, but do not understand why I do this.

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
export();
  }

//+------------------------------------------------------------------+
void export() 
{ 

string file="export_"+Symbol()+"_"+Period()+".csv"; 
int f=FileOpen(file,FILE_READ|FILE_WRITE, ';'); 
if(f>0)
{
     FileSeek(f, 0, SEEK_END);
   
    }



for(int i=Bars-1;i>=0;i--)
{
FileWrite(f,TimeToStr(Time,TIME_DATE|TIME_MINUTES),Open,High,Low,Close ,iFractals(Symbol(),0,1,i),iFractals(Symbol(),0,2,i),iCustom(Symbol(),0,"ZigZag",0,i),iCustom(Symbol(),0, "ZigZag",1,i));
}

Alert("Export "+Symbol()+" finished. Exported: "+Bars+" records");  
FileClose(f); 
}
 
burnssss:

In the code, I think I use the right steps. I think you should download all the data in a file. Csv, but do not understand why I do this.

When the loop runs for the first value of i it will write data and then close the file, for the next value of i in the loop the file is closed . . . what do you think will happen ?
 
Many thanks, I found the solution
Reason: