#_i_FFT_separate_Close
Download scriptThe SpecktrAnalis tool is a specialized technical indicator designed to analyze financial market data by looking at the "hidden" frequencies within price movements. Rather than simply following the price line (which can be volatile and noisy), this script treats price action like a sound wave or a radio signal, allowing it to identify underlying patterns that are often invisible to the naked eye.
How it Works: The Core Logic
The logic operates through a sophisticated three-step process of translation, filtering, and reconstruction:
1. Frequency Translation (Decomposition) The script begins by taking a specific sequence of recent closing prices and converting them into a frequency spectrum. Using a mathematical technique known as a Fast Fourier Transform, the tool breaks down complex price fluctuations into their individual components. Think of this like taking a recorded song and separating it so you can hear every individual instrument—the "bass," the "treble," and the "rhythm"—separately.
2. Targeted Filtering Once the price data is broken down into these various frequencies, the tool applies a specific filter based on user-defined boundaries (Minimum and Maximum). By doing this, the script intentionally ignores the "noise" of the market—the tiny, insignificant vibrations caused by minor fluctuations—and focuses only on the core structural movements. It effectively mutes the static so that only the most meaningful trends remain visible.
3. Reconstruction (Synthesis) After the unwanted noise has been removed, the script performs an inverse operation. It takes the "cleaned" frequencies and reconstructs them back into a visual price line. The result is a smoothed representation of the market's primary trend. Because the erratic "jitter" has been stripped away during the filtering stage, the resulting line provides a clearer picture of the core direction of the asset.
Key Features for the User
- Noise Reduction: By isolating specific frequency ranges, the indicator helps traders see through market "static," potentially providing a cleaner view of long-term momentum.
- Customizable Range: Users can adjust the sensitivity of the analysis by defining which frequencies to keep and which to discard, allowing for different levels of smoothing depending on the trading style.
- Data Integrity: The tool processes a specific "window" of data points to ensure that the frequency analysis remains consistent and relevant to the current market price.
//+------------------------------------------------------------------+
//| #_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
//#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=50;//128; // Ãðàíèöà Ôèëüòðà ïî Â×.
//extern string sym="GBPUSD";
//extern string sym="EURUSD";
double aa[];
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);
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]=iClose(Symbol(),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