CÓDIGO DO PROBLEMA

 
Quero baixar o histórico OHLC, os fractais e o indicador ziguezague, usando este script, mas quando abri o csv, não tenho nenhuma informação.
Alguém pode me dizer o erro ali?
//+------------------------------------------------------------------+
//|                                                                  |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
//#property copyright ""
//#property link      ""

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

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

string file="export_"+Symbol()+"_"+Period()+".csv"; 
int f=FileOpen(file,FILE_CSV|FILE_WRITE,","); 
if(f<1) { Alert("File opening error"); return(0); }
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");  
FileFlush(f); 
FileClose(f); 
}
 
Eu também criei o seguinte especialista, mas não me mostra os dados como o roteiro anterior
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   start();
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
 
 void export() 
{ 

string file="export_"+Symbol()+"_"+Period()+".csv"; 
int f=FileOpen(file,FILE_CSV|FILE_WRITE,","); 
if(f<1) { Alert("File opening error"); return(0); }
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");  
FileFlush(f); 
FileClose(f); 
}

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
export();

//----
//Alert(ArraySize(norepeats) + ArraySize(morerepeats));
   return(0);
 }
//+------------------------------------------------------------------+
 
burnssss:
Quero baixar o histórico OHLC, os fractais e o indicador ziguezague, usando este script, mas quando abri o csv, não tenho nenhuma informação.
Alguém pode me dizer o erro ali?

Por favor, use a pesquisa do Fórum . .

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

... e a documentação

 

Combinei desta maneira, e isso me dá erro. Não entendo porque recebo o arquivo sem nenhum dado

//#property copyright ""
//#property link      ""

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

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

string file="export_"+Symbol()+"_"+Period()+".csv"; 
int f=FileOpen(file,FILE_CSV|FILE_READ,","); 
if(f<1) { Alert("File opening error"); return(0); }
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");  
FileFlush(f); 
FileClose(f); 
}
 

1) >=

for(int i=Bars-1;i<=0;i--)

2) FILE_WRITE ou FILE_READ|FILE_WRITE

FileOpen(file,FILE_CSV|FILE_READ,","); 

3) Você conhece o EMPTY_VALUE (ZZ e Fractals podem tê-lo) ???? (Valores vazios não são desenhados ou mostrados na DataWindow. Por padrão, o valor vazio é EMPTY_VALUE)

4) No fechamento do arquivo, os dados são descarregados para o disco automaticamente, de modo que não há necessidade de chamar a função FileFlush() antes de chamar a função FileClose().

 

Eu fiz essas mudanças, e o arquivo me dá apenas um fato:

1970.01.01 00:00,,,,, 0,0,0,2147483647.

Não consigo pensar em mais nada.

//#property copyright ""
//#property link      ""

//+------------------------------------------------------------------+
//| 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<1) { Alert("File opening error"); return(0); }
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));
FileClose(f);
}


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

 
burnssss:

Eu fiz essas mudanças, e o arquivo me dá apenas um fato:

1970.01.01 00:00,,,,, 0,0,0,2147483647.

Não consigo pensar em mais nada.

Se você abrir um arquivo, escreva para ele, feche-o, depois abra-o novamente para escrever mais alguns dados onde os novos dados serão escritos ? para que lugar do arquivo ?
 

Algumas horas antes de você abrir este tópico

outro tópico opere também com seu assunto

você não leu ?? Salvando dados de gráficos para arquivo

 
RaptorUK:
Se você abrir um arquivo, escreva para ele, feche-o, depois abra-o novamente para escrever mais alguns dados onde os novos dados serão escritos ? para que lugar do arquivo ?


No código, acho que utilizo os passos corretos. Acho que você deve baixar todos os dados de um arquivo. Csv, mas não entendo porque eu faço isso.
 

Eu tentei criar um código mais ou menos similar e escrevo um arquivo, por exemplo, dados mensais

1970.01.01 00:00,,,,,0,0,0,2147483647

1970.01.01 00:00,,,,,0,0,0,2147483647

1970.01.01 00:00,,,,,0,0,0,2147483647

1970.01.01 00:00,,,,,0,0,0,2147483647

1970.01.01 00:00,,,,,0,1.1614,0,2147483647

1970.01.01 00:00,,,,,0,0,0,2147483647

1970.01.01 00:00,,,,,0,0,0,2147483647

1970.01.01 00:00,,,,,0,0,0,2147483647

1970.01.01 00:00,,,,,0,0,0,2147483647

1970.01.01 00:00,,,,,0,0,0,2147483647

1970.01.01 00:00,,,,,1.4104,0,0,2147483647

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,1.1688,0,0

1970.01.01 00:00,,,,,1.2495,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,1.1192,0,0

1970.01.01 00:00,,,,,1.2315,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,1.1069,1.1069,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,1.2894,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,1.3161,0,0,1.3161

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,1.2351,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,1.4535,0,1.4535,1.4535

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,1.3,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,1.3353,1.2596,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,1.0344,1.0344,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,1.1537,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,1.0608,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,1.1216,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,1.079,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,0,0,0,0

1970.01.01 00:00,,,,,1.2401,0,1.2401,1.2401

Mas não há mais dados de download de 1970.

O código que utilizamos foi o seguinte:

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   start();
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
 
 void export() 
{ 

string file="export_"+Symbol()+"_"+Period()+".csv"; 
int f=FileOpen(file,FILE_CSV|FILE_WRITE,","); 
if(f<1) { Alert("File opening error"); return(0); }
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); 
}

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
export();

//----
//Alert(ArraySize(norepeats) + ArraySize(morerepeats));
   return(0);
 }
//+------------------------------------------------------------------+
 
burnssss:

No código, acho que utilizo os passos corretos. Acho que você deve baixar todos os dados de um arquivo. Csv, mas não entendo porque eu faço isso.
Você não respondeu à minha simples pergunta, onde no arquivo você quer colocar os novos dados ? se você pensar nisso por alguns minutos, isso o ajudará . . .