#_i_FFT_separate_Close2_H
Download scriptThis technical tool is designed to analyze financial market data by identifying and isolating specific underlying patterns that are often hidden by standard price fluctuations. Rather than simply looking at where the price is currently moving, this script applies advanced mathematical processing—specifically a technique known as a Fast Fourier Transform (FFT)—to break down market activity into its fundamental components.
How it Works
The logic operates by treating price movements as complex waves. In many financial markets, price action is composed of various different cycles: some are very fast and "noisy," while others are slow and provide the primary trend. The script works through the following stages:
- Data Collection: The tool captures a specific window of recent closing prices from the market chart.
- Frequency Decomposition: It converts these price movements from the "time domain" (where we see price moving over minutes or hours) into the "frequency domain." This allows the script to see which specific cycles are most dominant in the current data.
- Signal Filtering: The user can define specific boundaries (minimum and maximum frequencies). The logic automatically identifies and suppresses the "noise"—the irrelevant, high-frequency jitter—while preserving the core structural signals that matter for analysis.
- Reconstruction: After filtering out the unwanted noise, the script performs an inverse calculation to turn those clean signals back into a visual format.
Visual Output
The result is displayed in a separate window on your trading platform as two distinct lines. These lines represent a "cleaned" version of the market's behavior. By comparing these filtered signals against the raw price chart, traders can more clearly identify the underlying rhythm of the market, potentially making it easier to distinguish between temporary volatility and significant structural shifts in price movement.
//+------------------------------------------------------------------+
//| #_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=90;//80;//2; // Ãðíèöà Ôèëüòðà ïî Í×.
extern int Fmax=128;//128; // Ãðàíèöà Ôèëüòðà ïî Â×.
//extern string sym="GBPUSD";
extern int shift=0;//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