LaguerreVolume
Download scriptThis tool is designed to provide a specialized visual analysis of trading volume by applying a sophisticated smoothing and balancing technique. Rather than looking at raw, erratic spikes in market activity, it filters the data to identify more meaningful trends in how volume is moving over time.
Core Logic Overview
The indicator operates through a three-step process to translate raw volume into a readable percentage scale:
1. Data Smoothing (Laguerre Filtering) The script first takes the raw trading volume and subjects it to a mathematical filter. By using a specific "gamma" factor (a weighting constant), the tool balances the importance of the most recent volume data against historical data. This prevents minor, insignificant fluctuations from creating "noise," resulting in a smoother line that highlights the underlying momentum of market activity.
2. Dynamic Comparison Once the data is smoothed, the script creates a series of layered values. It compares these values against one another to determine whether the volume trend is currently expanding or contracting. It effectively looks at the "distance" between different stages of the volume cycle to see if the market is accelerating or decelerating.
3. Relative Strength Calculation The final step converts these comparisons into a normalized ratio. Instead of showing you raw numbers (which can vary wildly depending on the asset), it calculates a relative strength value. This result is displayed on a scale typically ranging from 0 to 1.
How to Interpret the Results
The output provides a clear picture of volume momentum:
- When the value moves toward the higher end of the scale, it suggests that the current volume trend is gaining strength or intensity relative to its recent history.
- When the value drops toward the lower end, it indicates that the volume momentum is weakening.
By using this logic, traders can better visualize whether the "effort" behind a price move (the volume) is increasing or decreasing, helping to identify potential exhaustion points or high-conviction trends in a way that raw volume charts cannot show alone.
//+-------------------------------------------------------------------------+
//| LaguerreVolume.mq4 |
//| Emerald King, t_david |
//| http://finance.groups.yahoo.com/group/MetaTrader_Experts_and_Indicators |
//+-------------------------------------------------------------------------+
#property link "http://finance.groups.yahoo.com/group/MetaTrader_Experts_and_Indicators"
#property indicator_separate_window
#property indicator_minimum -0.05
#property indicator_maximum 1.05
#property indicator_color1 Orange
#property indicator_level2 1.0
#property indicator_level3 0.75
#property indicator_level4 0.50
#property indicator_level5 0.25
#property indicator_level6 0.0
//---- input parameters
extern double gamma = 0.618;
extern int CountBars = 300;
double L0 = 0;
double L1 = 0;
double L2 = 0;
double L3 = 0;
double L0A = 0;
double L1A = 0;
double L2A = 0;
double L3A = 0;
double LRSI = 0;
double CU = 0;
double CD = 0;
double val1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
SetIndexBuffer(0,val1);
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
if (CountBars>Bars) CountBars=Bars;
SetIndexDrawBegin(0,Bars-CountBars);
int i;
int counted_bars=IndicatorCounted();
i=CountBars-1;
while(i>=0)
{
L0A = L0;
L1A = L1;
L2A = L2;
L3A = L3;
L0 = ((1 - gamma)*(Volume[i])) + (gamma*L0A);
L1 = - gamma *L0 + L0A + gamma *L1A;
L2 = - gamma *L1 + L1A + gamma *L2A;
L3 = - gamma *L2 + L2A + gamma *L3A;
CU = 0;
CD = 0;
if (L0 >= L1) CU = L0 - L1; else CD = L1 - L0;
if (L1 >= L2) CU = CU + L1 - L2; else CD = CD + L2 - L1;
if (L2 >= L3) CU = CU + L2 - L3; else CD = CD + L3 - L2;
if (CU + CD != 0) LRSI = CU / (CU + CD);
val1[i] = LRSI;
i--;
}
return(0);
}
//+------------------------------------------------------------------+
Comments