#_i_FFT_separate_Close2_D
Download scriptThis tool functions as a sophisticated frequency analyzer for financial charts, designed to break down market price movements into their fundamental components. Instead of looking at the "noise" of individual price ticks, it treats price action like an audio signal or a wave, allowing it to isolate specific patterns that might otherwise be hidden from the naked eye.
Core Logic and Methodology
1. Signal Decomposition (The Fourier Transform) The script utilizes a mathematical process known as a Fast Fourier Transform (FFT). In non-technical terms, this is like taking a complex musical chord and identifying every individual note played within it. The tool takes a set of historical closing prices and "deconstructs" them into different frequencies. It identifies which parts of the price movement are occurring rapidly (high frequency) and which are moving slowly (low frequency).
2. Comparative Analysis The logic operates on two parallel streams of data. It analyzes the current price action while simultaneously analyzing a secondary set of prices shifted backward by a specific number of bars. By processing these two streams independently, the tool can highlight differences in how market "harmonics" are evolving over time compared to where they were previously.
3. Frequency Filtering One of the most important features of this script is its ability to filter out unwanted data. The user can define a specific range of frequencies to keep while silencing others. This acts as a sophisticated "noise gate":
- It removes ultra-fast, jittery fluctuations that don't represent true trends.
- It removes extremely slow cycles that may be irrelevant to current trading decisions.
- By focusing only on the "middle" range of frequencies, it isolates the most relevant rhythmic patterns in the market.
4. Reconstruction and Visualization After the data has been decomposed into its individual frequencies and filtered for relevance, the script performs an "Inverse Transform." This reconstructs the price action back into a visual format. The result is a smoothed representation of the market trend that reflects only the specific cycles selected by the user.
Summary of Operation
Instead of showing you what the price is doing right now, this tool shows you what the price is made of. It strips away the chaos of the market, filters out the "static," and redraws the price action based on the underlying rhythmic cycles that define the current trend. This allows traders to see the underlying structure of a movement rather than just its surface appearance.
//+------------------------------------------------------------------+
//| #_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=30;//80;//2; // Ãðíèöà Ôèëüòðà ïî Í×.
extern int Fmax=60;//128; // Ãðàíèöà Ôèëüòðà ïî Â×.
//extern string sym="GBPUSD";
extern int shift=6;//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]=iClose(Symbol(),0,i);
bb[i]=iClose(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(aa, N, true);
realfastfouriertransform(bb, N, true);
//---
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