#_i_FFT_separate_Close2_W
Download scriptThis tool is designed to analyze financial market data by breaking down complex price movements into their fundamental underlying frequencies. Rather than simply looking at the raw "zig-zag" of price history, this script applies a mathematical process known as a Fast Fourier Transform (FFT). This technique allows the software to identify hidden cycles and patterns within the market noise, similar to how a prism breaks white light into its individual colors.
How the Logic Works:
- Data Collection: The script captures recent closing prices from the market. It specifically looks at two distinct sets of data points: the current price action and a slightly older segment of history (determined by a "shift" value).
- Frequency Transformation: Once the data is collected, the tool converts it from the "time domain" (where we see prices moving over minutes or hours) into the "frequency domain." In this state, the software can see which specific cycles—such as recurring trends or vibrations—are driving the market.
- Filtering: The script uses customizable boundaries to filter out unwanted interference. By setting minimum and maximum frequency limits, you can essentially "mute" the random noise of the market and focus only on the significant, repeating patterns that matter for analysis.
- Reconstruction: After filtering out the noise, the script performs an inverse transformation. This converts the cleaned data back into a readable format. The final result is presented as two distinct visual lines on your chart.
What this means for the user:
The resulting visual output represents a "cleaned" version of the market's movement. By comparing the two lines generated by the script, you are looking at the core trend of the current price action versus a shifted historical reference point, stripped of minor fluctuations and random market "static." It provides a clearer view of the underlying rhythm of the asset you are trading.
//+------------------------------------------------------------------+
//| #_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;//80;//2; // Ãðíèöà Ôèëüòðà ïî Í×.
extern int Fmax=30;//128; // Ãðàíèöà Ôèëüòðà ïî Â×.
//extern string sym="GBPUSD";
extern int shift=30;//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