//+------------------------------------------------------------------+ //| #_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 Lime #property indicator_level1 0.0 //#property indicator_level1 0.0 //#property indicator_level1 0.0 //---- buffers double Buffer1[]; double Buffer2[]; //--- /* EURUSD 4h 0. frequency zone = 2 ( Fmin=2; Fmax=128) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //1. frequency zone = 8 ( Fmin=6; Fmax=10) //2. frequency zone = 14 (Fmin=12;Fmax=16) //3. frequency zone = 18 (Fmin=17;Fmax=19) //4. frequency zone = 22 (Fmin=21;Fmax=23) //5. frequency zone = 26 (Fmin=25;Fmax=27) //6. frequency zone = 35 (Fmin=33;Fmax=37) //7. frequency zone = 48 (Fmin=46;Fmax=50) //8. frequency zone = 76 (Fmin=74;Fmax=78) //9. frequency zone = 118 (Fmin=115;Fmax=121) */ extern int n=9; // Äëèíà ðÿäà //extern int Fmin0=2; //extern int Fmax0=128; //1. frequency zone = 8 ( Fmin=6; Fmax=10) extern int Fmin1=1; extern int Fmax1=3; //2. frequency zone = 14 (Fmin=12;Fmax=16) extern int Fmin2=7; extern int Fmax2=9; //3. frequency zone = 18 (Fmin=17;Fmax=19) extern int Fmin3=27; extern int Fmax3=28; //4. frequency zone = 22 (Fmin=21;Fmax=23) extern int Fmin4=34; extern int Fmax4=35; //5. frequency zone = 26 (Fmin=25;Fmax=27) extern int Fmin5=0; extern int Fmax5=0; //6. frequency zone = 35 (Fmin=33;Fmax=37) extern int Fmin6=0; extern int Fmax6=0; //7. frequency zone = 48 (Fmin=46;Fmax=50) extern int Fmin7=0; extern int Fmax7=0; //8. frequency zone = 76 (Fmin=74;Fmax=78) extern int Fmin8=0; extern int Fmax8=0; //9. frequency zone = 118 (Fmin=115;Fmax=121) extern int Fmin9=0; extern int Fmax9=0; //extern string sym="GBPUSD"; //extern string sym="EURUSD"; double aa[]; double bb[]; int N; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE,0,5); SetIndexBuffer(0,Buffer1); SetIndexStyle(1,DRAW_LINE,0,5); SetIndexBuffer(1,Buffer2); //--- N=MathPow(2,n); ArrayResize(aa,N); //ArrayResize(bb,N); /* if( Fmax1>=N ) Fmax1=N; if( Fmin1<=2 ) Fmin1=2; if( Fmax2>=N ) Fmax2=N; if( Fmin2<=2 ) Fmin2=2; if( Fmax3>=N ) Fmax3=N; if( Fmin3<=2 ) Fmin3=2; if( Fmax4>=N ) Fmax4=N; if( Fmin4<=2 ) Fmin4=2; if( Fmax5>=N ) Fmax5=N; if( Fmin5<=2 ) Fmin5=2; if( Fmax6>=N ) Fmax6=N; if( Fmin6<=2 ) Fmin6=2; if( Fmax7>=N ) Fmax7=N; if( Fmin7<=2 ) Fmin7=2; if( Fmax8>=N ) Fmax8=N; if( Fmin8<=2 ) Fmin8=2; if( Fmax9>=N ) Fmax9=N; if( Fmin9<=2 ) Fmin9=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); //bb[i]=iClose(Symbol(),0,i); } //--- InSigNormalize(aa); InSigNormalize(bb); realfastfouriertransform(aa, N, false); //realfastfouriertransform(bb, N, false); //--- N=ArraySize(aa); //Comment("n= ",N); //--- for( i=0; i<=N-1; i++) { if( (i<Fmin1 || i>Fmax1) && (i<Fmin2 || i>Fmax2) && (i<Fmin3 || i>Fmax3) && (i<Fmin4 || i>Fmax4) && (i<Fmin5 || i>Fmax5) && (i<Fmin6 || i>Fmax6) && (i<Fmin7 || i>Fmax7) && (i<Fmin8 || i>Fmax8) && (i<Fmin9 || i>Fmax9) ) { aa[i]=0.0; } //if( i<Fmin0 || i>Fmax0) { bb[i]=0.0; } } //--- realfastfouriertransform(aa, N, true); //realfastfouriertransform(bb, N, true); //--- SetIndexDrawBegin(0,Bars-N); SetIndexDrawBegin(1,Bars-N); //--- for( i=0; i<=N-1; i++) { Buffer1[i]=aa[i]; //Buffer2[i]=bb[i]; } //---- return(0); } //-------------------------------------------------------------------+ //--------------------------------------------------------------------+ void InSigNormalize(double& aa[]) { double sum_sqrt; int element_count=ArraySize(aa); sum_sqrt=0; for( int i=0; i<=element_count-1; i++) { sum_sqrt+=MathPow(aa[i],2); } sum_sqrt=MathSqrt(sum_sqrt); if (sum_sqrt!=0) { for( i=0; i<=element_count-1; i++) { aa[i]=aa[i]/sum_sqrt; } } return; }
Sample
Analysis
Market Information Used:
Series array that contains close prices for each bar
Indicator Curves created:
Implements a curve of type DRAW_LINE
Indicators Used:
Custom Indicators Used:
#_lib_FFT
Order Management characteristics:
Other Features: