#_i_FFT_spectrum_Speedometer_sell
Download scriptThis tool functions as a sophisticated visual analyzer designed to decompose market price movements into their underlying frequencies. Rather than simply looking at the price on a standard chart, this script treats market data like a sound wave or a physical vibration, allowing it to identify hidden patterns and cycles that are typically invisible to the naked eye.
How the Logic Works
The system operates through a three-step process of data collection, mathematical transformation, and selective filtering:
1. Data Acquisition The tool begins by gathering specific momentum or velocity data from another specialized indicator (the "Speedometer"). It captures a set amount of recent market history—determined by a user-defined window size—to create a foundation for analysis.
2. Frequency Transformation (Fast Fourier Transform) The core of this script is a mathematical process known as a Fast Fourier Transform (FFT). This logic takes complex, "messy" price data and breaks it down into individual frequency components. Think of this like a prism taking white light and splitting it into a rainbow of colors; the script takes erratic market fluctuations and identifies the specific "beats" or cycles that are driving those movements.
3. Noise Filtering Once the data is broken down into frequencies, the tool applies a filter to remove unnecessary "noise." By setting minimum and maximum frequency boundaries, the script ignores very high-frequency jitter (micro-movements) and very low-frequency trends that might be irrelevant to your trading timeframe. It focuses specifically on the "heartbeat" of the market that falls within your chosen range.
Visual Representation
The final result is displayed in a separate window as a histogram. Each bar represents the strength of a specific frequency. By observing these levels, you can see which cycles are currently dominant in the market, helping you identify repetitive patterns or structural shifts in price momentum that standard candles cannot reveal.
//+------------------------------------------------------------------+
//| #_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
//---- buffers
double Buffer1[];
//double Buffer2[];
//---
extern int n=7; // Äëèíà ðÿäà
extern int Fmin=2; // Ãðíèöà Ôèëüòðà ïî Í×.
extern int Fmax=128; // Ãðàíèöà Ôèëüòðà ïî Â×.
//extern string sym="GBPUSD";
//extern string sym="EURUSD";
double aa[];
int N;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM,0,2);
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]=iCustom(Symbol(),0,"Speedometer_v1_mod_v01",0,1,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