#_i_FFT_separate_Volume2_W_D_diff_001

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

This script functions as a sophisticated technical analysis tool designed to break down market data into its fundamental components. Instead of looking at price movements in a simple linear fashion, it utilizes mathematical principles similar to how sound engineers analyze audio waves to identify specific frequencies.

Core Logic and Methodology

The primary objective of this tool is to isolate and visualize specific "cycles" or patterns within the trading volume. It accomplishes this through the following logical steps:

1. Data Collection and Comparison The script captures trading volume data from two distinct points in time simultaneously. By looking at the current volume and comparing it to a slightly delayed version of itself (determined by a user-defined "shift"), the tool can detect changes in the rhythm of market activity.

2. Frequency Transformation Once the data is collected, the script performs a mathematical process called a Fast Fourier Transform (FFT). In non-technical terms, this converts the raw trading data from the "time domain" (how much volume happened at what time) into the "frequency domain" (how fast or slow different market cycles are repeating). This allows the tool to identify underlying periodicities that are usually hidden by standard price charts.

3. Filtering and Focus The logic includes a specific filter range. Because markets are filled with "noise" (random, insignificant fluctuations), the script is designed to ignore frequencies that are too low or too high. It focuses only on a specific window of activity, effectively cleaning the data so that only the most relevant cycles remain visible to the user.

4. Reconstruction and Visualization After identifying and filtering these cycles, the script "reconstructs" the data back into a readable format. It then calculates the difference between the two compared data sets. The final result is displayed on your chart in three distinct visual formats:

  • Positive Deviations: Highlighted to show where the secondary data set exceeds the primary.
  • Negative Deviations: Highlighted to show where the primary data set exceeds the secondary.
  • Net Difference: A continuous line representing the overall variance between the two filtered cycles.

Summary of Utility

By using this logic, the tool helps traders see beyond the immediate "up and down" movement of price. It attempts to reveal the underlying pulse of the market, showing whether the current volume trends are accelerating, decelerating, or repeating based on specific historical cycles.

Price Data Components
Series array that contains tick volumes of each bar
Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
#_i_FFT_separate_Volume2_W_D_diff_001
//+------------------------------------------------------------------+
//|                                            #_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=2;//2; // Ãðíèöà Ôèëüòðà ïî Í×.
extern int Fmax=60;//128; // Ãðàíèöà Ôèëüòðà ïî Â×.
extern int shift=6;//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);
SetIndexEmptyValue(0,0);
SetIndexStyle(1,DRAW_HISTOGRAM,0,2);
SetIndexBuffer(1,Buffer2);
SetIndexEmptyValue(1,0);
SetIndexStyle(2,DRAW_LINE,0,2);
SetIndexBuffer(2,Buffer3);
SetIndexEmptyValue(2,0);
//---
//---
   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