Author: Lizhniyk E
Ticks

This tool is designed to automatically track and record specific price movements within the trading market over a set number of consecutive updates (ticks). Instead of recording every single movement, it aggregates data into meaningful segments based on a volume setting defined by the user.

How the Logic Works

1. Data Initialization When the script starts, it prepares a dedicated spreadsheet file (in .csv format) for saving the captured information. The filename is automatically generated based on the specific asset you are trading and your chosen volume setting. At the start of every new recording cycle, the script clears out any previous data to ensure a fresh start.

2. Tracking the Movement The script monitors the "Bid" price (the current selling price) in real-time. For every recording cycle:

  • It captures the exact date and time the period begins.
  • It establishes the starting price, the highest price reached, and the lowest price reached during that window.
  • As new price updates come in, the script constantly checks if the current price is higher than the previous "high" or lower than the previous "low," updating those values accordingly as the market moves.

3. Recording and Resetting Once the price has moved for the specific number of times you have requested (the "volume"):

  • The script gathers all the gathered information—starting time, ending time, opening price, highest point, lowest point, and final closing price—and saves it as a single line in your spreadsheet.
  • Immediately after saving the data, the script resets its internal counters and begins tracking a brand-new window of price movement.

Summary for the User

Essentially, this script acts as an automated logger. It watches the market "pulse" and captures a snapshot of how much the price fluctuated over a specific amount of activity. This allows you to see the range (High to Low) and the progression of prices over defined intervals without having to manually record every minor fluctuation yourself.

Miscellaneous
Uses files from the file systemIt writes information to file
13 Views
0 Downloads
0 Favorites
Ticks
//+------------------------------------------------------------------+
//|                                                        Ticks.mq4 |
//|                                                       Lizhniyk E |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Lizhniyk E"
#property link      "http://www.metaquotes.net"

extern int volume=100;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int handle;
string file_name;
int init()
  {
//----
   file_name=Symbol()+" "+"volume "+volume+".csv";
   FileDelete(file_name);
   handle=FileOpen(file_name,FILE_CSV|FILE_WRITE,';'); 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
//                 open   high   low    close 
//2008.01.16,04:13,1.4817,1.4819,1.4817,1.4819,2
int count;
double h,l,o,c;
bool next=true;
string open_date, open_hour;
string data;
int start()
  {
//----
   count++;
   if(next) 
    {
    open_date=TimeToStr(TimeCurrent(),TIME_DATE);
    open_hour=TimeToStr(TimeCurrent(),TIME_MINUTES);
    o=Bid;
    h=Bid;
    l=Bid;
    next=false;
    }
   if(count!=volume)
    {
    if(Bid>h) h=Bid;
    if(Bid<l) l=Bid;
    }
    
   if(count==volume)
    {
    c=Bid;
    data=open_date+","+open_hour+","+o+","+h+","+l+","+c+","+count;
    count=0; //h=0; l=0;
    next=true;
    FileWrite(handle,data);
    }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments