VolumeMeans
Download scriptThis script is designed to analyze and export trading volume data across a broad range of major currency pairs into an external spreadsheet format. Instead of displaying a visual chart on your trading platform, its primary purpose is to perform a comprehensive data "audit" of market activity based on specific timeframes.
Core Functionality
The tool processes 13 different currency pairs simultaneously (including popular combinations like EURUSD, USDJPY, and GBPUSD). It scans the historical price data to calculate the average trading volume for every hour of every day of the week.
How the Logic Works:
- Data Collection: The script iterates through every available "bar" (historical price candle) in your current chart history.
- Time Categorization: For each individual bar, it identifies two key pieces of information: the specific hour of the day (0–23) and the day of the week.
- Volume Aggregation: It collects the total volume recorded for each currency pair during those specific hours and keeps a count of how many bars occurred in that timeframe.
- Averaging: Once it has scanned all available history, it calculates a mathematical average by dividing the total volume by the number of occurrences for every hour of every day.
The Final Output
The results are organized into a structured CSV file (titled "Volumes.csv"). This file provides a systematic map of market liquidity, showing you which hours of the week tend to have the highest and lowest trading activity across all 13 monitored currencies. It effectively transforms raw historical data into a summarized report that helps identify peak trading periods.
//+------------------------------------------------------------------+
//| 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