Help me Slawa!! Thank you very much!

 
Please help me ! conversion code to MQL4_code
extern    int       N=10;
extern    double       P=2;
extern    double       Q=30;
extern    int       K=15;
Direction:=CLOSE - REF( CLOSE , N ) ; 
XX:=ABS( CLOSE - REF( CLOSE , 1 ) ) ; 
Volatility:=SUM( XX , N ) ; 
ER:=ABS( Direction / Volatility ) ; 
FastC:= 2 / ( p + 1 ) ; 
SlowC:= 2 / ( q + 1 ) ; 
SSC:=ER * ( FastC - SlowC ) + SlowC ; 
Constant :=SSC * SSC ; 
AMA:DMA(C, Constant);
FFilter:=( K / 100 ) * Std( AMA - REF( AMA , 1 ) , N )

my conversion code :

int start()
  {
    //---- TODO: add your code here
    int limit;
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- TODO: add your code here
 for(int i=0; i<limit; i++)
 {

//Direction:=CLOSE - REF( CLOSE , N ) ,  Direction=ExtMapBuffer3[i]
 ExtMapBuffer3[i]=Close[i]-Close[i+N];

 //XX:=ABS( CLOSE - REF( CLOSE , 1 ) ) , XX=ExtMapBuffer1[i]
ExtMapBuffer1[i]=MathAbs(Close[i+1]-Close[i]);
   }
//Volatility:=SUM( XX , N ) ; Volatility=ExtMapBuffer4[i]
 for(i=0;i<limit;i++)
 {
     swip=0;
     for(int j=0; j<N; j++)
       {
       swip=swip+ExtMapBuffer1[i+j];
       ExtMapBuffer2[i]=swip;
       }
     ExtMapBuffer4[i]=MathAbs((Close[i]-Close[i+N])/ExtMapBuffer2[i]);
//FastC:= 2 / ( p + 1 ) ; 
//SlowC:= 2 / ( q + 1 ) ; 
//SSC:=ER * ( FastC - SlowC ) + SlowC ; 
//Constant :=SSC * SSC ; Constant=ExtMapBuffer[i]
 
   FastC=2.0/(P+1.0);
   SlowC=2.0/(Q+1.0);
   ExtMapBuffer5[i]=(ExtMapBuffer4[i]*(FastC-SlowC)+SlowC)*(ExtMapBuffer4[i]*(FastC-SlowC)+SlowC);

//AMA:DMA(Close, Constant);  Y=DMA(X,A), Y=A*X+(1-A)*Y' ,Y'[i]=Y'[i-1],A<1;
AMA=???
//FFilter:=( K / 100 ) * Std( AMA - REF( AMA , 1 ) , N ) 
FFilter= ???

 }
 

Reason: