#_i_FFT_spectrum_Speed

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

This tool is designed as a specialized technical analysis indicator that interprets market price movements by looking at their underlying frequencies. Rather than just following the price trends directly, it analyzes the "rhythm" of the market to identify specific patterns.

How the Logic Works

1. Data Gathering (The Input) The script begins by collecting data from a secondary source—a momentum-based "Speed" indicator. It looks at a specific number of recent candles (defined by the user) to understand how fast and in what direction the price is moving at any given moment.

2. Frequency Transformation Once it has this speed data, the tool performs a mathematical process known as a Fast Fourier Transform (FFT). In simple terms, this converts the price movements from a "time" perspective into a "frequency" perspective. Just as a music visualizer can break down a song into different notes or pitches, this logic breaks down market price action into different cycles and frequencies.

3. Filtering the Noise Not all data is useful for trading. The script uses specific boundaries (Minimum and Maximum Frequency) to filter out the "noise." By doing this, it ignores very high-frequency jitters (random fluctuations) and very low-frequency movements that might be irrelevant. It focuses on the specific frequency range that the user chooses to highlight, effectively isolating the most meaningful market signals.

4. Visualizing the Result The final output is displayed as a histogram in a separate window. Each bar represents the strength of a specific frequency within the chosen range. This allows traders to see which specific "rhythms" are currently dominant in the market, helping to distinguish between significant structural moves and minor price noise.

Miscellaneous
Implements a curve of type %1
8 Views
0 Downloads
0 Favorites
#_i_FFT_spectrum_Speed
//+------------------------------------------------------------------+
//|                                            #_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]=iCustom(Symbol(),0,"Speed",true,0,5,20,20,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