Navigation:Home > Content >

ang_Фурье.mq4

Time: 2010-02-03 | Download file:ang_Фурье.mq4

#property  copyright "ANG3110@latchess.com"
//----------------------------------------
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Yellow
//-------------------------------
#import "af_T3.ex4"
int   af_T3( int i,int pt3, double ct3);
//-------------------------------
extern int hrf = 2;
extern int hrT3 = 6;
extern int days = 1;
//-----------------------------------------
double ak[],bk[],fx[],w,ak0,ss,sc,sk,dfx[];
double pi=3.1415926535897932384626433832795;
int T,sm,k;
double t3[],ct3,dc[];
int pt3;
//==========================================
int init() {
    IndicatorBuffers(5);
    SetIndexStyle(0,DRAW_LINE); 
    SetIndexBuffer(0,fx);
    SetIndexBuffer(1,t3);
    SetIndexBuffer(2,ak);
    SetIndexBuffer(3,bk);
    SetIndexBuffer(4,dc);
//--------------------------
pt3=hrT3*60/Period();
T=days*1440/Period(); 
w=2*pi/T;     
k=T/(hrf*60/Period());
return(0); }
//***************************************************
int start() {
//-----------------
int n,i,cbi;
//------------------
cbi=Bars-IndicatorCounted()-2;
for(i=cbi; i>=0; i--) {
//---------------------
ct3=Close[i];
t3[i]=af_T3(i,pt3,ct3);
dc[i]=Close[i]-t3[i];
}
//-------------------------- 
ak0=0.0;
for (n=0; n<=k; n++) { sc=0.0; ss=0.0;  
for (i=0; i<=T-1; i++) {
if (n==0) ak0+=dc[i]; 
if (n!=0) {sc=sc+dc[i]*MathCos(n*i*w); ss=ss+dc[i]*MathSin(n*i*w);} }
ak[n]=sc*2/T; bk[n]=ss*2/T; }
ak0=ak0/T; 
//--------------------------
for (i=0; i<=T-1; i++) { sk=0.0;
for (n=1; n<=k; n++) {
sk=sk+ak[n]*MathCos(n*i*w)+bk[n]*MathSin(n*i*w);}
fx[i]=ak0+sk+t3[i];  
} 
//---------------------------
 return(0); }
//****************************************************

Recommend