VolumeMeans
Download scriptThis script is designed to analyze and export historical trading volume data across a specific portfolio of 13 different currency pairs. Rather than displaying a visual chart directly on your trading platform, the tool functions as a data processor that compiles information into an external spreadsheet file.
Core Functionality
The logic operates by systematically scanning through every historical price bar available in your trading history. For each bar, it identifies two key pieces of information: the day of the week and the specific hour of the day.
Data Collection Process
The script tracks 13 specific currency pairs simultaneously (including major pairs like EURUSD, USDJPY, and GBPUSD). As it moves through the historical data, it performs the following actions:
- Volume Aggregation: It captures the total trading volume for each currency pair at every specific hour of every day of the week.
- Frequency Counting: It tracks how many times a specific currency pair appeared during those specific hours to ensure the final data is weighted correctly.
Processing and Output
Once the script has finished scanning the entire history, it performs a calculation to determine the average volume for each currency pair for every hour of the week (for example, the average volume for USDJPY on Monday at 10:00 AM).
The final result is exported into a CSV file. This allows you to open the data in external software (like Excel) to see a comprehensive breakdown of trading activity across all 13 pairs, organized by day and hour, providing a clear picture of market liquidity trends over time.
//+------------------------------------------------------------------+
//| MULTICUR.mq4 |
//| Edward Samokhvalov |
//| |
//+------------------------------------------------------------------+
#property copyright "Edward Samokhvalov"
#property indicator_separate_window
extern string inFile = "Volumes.csv";
double Volumes[13][5][24][2];
string cur[13];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
cur[0]="CADJPY";
cur[1]="AUDJPY";
cur[2]="CHFJPY";
cur[3]="NZDUSD";
cur[4]="EURJPY";
cur[5]="EURCHF";
cur[6]="EURGBP";
cur[7]="USDCAD";
cur[8]="AUDUSD";
cur[9]="USDJPY";
cur[10]="EURUSD";
cur[11]="GBPUSD";
cur[12]="USDCHF";
int c,d,h;
// reset array
for (c=0;c<13;c++)
for (d=0; d<5; d++)
for (h =0; h<24; h++)
for (int n=0; n<2; n++)
Volumes[c][d][h][n]=0;
int handle=FileOpen(inFile, FILE_CSV|FILE_WRITE);
string t = cur[0];
for (c=1; c<13; c++) t = t + " , " + cur[c];
FileWrite(handle, t );
for (int i=0; i<Bars; i++) // for each bar
{
h = TimeHour(Time[i]);
d = TimeDayOfWeek(Time[i])-1;
for (c=0; c<13; c++)
{
Volumes[c][d][h][0] += iVolume(cur[c],0,i);
Volumes[c][d][h][1] ++;
} // c
} // i Bars
for (d=0; d<5; d++)
for (h =0; h<24; h++)
{
string ss="";
for (c=0;c<13;c++) ss = ss + (Volumes[c][d][h][0] / Volumes[c][d][h][1]) + " , " ;
FileWrite(handle,ss);
}
FileClose(handle);
return(0);
}
int start()
{
return(0);
}
Comments