#_i_FFT_separate_Volume2_4H_diff

Download script
Author: Copyright � 2006, klot.
#_i_FFT_separate_Volume2_4H_diff

This tool is designed to analyze market activity by examining the underlying "rhythm" or frequency of trading volume. Rather than simply looking at how much volume occurred at a specific moment, it uses a mathematical process called a Fast Fourier Transform (FFT). This technique allows the script to break down complex price action into various cyclical patterns, similar to how a prism breaks light into different colors.

How the Logic Works

The script follows a structured four-step process to interpret market data:

1. Data Collection and Comparison The tool looks at two distinct sets of volume data simultaneously. It captures the volume from the current period and compares it against a secondary set shifted slightly forward in time. This "dual-view" approach allows the script to identify discrepancies between immediate action and the preceding market momentum.

2. Frequency Analysis By applying the Fourier Transform, the tool converts this raw volume data into different frequency components. It essentially searches for repeating cycles—identifying what is "noise" (random fluctuations) and what is a "signal" (consistent, rhythmic movement).

3. Targeted Filtering Not all frequencies are useful for trading. The script includes a specific filter range that allows the user to ignore irrelevant data points. By setting minimum and maximum boundaries, the tool focuses only on the most significant cycles, stripping away the insignificant background interference that often confuses standard indicators.

4. Difference Mapping After filtering the relevant cycles, the script performs a final calculation to find the difference between the two primary data sets. It then visualizes this "delta" or variance in three ways:

  • Positive Deviations: Highlighted when one data set exceeds the other.
  • Negative Deviations: Highlighted when the opposite occurs.
  • Net Variance: A continuous line that tracks the overall spread between the two signals.

Summary for the User

In plain terms, this script acts as a "noise filter" for trading volume. It helps traders see the underlying pulse of the market by identifying significant rhythmic patterns while ignoring random market chatter. By visualizing the difference between these filtered rhythms, it provides a clearer picture of where the momentum is shifting.

Price Data Components
Series array that contains tick volumes of each bar
Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
#_i_FFT_separate_Volume2_4H_diff
//+------------------------------------------------------------------+
//|                                            #_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 3
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 Yellow
#property indicator_level1 0.0
//#property indicator_level1 0.0
//#property indicator_level1 0.0
//---- buffers
double Buffer1[];
double Buffer2[];
double Buffer3[];
//---
extern int n=7; // Äëèíà ðÿäà
extern int Fmin=60;//2; // Ãðíèöà Ôèëüòðà ïî Í×.
extern int Fmax=90;//128; // Ãðàíèöà Ôèëüòðà ïî Â×.
extern int shift=1;//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_HISTOGRAM,0,2);
SetIndexBuffer(0,Buffer1);
SetIndexStyle(1,DRAW_HISTOGRAM,0,2);
SetIndexBuffer(1,Buffer2);
SetIndexStyle(2,DRAW_LINE,0,2);
SetIndexBuffer(2,Buffer3);
//---
   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++)
   {
       double diff1=bb[i]-aa[i];
      if (diff1>0)
        Buffer2[i]=diff1;
      //Buffer2[i+shift]=bb[i];
      else if (diff1<0)
        Buffer1[i]=diff1;          
      Buffer3[i]=diff1;  
        
   }
   //----
   return(0);
  }
//-------------------------------------------------------------------+

Comments