CollectData

Download script
Author: Copyright � 2006, Derk Wehler
CollectData

This automated script is designed to act as a background data logger for your trading platform. Its primary purpose is to create a continuous, organized record of live market prices by exporting them into a standardized file format that can be used later for analysis or auditing.

How the Logic Works

The script follows a straightforward, repetitive process to ensure you have a consistent history of market activity:

  • Automatic File Creation: Every time the script runs, it automatically identifies the specific financial instrument (the symbol) you are currently viewing. It then creates or accesses a dedicated CSV file named specifically for that asset. This ensures that data for different currencies or assets remains separated and organized.
  • Data Identification: The logic is designed to capture three critical pieces of information simultaneously:
    1. The exact current date and time.
    2. The current "Bid" price (the price at which you can sell).
    3. The current "Ask" price (the price at which you can buy).
  • Sequential Logging: The script is programmed to move to the very end of the existing file every time it executes. This prevents it from overwriting your previous data, allowing it to build a chronological "logbook" of prices over time.
  • Seamless Export: Once the data is captured, the script instantly writes it into the file and closes the connection. This "write-and-close" cycle ensures that the data is saved securely and does not interfere with your platform's performance while the script is running.

Summary for Users

Essentially, this tool serves as a digital recorder. It watches the market in real-time and writes down the current price and timestamp into an external spreadsheet-compatible file at regular intervals, providing you with a raw data trail of market movement without requiring any manual entry.

Price Data Components
Series array that contains open time of each bar
Miscellaneous
Uses files from the file systemIt writes information to file
13 Views
0 Downloads
0 Favorites
CollectData
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//=============================================================================
//															CollectData.mq4
//											  Copyright © 2006, Derk Wehler
//
//=============================================================================
#property copyright "Copyright © 2006, Derk Wehler"
#property link      "none"


//=============================================================================
// expert initialization function
//=============================================================================
int init()
{
	return(0);
}
  
  
//=============================================================================
// expert deinitialization function
//=============================================================================
int deinit()
{
	return(0);
}
  
  
//=============================================================================
// expert start function
//=============================================================================
int start()
{
	int handle;

	handle = FileOpen("Data_" + Symbol() + ".csv", FILE_READ|FILE_WRITE|FILE_CSV, ",");
	FileSeek(handle, 0, SEEK_END);      
	FileWrite(handle, TimeToStr(CurTime(), TIME_DATE|TIME_SECONDS), Bid, Ask);
	FileClose(handle);
	
	return(0);
}


Comments