Expected_Volumes_
Download scriptThis tool is designed to provide traders with a clearer picture of "Expected Volumes" by analyzing historical trading data. Instead of simply showing you how much volume occurred in the past, it attempts to predict a baseline of what a typical trading volume looks like based on consistent patterns over time.
How the Logic Works
The script operates by looking backward through your trading history to identify recurring patterns. Here is the step-by-step breakdown of its logic:
- Historical Observation: The tool looks back at a specific number of historical periods (defined by the "history steps" setting). It doesn't just look at the most recent data; it seeks out consistent data points from many different days in the past.
- Time-Specific Filtering: To ensure accuracy, the script identifies the specific hour of the current candle. It then searches through the history to find other instances where trading occurred during that same hour. This helps the tool distinguish between "normal" volume (like a midday lull) and "high" volume (like the market open).
- Data Aggregation: Once it finds these matching historical time slots, it gathers the volume data from those specific moments. It ignores irrelevant noise and focuses only on the data points that match the current time of day.
- Averaging the Results: After gathering all relevant data points from the past, the script calculates an average. This result is then displayed as a histogram.
What This Means for the Trader
The final output—the blue histogram—represents the "Expected Volume." By comparing the current live volume against this expected volume, you can better understand market activity:
- Contextual Awareness: It helps you determine if the current trading volume is unusually high or low compared to what usually happens at that specific time of day.
- Trend Identification: If the current volume is significantly higher than the "Expected Volume," it may indicate a surge in interest or a strong breakout. Conversely, if it is much lower, it might suggest a lack of liquidity or a period of consolidation.
- Simplified Analysis: By automating the math of calculating historical averages across hundreds of past bars, the tool provides you with a steady baseline to help make more informed decisions about market momentum.
//+------------------------------------------------------------------+
//| Expected Volumes.mq4 |
//| Copyright © 2007, Amir Aliev |
//| http://finmat.blogspot.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, Amir Aliev"
#property link "http://finmat.blogspot.com"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Blue
//---- input parameters
extern int hist_steps = 100; // Number of observations
extern int span = 1; // Days to step back each time
//---- buffers
double ExtMapBuffer1[];
int sum;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicators
SetIndexStyle(0, DRAW_HISTOGRAM);
SetIndexBuffer(0,ExtMapBuffer1);
//----
short_name = "Expected volumes(" + hist_steps + ")";
IndicatorShortName(short_name);
SetIndexLabel(0, short_name);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars = IndicatorCounted();
int rest = Bars - counted_bars;
int j, k, u;
//----
while(rest >= 0)
{
if(Bars - rest < span * 23 * hist_steps)
{
ExtMapBuffer1[rest] = 0;
rest--;
continue;
}
sum = 0;
j = 0;
k = 0;
u = 0;
while(j < hist_steps && k < Bars)
{
if(TimeHour(Time[rest+k]) == TimeHour(Time[rest]))
{
u++;
if(u == span)
{
u = 0;
j++;
sum += Volume[rest + k];
}
k += 23;
}
k++;
}
ExtMapBuffer1[rest] = sum / hist_steps;
rest--;
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments