Return to Snippet

Revision: 37344
at December 8, 2010 17:40 by forexgenuine


Initial Code
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
   string symbols[]={"_US30","_FRA40","EURUSD","EURGPB"};
   int periods[] = {1,5,15,60,240,1440,10080,43200};
   
   int count = ArraySize(symbols);
   int counttf = ArraySize(periods); 
     
   string symbol;
   int period;
   for (int ii=0; ii<count; ii++){   
      symbol = symbols[ii];
      for (int jj=0; jj<counttf; jj++){ 
         period = periods[jj];
         export(symbol, period);
      }
   }   

//----
   Alert("the end");
   return(0);
  }
//+------------------------------------------------------------------+

int export(string symbol, int theperiod)
  {

   string filename = StringSubstr(symbol,0,6) + theperiod + ".csv";
   int handle = FileOpen(filename, FILE_CSV|FILE_WRITE, ";");
   if(handle>0)
   {
      // table column headers recording
      FileWrite(handle, "Time;Open;High;Low;Close;Volume");
      // data recording
      
      for(int i=iBars(symbol,theperiod); i>=0; i--) {

       datetime t = iTime(symbol,theperiod,i);
       // int year = TimeYear(Time[i]);
       int year = TimeYear(t);
       if (year > 1970) {

         
         string strdatetime = TimeToStr(t);
         strdatetime = StringSetChar(strdatetime,4,'-');
         strdatetime = StringSetChar(strdatetime,7,'-');
                  
         double Open_i = iOpen(symbol,theperiod,i);
         double High_i = iHigh(symbol,theperiod,i);
         double Low_i = iLow(symbol,theperiod,i);
         double Close_i = iClose(symbol,theperiod,i);
         double Volume_i = iVolume(symbol,theperiod,i);
         
         //FileWrite(handle, year + "-" + month + "-" + month + " " + hour + ":" + minute + ":" + seconds, Open[i], High[i], Low[i], Close[i], Volume[i]);
         FileWrite(handle, strdatetime, Open_i, High_i, Low_i, Close_i, Volume_i);
         
       }
      }
      FileClose(handle);
   }
   return(0);
  }

Initial URL

                                

Initial Description
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

Initial Title
Export Alpari from Server

Initial Tags

                                

Initial Language
C