#_i_FFT_separate_Close3
Download scriptThis tool is designed to analyze market price movements by breaking down complex price action into its underlying cycles and frequencies. Rather than simply looking at where the price is moving right now, this script uses a mathematical technique called a "Fast Fourier Transform" to identify the rhythmic patterns—the "heartbeat"—of the market.
How it works:
1. Data Collection and Comparison The tool looks at two distinct sets of historical price data simultaneously. It captures a specific window of recent price movements and compares it against a previous period (determined by a user-defined "shift"). By comparing these two segments, the script can identify how market rhythms are evolving over time.
2. Frequency Analysis The core logic processes these price sets to extract their component frequencies. Think of this like an equalizer on a stereo system: it takes a messy, complex sound (the price chart) and separates it into individual notes or tones. The script identifies which cycles are the strongest and most dominant in the current market environment.
3. Signal Filtering To ensure the analysis remains useful and isn't overwhelmed by "noise" (minor, insignificant price fluctuations), the tool includes a built-in filtering system. You can define specific boundaries for the frequencies you want to observe. By ignoring the very high-frequency jitter and the very low-frequency trends that may be irrelevant, the tool focuses on the specific range of cycles that are most likely to influence your trading decisions.
4. Reconstruction and Visualization Once the dominant frequencies are identified and filtered, the script performs a "reverse" calculation to reconstruct a refined version of the price movement. This results in two distinct visual lines:
- One represents the cleaned-up, cyclical rhythm of the current price action.
- The other represents the rhythm from the previous period.
Purpose for the User
By visualizing these processed cycles, the tool helps traders see the "hidden" structure of the market. It allows you to observe how different periodicities interact and move, potentially helping you identify recurring patterns that are not easily visible on a standard price chart.
//+------------------------------------------------------------------+
//| #_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=128;//128; // Ãðàíèöà Ôèëüòðà ïî Â×.
//extern string sym="GBPUSD";
extern int shift=127;//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