OutQuotings

Download script
Author: ��� ����� �. aka KimIV
OutQuotings

This script is designed for traders who need to export historical market data from their MetaTrader platform into an external spreadsheet format (CSV). It automates the process of gathering specific price information for a defined timeframe and saving it directly to a file on your computer.

How the Logic Works

1. User Configuration When you run the script, you are prompted to set three primary parameters:

  • Start and End Dates: You define the specific time window from which you want to extract data.
  • Separator: You can choose how to separate each piece of information (e.g., using a comma) so that it can be easily read by software like Microsoft Excel.

2. Automated Data Identification The script automatically looks through your trading history based on the dates you provided. It scans every individual "bar" or candle on your chart. If a candle falls within your selected start and end dates, the script captures its specific details:

  • Date and Time
  • Opening Price
  • Highest Price
  • Lowest Price
  • Closing Price
  • Trading Volume

3. File Creation and Saving The tool automatically generates a filename based on the asset you are currently viewing (e.g., EURUSD) and the timeframe of your chart (e.g., H1). It then creates a file containing all the relevant data points extracted from your chosen period.

4. Summary Report Once the export is finished, the script provides an immediate summary on your trading screen. This summary tells you exactly when the data extraction started and ended, as well as the total number of bars successfully exported to your file.

Key Benefits

  • Precision: It only captures data within your exact requested dates.
  • Convenience: You don't have to manually copy and paste price data; the script handles the heavy lifting of formatting and writing the data into a clean, readable file.
  • Compatibility: By exporting to a CSV format, you can easily move this data into other tools for further analysis or record-keeping.
Miscellaneous
Uses files from the file systemIt writes information to file
11 Views
0 Downloads
0 Favorites
OutQuotings
//+------------------------------------------------------------------+
//|                                                  OutQuotings.mq4 |
//|                                           Êèì Èãîðü Â. aka KimIV |
//|                                              http://www.kimiv.ru |
//|                                                                  |
//|    28.01.2006                                                    |
//|  Ñêðèïò äëÿ âûãðóçêè êîòèðîâîê çà âûáðàííûé ïåðèîä â ôàéë.       |
//+------------------------------------------------------------------+
#property copyright "Êèì Èãîðü Â. aka KimIV"
#property link      "http://www.kimiv.ru"
#property show_inputs

extern datetime BeginDate = D'2005.11.11';
extern datetime EndDate   = D'2005.12.21';
extern string   Separator = ",";

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
void start()
{
  int    i, b=0, bb=0, eb;
  string comm, st;
  string fn=Symbol()+Period()+" "+
         TimeToStr(BeginDate, TIME_DATE)+"-"+
         TimeToStr(EndDate, TIME_DATE)+".csv";

  for (i=Bars; i>0; i--)
  {
    if (Time[i]>=BeginDate && Time[i]<=EndDate)
    {
      if (bb==0) bb=i;       // ôèêñèðóåì íîìåð ïåðâîãî áàðà
      st=TimeToStr(Time[i], TIME_DATE)+Separator+
         TimeToStr(Time[i], TIME_MINUTES)+Separator+
         DoubleToStr(Open[i], Digits)+Separator+
         DoubleToStr(High[i], Digits)+Separator+
         DoubleToStr(Low[i], Digits)+Separator+
         DoubleToStr(Close[i], Digits)+Separator+
         DoubleToStr(Volume[i], 0);
      WritingLineInFile(fn, st);
      b++;
      eb=i;        // ôèêñèðóåì íîìåð ïîñëåäíåãî áàðà
    }
  }

  comm="Íà÷àëî: "+TimeToStr(Time[bb], TIME_DATE|TIME_MINUTES)+"\n";
  comm=comm+"Êîíåö: "+TimeToStr(Time[eb], TIME_DATE|TIME_MINUTES)+"\n";
  comm=comm+"Âûãðóæåíî áàðîâ: "+DoubleToStr(b, 0);

  Comment(comm);
}

//+------------------------------------------------------------------+
//| Çàïèñü ñòðîêè â ôàéë                                             |
//+------------------------------------------------------------------+
void WritingLineInFile(string FileName, string text)
{
  int file_handle=FileOpen(FileName, FILE_READ|FILE_WRITE, " ");

	if (file_handle>0)
	{
		FileSeek(file_handle, 0, SEEK_END);
		FileWrite(file_handle, text);
		FileClose(file_handle);
	}
}
//+------------------------------------------------------------------+

Comments