Skip to content

Instantly share code, notes, and snippets.

@lepinekong
Last active June 4, 2022 18:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lepinekong/9a53459b05ac5ed999883eb4a3cb6488 to your computer and use it in GitHub Desktop.
Save lepinekong/9a53459b05ac5ed999883eb4a3cb6488 to your computer and use it in GitHub Desktop.
//+--------------------------------------------------------+
//| adapted for FILE_SHARE_READ from BP-Ticks-1.0.mq4 |
//+--------------------------------------------------------+
// File identificator
int file;
uint startTick;
uint tickTime;
datetime theTime;
string strTickDate;
string strTickSecond;
string separator = ",";
// Tick count for flushing each 1024 ticks
int flushCount = 0;
int flushCountLimit = 32; // you can experiment with 1024
int init() {
startTick=GetTickCount();
file = FileOpen(Symbol() + "-Ticks.csv",
FILE_WRITE | FILE_READ | FILE_CSV | FILE_SHARE_READ, separator);
return(0);
}
int deinit() {
FileClose(file);
return(0);
}
int start() {
// - Date & time with seconds info
// - Bid
// - Ask
// - Volume indicator for the selected timeframe
tickTime=GetTickCount()- startTick;
theTime=TimeCurrent();
strTickDate=TimeToStr(theTime,TIME_DATE);
strTickSecond=TimeToStr(theTime,TIME_SECONDS);
FileWrite(file,
strTickDate, strTickSecond,
"" + tickTime,
Bid,
Ask,
iVolume(Symbol(), NULL, 0));
flushCount++;
// Flush file buffer each 1024 ticks to enhance performance
// when writing huge files
if (flushCount == flushCountLimit) {
FileFlush(file);
flushCount = 0;
}
return(0);
}
@lepinekong
Copy link
Author

Will export in subfolder: \MQL4\Files

@lepinekong
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment