TickLoggerForFXT1

Download script
TickLoggerForFXT1

This script is designed as a specialized logging tool for the MetaTrader 4 platform. Its primary purpose is to systematically record real-time price movements (known as "ticks") into an external file, allowing for precise data collection.

How the Logic Works

1. Initialization and File Setup When you first activate the script, it automatically prepares a workspace. It creates a unique CSV file (a format easily opened by programs like Microsoft Excel) named using a combination of the current currency pair and the current date. By using the date in the filename, the tool ensures that your data is organized day-by-day, preventing old records from being overwritten.

2. Continuous Data Capture Once active, the script enters a "logging" state. Every time the market price moves—even by the smallest fraction—the script captures two specific pieces of information:

  • The Exact Timestamp: The precise date and time the movement occurred.
  • The Current Price: The current "Bid" price (the price at which you could sell) in the market.

3. Permanent Storage The script writes these details into the file instantly. It is configured to always add new information to the end of the existing file, creating a chronological history of every price fluctuation that occurs while the script is running.

4. Clean Shutdown When you stop or remove the script from your chart, it automatically closes the connection to the file. This ensures that all captured data is saved correctly and the file is not left "locked" or corrupted by the system.

Summary for the User

Think of this tool as an automated digital diary for market prices. It sits in the background, watching the charts, and writes down every tiny price change into a spreadsheet-friendly file the moment it happens. This allows you to review a complete history of market activity later without having to watch the screen manually.

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

//+------------------------------------------------------------------+
//|                                             TickLoggerForFXT.mq4 |
//|                                               Paul Hampton-Smith |
//+------------------------------------------------------------------+

int handle;

int init()
{
   Comment("Waiting for tick");
   handle = FileOpen(Symbol() + TimeToStr(CurTime(),TIME_DATE) + "_tick_log.csv", FILE_CSV|FILE_READ|FILE_WRITE, ';' );
   FileSeek(handle,0,SEEK_END);
}

int deinit()
{
   FileClose(handle);
}

int start()
{
   Comment("Logging ticks");
   FileWrite(handle,TimeToStr(CurTime()),Bid);
   return(0);
}


Comments