Guest User

Untitled

a guest
Apr 23rd, 2018
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. //+--------------------------------------------------------+
  2. //| adapted for FILE_SHARE_READ from BP-Ticks-1.0.mq4 |
  3. //+--------------------------------------------------------+
  4.  
  5. // File identificator
  6. int file;
  7. uint startTick;
  8. uint tickTime;
  9.  
  10. datetime theTime;
  11. string strTickDate;
  12. string strTickSecond;
  13.  
  14. string separator = ",";
  15.  
  16. // Tick count for flushing each 1024 ticks
  17.  
  18. int flushCount = 0;
  19. int flushCountLimit = 32; // you can experiment with 1024
  20.  
  21. int init() {
  22.  
  23. startTick=GetTickCount();
  24. file = FileOpen(Symbol() + "-Ticks.csv",
  25. FILE_WRITE | FILE_READ | FILE_CSV | FILE_SHARE_READ, separator);
  26.  
  27. return(0);
  28. }
  29.  
  30. int deinit() {
  31. FileClose(file);
  32. return(0);
  33. }
  34.  
  35. int start() {
  36. // - Date & time with seconds info
  37. // - Bid
  38. // - Ask
  39. // - Volume indicator for the selected timeframe
  40. tickTime=GetTickCount()- startTick;
  41. theTime=TimeCurrent();
  42. strTickDate=TimeToStr(theTime,TIME_DATE);
  43. strTickSecond=TimeToStr(theTime,TIME_SECONDS);
  44. FileWrite(file,
  45. strTickDate, strTickSecond,
  46. "" + tickTime,
  47. Bid,
  48. Ask,
  49. iVolume(Symbol(), NULL, 0));
  50. flushCount++;
  51.  
  52. // Flush file buffer each 1024 ticks to enhance performance
  53. // when writing huge files
  54. if (flushCount == flushCountLimit) {
  55. FileFlush(file);
  56. flushCount = 0;
  57. }
  58.  
  59. return(0);
  60. }
Add Comment
Please, Sign In to add comment