zapis danych tickowych w mt4

O jezykach programowania w platformach i nie tylko.
makset
Uczestnik
Uczestnik
Posty: 2
Rejestracja: 03 lut 2014, 13:17

zapis danych tickowych w mt4

Nieprzeczytany post autor: makset »

Witam serdecznie.
Proszę o pomoc w eksportowaniu danych co tick w mt4. Znalazłem niżej przedstawimy skrypt z tym, że puki działa mt4 plik jest cały czas w użyciu a dane zapisują się dopiero po zamknięciu programu. Zależy mi na tym żeby przerobić go tak żeby działał tak jak drugi skrypt znajdujący się również poniżej.
Niestety dde odpada.
Chcę również zaznaczyć że jestem początkującym więc proszę o wyrozumiałość:)

Z góry dziękuję za pomoc.
Pozdrawiam

Kod: Zaznacz cały

//+--------------------------------------------------------+
//|                                       BP-Ticks-1.0.mq4 |
//+--------------------------------------------------------+
 
// File identificator
int file;
 
// Tick count for flushing each 1024 ticks
int flushCount = 0;
 
int init() {
 
   // Open the file for writing
   file = FileOpen(Symbol() + "-Ticks.txt",
                   FILE_WRITE | FILE_CSV,
                   ";");   
 
   return(0);
}
 
int deinit() {
 
   // Close the file
   FileClose(file);
 
   return(0);
}
 
int start() {
 
   // Write tick data:
   //    - Date & time with seconds info
   //    - Bid
   //    - Ask
   //    - Volume indicator for the selected timeframe
   FileWrite(file, 
             TimeToStr(TimeCurrent(),
                       TIME_DATE | TIME_SECONDS), 
             Bid, 
             Ask, 
             iVolume(Symbol(), NULL, 0));
 
   flushCount++;
   
   // Flush file buffer each 1024 ticks to enhance performance
   //    when writing huge files
   if (flushCount == 1024) {
      FileFlush(file);
      flushCount = 0;
   }
   
    //  FileClose(file);
 
   return(0);
}

Kod: Zaznacz cały

//+------------------------------------------------------------------+
//|                                              _EXPORT_DATA_1H.mq4 |
//|                      Copyright © 2010, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property indicator_chart_window
extern int length = 1000;   // The amount of bars sent to be processed
double ExtMap[];           // Chart buffer
string nameData;
int init()
{
   nameData = Symbol()+"1H.txt";         // name of the data file to be sent
   return(0);
}
int start()
{
   static int old_bars = 0;   // remember the amount of bars already known   
   if (old_bars != Bars)      // if a new bar is received 
   {
      write_data();                             // write the data file                              
   }      
   old_bars = Bars;              // remember how many bars are known
   return(0);
}
//+------------------------------------------------------------------+
void write_data()
{
  int handle;
  handle = FileOpen(nameData, FILE_CSV|FILE_WRITE,';');
  if(handle < 1)
  {
    Comment("Creation of "+nameData+" failed. Error #", GetLastError());
    return(0);
  }

  FileWrite(handle, "DATE","TIME","HIGH","LOW","CLOSE","OPEN");   // heading
  int i;
  for (i=length-1; i>=0; i--)
  {
    FileWrite(handle, TimeToStr(Time[i], TIME_DATE), TimeToStr(Time[i], TIME_SECONDS),
                      High[i], Low[i], Close[i], Open[i]);
  }
  FileClose(handle);
  Comment("File "+nameData+" has been created. "+TimeToStr(TimeCurrent(), TIME_SECONDS) );
  return(0);
}

ODPOWIEDZ