#_i_FFT_separate_Volume2

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

This tool is designed to analyze market data by looking beneath the surface of price movements, specifically focusing on the underlying "rhythm" and volume patterns of a financial instrument. Instead of simply tracking where the price goes, this script treats market activity as a complex wave—similar to how sound or radio waves are analyzed in physics.

How it Works

1. Data Collection (The Raw Input) The tool begins by collecting volume data from two different points in time. It looks at current trading volume and compares it against a historical "offset" (a specific look-back period). By capturing these two distinct snapshots of activity, the script creates a baseline for comparison.

2. Frequency Analysis (The Transformation) The core logic utilizes a mathematical process called a Fast Fourier Transform. In non-technical terms, this takes chaotic, messy market data and breaks it down into individual frequencies. Think of it like a prism: if market movement is white light, this process separates that light into individual colors. It identifies the dominant cycles and periodicities hidden within the trading volume.

3. Signal Filtering Not every frequency is useful for analysis; some are just "noise." The tool uses specific boundaries (minimum and maximum limits) to filter out these distractions. By discarding the very high and very low frequencies, it isolates the most significant trends—the "heartbeat" of the market—while smoothing out the erratic fluctuations that often cause confusion for manual traders.

4. Reconstruction and Visualization After filtering out the noise, the tool reconstructs the data back into a readable format. It then plots two distinct lines on your chart. These lines represent the cleaned-up, purified versions of the market's cycles.

The Practical Goal

By comparing these two resulting lines, the user can observe how the "rhythm" of the market is evolving over time. Because it focuses on the periodic nature of volume and frequency rather than just individual price candles, it aims to provide a clearer picture of the structural momentum and recurring patterns in the marketplace.

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
//+------------------------------------------------------------------+
//|                                            #_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