Testing 'CopyTicks' - page 4

 
CopyTicks 

////////////////////////////////////////////////////////////////////////////////////////////////////////// 

MqlTick tick_array[];  

int OnInit()
  {
   int copied=CopyTicks(_Symbol,tick_array,COPY_TICKS_ALL,0,countHistoryTicks);
   if(Save_File!=NOT_SAVE)
     {
      SaveTicksToFile(tick_array);
     }
   return(INIT_SUCCEEDED);
  }



void SaveTicksToFile(MqlTick &massiveTicks[])

  {

   string filename,file_buffer;

   StringConcatenate(filename,Symbol(),".txt");

   int file_handle=FileOpen(filename,FILE_READ|FILE_WRITE|FILE_ANSI|FILE_SHARE_READ);

FileSeek(file_handle,0,SEEK_END);

   int sizeMassiveTicks=ArraySize(massiveTicks);

   int i=0;

   while(i<sizeMassiveTicks)

     {

      StringConcatenate(file_buffer,TimeToString(massiveTicks[i].time,TIME_DATE|TIME_SECONDS)," ",DoubleToString(massiveTicks[i].bid,_Digits)," ",DoubleToString(massiveTicks[i].ask,_Digits)," ",DoubleToString(massiveTicks[i].last,_Digits)," ",IntegerToString(massiveTicks[i].volume,_Digits)," ",IntegerToString(massiveTicks[i].time_msc)," ",IntegerToString(massiveTicks[i].flags,_Digits));

      FileWrite(file_handle,file_buffer);

      i++;

     }

   FileClose(file_handle);

  } 
 

SymbolInfoTick 

////////////////////////////////////////////////////////////////////////

int OnCalculate(const int rates_total,

                const int prev_calculated,

                const datetime &time[],

                const double &open[],

                const double &high[],

                const double &low[],

                const double &close[],

                const long &tick_volume[],

                const long &volume[],

                const int &spread[])

  {

   MqlTick last_tick;

   SymbolInfoTick(Symbol(),last_tick);



   TickStruct tick={0,0,0,0,0,0,0};

   tick.time=TimeCurrent();

   tick.bid=last_tick.bid;

   tick.ask=last_tick.ask;

   tick.flag=last_tick.flags;

   tick.last=last_tick.last;

   tick.time_msc=last_tick.time_msc;

   tick.volume=last_tick.volume;

   int total=ArraySize(g_ticks);

   if(ArrayResize(g_ticks,total+1,1000)<0)

     {

      Alert(": индикатору не хватает памяти для сохранения данных об очередном тике.");

     }

   else

     {

      g_ticks[total]=tick;

      UpTick[rates_total-1]=total;

     }

   if(total>999)

     {

      SaveTempTicks();

      ArrayFree(g_ticks);

     }

   return(rates_total);

  } 

 

 

void SaveTempTicks()

  {

// Создание файла тиковой истории

   int hTicksFile=FileOpen(Symbol()+"fullTicks.tks",FILE_BIN|FILE_READ|FILE_WRITE|FILE_SHARE_READ|FILE_SHARE_WRITE);

   if(hTicksFile<1)

      return;

   FileSeek(hTicksFile,0,SEEK_END);

// Запись файла 

   int total=ArraySize(g_ticks),i=0;

   while(i<total)

     {

      if(FileWriteStruct(hTicksFile,g_ticks[i])==0)

        {

         Print("Ошибка сохранения данных во временный файл...");

         return;

        }

  i++;

     }

FileClose(hTicksFile);

 }  
 
Create as short an example as possible that clearly demonstrates the problem. Ideally, all processing in one file.
 
 

In the debugger I look at values:

last_tick obtained viaSymbolInfoTick(Symbol(),last_tick),

tick_array via CopyTicks(_Symbol,tick_array,COPY_TICKS_ALL,0,1);

All in real time, ticks are the same, flags are different. I haven't managed to catch the difference in volumes in this way, it's not so frequent as the difference in flags.

Let's at least define them.

 
zimbabve15:

In the debugger I look at values:

last_tick obtained via SymbolInfoTick(Symbol(),last_tick),

tick_array via CopyTicks(_Symbol,tick_array,COPY_TICKS_ALL,0,1);

All in real time, ticks are the same, flags are different. I haven't managed to catch the difference in volumes in this way, it's not so frequent as the difference in flags.

Let's define them at least.

In order to define it, we need an example file.
 

ED-3.16.txt - broker Opening via CopyTicks

Second file same broker viaSymbolInfoTick(Symbol(),last_tick),

Files:
ED-3.16.txt  707 kb
 
second file same broker viaSymbolInfoTick(Symbol(),last_tick),
Files:
 
Tell me, how will I be able to load *.txt files into MetaEditor? If there is a problem, make the example as simple as possible - one file.
 
Karputov Vladimir:
Tell me, how will I be able to load *.txt files into MetaEditor? If there is a problem, make the example as simple as possible - one file.
Actually it is not a problem, change the extension and MetaEditor will eat it. You'd better ask for source code files of the program, due to which this log is obtained.
 
Alexey Kozitsyn:
No problem, change the extension and MetaEditor will eat it up. You'd better ask for source code files of the program, which produced this log.
So I have already asked for two pages: give the shortest example (I clarify, just in case, that "example" is *.mq5 file in number of one pieces - that is just one) which shows the problem.
Reason: