Export Alpari from Server


/ Published in: C
Save to your folder(s)

Opt("WinTitleMatchMode", 2) ;1=complete, 2=quick
$title = WinGetHandle("MetaTrader - Alpari UK")
If $title = 0 Then
MsgBox(0,"Not Found", "The window title specified was not found!")
Else
WinActivate($title)
WinWaitActive($title)
Send("^x")
WinWaitActive("Signal")
Send("{ENTER}")
EndIf


Copy this code and paste it in your HTML
  1. //+------------------------------------------------------------------+
  2. //| script program start function |
  3. //+------------------------------------------------------------------+
  4. int start()
  5. {
  6. //----
  7. string symbols[]={"_US30","_FRA40","EURUSD","EURGPB"};
  8. int periods[] = {1,5,15,60,240,1440,10080,43200};
  9.  
  10. int count = ArraySize(symbols);
  11. int counttf = ArraySize(periods);
  12.  
  13. string symbol;
  14. int period;
  15. for (int ii=0; ii<count; ii++){
  16. symbol = symbols[ii];
  17. for (int jj=0; jj<counttf; jj++){
  18. period = periods[jj];
  19. export(symbol, period);
  20. }
  21. }
  22.  
  23. //----
  24. Alert("the end");
  25. return(0);
  26. }
  27. //+------------------------------------------------------------------+
  28.  
  29. int export(string symbol, int theperiod)
  30. {
  31.  
  32. string filename = StringSubstr(symbol,0,6) + theperiod + ".csv";
  33. int handle = FileOpen(filename, FILE_CSV|FILE_WRITE, ";");
  34. if(handle>0)
  35. {
  36. // table column headers recording
  37. FileWrite(handle, "Time;Open;High;Low;Close;Volume");
  38. // data recording
  39.  
  40. for(int i=iBars(symbol,theperiod); i>=0; i--) {
  41.  
  42. datetime t = iTime(symbol,theperiod,i);
  43. // int year = TimeYear(Time[i]);
  44. int year = TimeYear(t);
  45. if (year > 1970) {
  46.  
  47.  
  48. string strdatetime = TimeToStr(t);
  49. strdatetime = StringSetChar(strdatetime,4,'-');
  50. strdatetime = StringSetChar(strdatetime,7,'-');
  51.  
  52. double Open_i = iOpen(symbol,theperiod,i);
  53. double High_i = iHigh(symbol,theperiod,i);
  54. double Low_i = iLow(symbol,theperiod,i);
  55. double Close_i = iClose(symbol,theperiod,i);
  56. double Volume_i = iVolume(symbol,theperiod,i);
  57.  
  58. //FileWrite(handle, year + "-" + month + "-" + month + " " + hour + ":" + minute + ":" + seconds, Open[i], High[i], Low[i], Close[i], Volume[i]);
  59. FileWrite(handle, strdatetime, Open_i, High_i, Low_i, Close_i, Volume_i);
  60.  
  61. }
  62. }
  63. FileClose(handle);
  64. }
  65. return(0);
  66. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.