#_i_FFT_separate_Volume3
Download scriptThis technical indicator is designed to analyze market activity by focusing on volume data rather than price movement alone. It uses a sophisticated mathematical process to "deconstruct" the trading volume into its underlying patterns, helping traders visualize specific cycles or trends that might not be obvious to the naked eye.
How the Logic Works
1. Data Collection The script looks at two distinct segments of trading volume on the chart. By comparing a recent block of volume data against an older historical block (determined by a specific "shift" setting), the tool can identify how market behavior has changed over time.
2. Frequency Analysis (Fourier Transform) The core of this script is a mathematical technique called a Fourier Transform. In simple terms, this process takes a complex set of data (like volatile trading volume) and breaks it down into different frequencies—much like how a prism splits white light into individual colors. This allows the tool to separate "noise" from meaningful repeating patterns or cycles in the market.
3. Filtering and Isolation Not all frequency data is useful. The script uses specific boundaries (Minimum and Maximum frequency limits) to filter out unnecessary information. By isolating only the specific frequencies of interest, it removes random market fluctuations and highlights the dominant rhythms of the trading volume.
4. Reconstruction and Visualization After filtering out the "noise," the script reconstructs the data back into a readable format. It then plots two separate lines on a dedicated window:
- The Primary Line: Shows the processed volume pattern for the most recent period.
- The Secondary Line: Shows the processed pattern for the historical period.
Practical Purpose
By displaying these two reconstructed patterns side-by-side, the indicator allows you to visually compare current market "rhythms" against past behavior. If the current wave pattern matches a previous known cycle, it can provide a visual cue regarding potential trend continuity or exhaustion in trading volume.
//+------------------------------------------------------------------+
//| #_i_SpecktrAnalis.mq4 |
//| Copyright © 2006, klot. |
//| klot@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, klot."
#property link "klot@mail.ru"
#import "#_lib_FFT.ex4"
void realfastfouriertransform(double& a[], int tnn, bool inversefft);
#import
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_level1 0.0
//#property indicator_level1 0.0
//#property indicator_level1 0.0
//---- buffers
double Buffer1[];
double Buffer2[];
//---
extern int n=7; // Äëèíà ðÿäà
extern int Fmin=2;//2; // Ãðíèöà Ôèëüòðà ïî Í×.
extern int Fmax=128;//128; // Ãðàíèöà Ôèëüòðà ïî Â×.
extern int shift=127;//127;
//extern string sym="GBPUSD";
//extern string sym="EURUSD";
double aa[];
double bb[];
int N;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,Buffer1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,Buffer2);
//---
N=MathPow(2,n);
ArrayResize(aa,N);
ArrayResize(bb,N);
if( Fmax>=N ) Fmax=N;
if( Fmin<=2 ) Fmin=2;
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
if( Bars<N+shift) return(0);
//---
for(int i=N-1; i>=0; i--)
{
aa[i]=iVolume(Symbol(),0,i);
bb[i]=iVolume(Symbol(),0,i+shift);
}
//---
realfastfouriertransform(aa, N, false);
realfastfouriertransform(bb, N, false);
//---
N=ArraySize(aa);
//Comment("n= ",N);
//---
for( i=0; i<=N-1; i++)
{
if( i<Fmin || i>Fmax) { aa[i]=0.0;bb[i]=0.0; }
}
//---
//realfastfouriertransform(double& a[], int tnn, bool inversefft);
realfastfouriertransform(aa, N, true);
realfastfouriertransform(bb, N, true);
//tworealffts(double a1[], double a2[], double& a[], double& b[], int tn);
//---
SetIndexDrawBegin(0,Bars-N);
SetIndexDrawBegin(1,Bars-N-shift);
//SetIndexDrawBegin(1,Bars-N);
//---
for( i=0; i<=N-1; i++)
{
Buffer1[i]=aa[i];
Buffer2[i+shift]=bb[i];
//Buffer2[i]=bb[i];
}
//----
return(0);
}
//-------------------------------------------------------------------+
Comments