#_i_FFT_spectrum_Volume

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

This technical indicator is designed to analyze market activity by examining the underlying "rhythm" of trading volume rather than just looking at price movements. It employs a sophisticated mathematical approach called a Fourier Transform to break down complex data into simpler, manageable components.

Core Logic and Functionality

Data Collection The script begins by gathering specific volume data from the market history. Instead of focusing on every single tick, it looks at a defined window of recent trading activity (determined by the user-defined "n" parameter). By capturing this volume, the tool creates a raw snapshot of how much trading activity is occurring over a specific period.

Frequency Analysis Once the volume data is collected, the script applies a Fast Fourier Transform. In plain terms, this process acts like a prism for data; just as a prism separates white light into different colors, this mathematical formula separates "noisy" market data into distinct frequencies. It helps identify repeating patterns and cycles that might not be visible to the naked eye on a standard price chart.

Signal Filtering To make the information useful for a trader, the script applies a filtering system. It allows you to set minimum and maximum boundaries (Fmin and Fmax). This ensures that the indicator ignores "background noise"—the tiny, insignificant fluctuations of the market—and focuses only on the specific frequency ranges that are most relevant to your trading strategy.

Visual Representation The final result is displayed as a histogram in a separate window from the main price chart. This visualization allows you to see the strength and presence of specific market rhythms. By observing these peaks and valleys, traders can better understand the periodic nature of volume flow, potentially helping to identify when market momentum is shifting or stabilizing.

Price Data Components
Series array that contains tick volumes of each bar
Miscellaneous
Implements a curve of type %1
10 Views
0 Downloads
0 Favorites
#_i_FFT_spectrum_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 1
#property indicator_color1 Red
//#property indicator_color2 Blue
#property indicator_level1 0.0
//---- buffers
double Buffer1[];
//double Buffer2[];
//---
extern int n=7; // Äëèíà ðÿäà
extern int Fmin=2; // Ãðíèöà Ôèëüòðà ïî Í×.
extern int Fmax=128; // Ãðàíèöà Ôèëüòðà ïî Â×.
//extern string sym="GBPUSD";
//extern string sym="EURUSD";

double aa[];
int N;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM,0,2);
SetIndexBuffer(0,Buffer1);
//SetIndexStyle(1,DRAW_LINE);
//SetIndexBuffer(1,Buffer2);
//---
   N=MathPow(2,n);
   ArrayResize(aa,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) return(0);
   
   //---
   for(int i=N-1; i>=0; i--) { aa[i]=iVolume(Symbol(),0,i); }
   //---
   realfastfouriertransform(aa, N, false);
   //---
   N=ArraySize(aa);
   //Comment("n= ",N);
   //---
   for( i=0; i<=N-1; i++) 
   { 
      if( i<Fmin || i>Fmax) { aa[i]=0.0; }
   }
   //---
   //realfastfouriertransform(aa, N, true);
   //---
   SetIndexDrawBegin(0,Bars-N);
   //---
   for( i=0; i<=N-1; i++)
   {
      Buffer1[i]=aa[i];
   }
   //----
   return(0);
  }
//-------------------------------------------------------------------+

Comments