#_i_FFT_separate_Volume2_D_diff

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

This tool is designed to analyze market data by looking beyond simple price movements and focusing on the underlying "frequency" of trading activity. By using a sophisticated mathematical technique called a Fourier Transform, the script breaks down complex price and volume information into individual components to identify patterns that might not be visible to the naked eye.

How the Logic Works

1. Data Collection & Comparison The script monitors two distinct sets of market data simultaneously. It captures trading volume from the current point in time and compares it against a historical "shifted" timeframe. By looking at these two different windows of time side-by-side, the tool can detect shifts in momentum or changes in how aggressively the market is moving.

2. Frequency Analysis (The "Spectrum") Once the data is collected, the script performs a transformation that treats price and volume as waves. It decomposes these waves into different frequencies—essentially identifying which parts of the market movement are "noise" and which parts represent significant, repeating cycles.

3. Precision Filtering Not all data gathered is useful. The logic includes specific filters (minimum and maximum boundaries) that allow it to ignore insignificant fluctuations. By focusing only on a specific range of frequencies, the tool clears away the "static" of the market, highlighting only the most relevant structural trends.

4. Signal Generation After filtering the data, the script performs an inverse calculation to project those findings back onto your chart. It then calculates the difference between the two compared timeframes:

  • Positive Deviations: When one timeframe shows significantly more activity or strength than the other, it is plotted as one visual element.
  • Negative Deviations: When the opposite occurs, it is plotted as a different visual element.
  • Net Difference: A third line tracks the total variance between the two periods.

Summary for the User

In simple terms, this indicator acts like a "noise-canceling" filter for market data. It takes raw trading volume, breaks it down into its core frequencies, filters out the unimportant movements, and then shows you the net difference between current market behavior and a previous period. This helps traders visualize where the "hidden" momentum is shifting before it becomes obvious on a standard price chart.

Price Data Components
Series array that contains tick volumes of each bar
Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
#_i_FFT_separate_Volume2_D_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=30;//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
//---- 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