# 急求AA-BB的写法

AA:=MA(CLOSE,5);

BB:=REF(AA,1);

//--------------------------------------------------------------------------------------------------------------
double kd0=(iClose(NULL,PERIOD_D1,0)+iOpen(NULL,PERIOD_D1,0)+iHigh(NULL,PERIOD_D1,0)+iLow(NULL,PERIOD_D1,0))/4;
double kd1=(iClose(NULL,PERIOD_D1,1)+iOpen(NULL,PERIOD_D1,1)+iHigh(NULL,PERIOD_D1,1)+iLow(NULL,PERIOD_D1,1))/4;
double kd2=(iClose(NULL,PERIOD_D1,2)+iOpen(NULL,PERIOD_D1,2)+iHigh(NULL,PERIOD_D1,2)+iLow(NULL,PERIOD_D1,2))/4;
double kd3=(iClose(NULL,PERIOD_D1,3)+iOpen(NULL,PERIOD_D1,3)+iHigh(NULL,PERIOD_D1,3)+iLow(NULL,PERIOD_D1,3))/4;
double kd4=(iClose(NULL,PERIOD_D1,4)+iOpen(NULL,PERIOD_D1,4)+iHigh(NULL,PERIOD_D1,4)+iLow(NULL,PERIOD_D1,4))/4;
double kd5=(iClose(NULL,PERIOD_D1,5)+iOpen(NULL,PERIOD_D1,5)+iHigh(NULL,PERIOD_D1,5)+iLow(NULL,PERIOD_D1,5))/4;
double kd6=(iClose(NULL,PERIOD_D1,6)+iOpen(NULL,PERIOD_D1,6)+iHigh(NULL,PERIOD_D1,6)+iLow(NULL,PERIOD_D1,6))/4;
double kd7=(iClose(NULL,PERIOD_D1,7)+iOpen(NULL,PERIOD_D1,7)+iHigh(NULL,PERIOD_D1,7)+iLow(NULL,PERIOD_D1,7))/4;
double kd8=(iClose(NULL,PERIOD_D1,8)+iOpen(NULL,PERIOD_D1,8)+iHigh(NULL,PERIOD_D1,8)+iLow(NULL,PERIOD_D1,8))/4;
double kd9=(iClose(NULL,PERIOD_D1,9)+iOpen(NULL,PERIOD_D1,9)+iHigh(NULL,PERIOD_D1,9)+iLow(NULL,PERIOD_D1,9))/4;
double kd10=(iClose(NULL,PERIOD_D1,10)+iOpen(NULL,PERIOD_D1,10)+iHigh(NULL,PERIOD_D1,10)+iLow(NULL,PERIOD_D1,10))/4;

double pd1=kd0;
double pd2=(kd0+kd1)/2;
double pd3=(kd0+kd1+kd2)/3;
double pd4=(kd0+kd1+kd2+kd3)/4;
double pd5=(kd0+kd1+kd2+kd3+kd4)/5;
double pd6=(kd0+kd1+kd2+kd3+kd4+kd5)/6;
double pd7=(kd0+kd1+kd2+kd3+kd4+kd5+kd6)/7;
double pd8=(kd0+kd1+kd2+kd3+kd4+kd5+kd6+kd7)/8;
double pd9=(kd0+kd1+kd2+kd3+kd4+kd5+kd6+kd7+kd8)/9;

double pd10=(kd0+kd1+kd2+kd3+kd4+kd5+kd6+kd7+kd8+kd9)/10;//----------------十日均价
double pd11=(kd1+kd2+kd3+kd4+kd5+kd6+kd7+kd8+kd9+kd10)/10;//--------------前十日均价///自己理解下5日怎么弄，

23581321:
//--------------------------------------------------------------------------------------------------------------
double kd0=(iClose(NULL,PERIOD_D1,0)+iOpen(NULL,PERIOD_D1,0)+iHigh(NULL,PERIOD_D1,0)+iLow(NULL,PERIOD_D1,0))/4;
double kd1=(iClose(NULL,PERIOD_D1,1)+iOpen(NULL,PERIOD_D1,1)+iHigh(NULL,PERIOD_D1,1)+iLow(NULL,PERIOD_D1,1))/4;
double kd2=(iClose(NULL,PERIOD_D1,2)+iOpen(NULL,PERIOD_D1,2)+iHigh(NULL,PERIOD_D1,2)+iLow(NULL,PERIOD_D1,2))/4;
double kd3=(iClose(NULL,PERIOD_D1,3)+iOpen(NULL,PERIOD_D1,3)+iHigh(NULL,PERIOD_D1,3)+iLow(NULL,PERIOD_D1,3))/4;
double kd4=(iClose(NULL,PERIOD_D1,4)+iOpen(NULL,PERIOD_D1,4)+iHigh(NULL,PERIOD_D1,4)+iLow(NULL,PERIOD_D1,4))/4;
double kd5=(iClose(NULL,PERIOD_D1,5)+iOpen(NULL,PERIOD_D1,5)+iHigh(NULL,PERIOD_D1,5)+iLow(NULL,PERIOD_D1,5))/4;
double kd6=(iClose(NULL,PERIOD_D1,6)+iOpen(NULL,PERIOD_D1,6)+iHigh(NULL,PERIOD_D1,6)+iLow(NULL,PERIOD_D1,6))/4;
double kd7=(iClose(NULL,PERIOD_D1,7)+iOpen(NULL,PERIOD_D1,7)+iHigh(NULL,PERIOD_D1,7)+iLow(NULL,PERIOD_D1,7))/4;
double kd8=(iClose(NULL,PERIOD_D1,8)+iOpen(NULL,PERIOD_D1,8)+iHigh(NULL,PERIOD_D1,8)+iLow(NULL,PERIOD_D1,8))/4;
double kd9=(iClose(NULL,PERIOD_D1,9)+iOpen(NULL,PERIOD_D1,9)+iHigh(NULL,PERIOD_D1,9)+iLow(NULL,PERIOD_D1,9))/4;
double kd10=(iClose(NULL,PERIOD_D1,10)+iOpen(NULL,PERIOD_D1,10)+iHigh(NULL,PERIOD_D1,10)+iLow(NULL,PERIOD_D1,10))/4;

double pd1=kd0;
double pd2=(kd0+kd1)/2;
double pd3=(kd0+kd1+kd2)/3;
double pd4=(kd0+kd1+kd2+kd3)/4;
double pd5=(kd0+kd1+kd2+kd3+kd4)/5;
double pd6=(kd0+kd1+kd2+kd3+kd4+kd5)/6;
double pd7=(kd0+kd1+kd2+kd3+kd4+kd5+kd6)/7;
double pd8=(kd0+kd1+kd2+kd3+kd4+kd5+kd6+kd7)/8;
double pd9=(kd0+kd1+kd2+kd3+kd4+kd5+kd6+kd7+kd8)/9;

double pd10=(kd0+kd1+kd2+kd3+kd4+kd5+kd6+kd7+kd8+kd9)/10;//----------------十日均价
double pd11=(kd1+kd2+kd3+kd4+kd5+kd6+kd7+kd8+kd9+kd10)/10;//--------------前十日均价///自己理解下5日怎么弄，

23581321:
//--------------------------------------------------------------------------------------------------------------
double kd0=(iClose(NULL,PERIOD_D1,0)+iOpen(NULL,PERIOD_D1,0)+iHigh(NULL,PERIOD_D1,0)+iLow(NULL,PERIOD_D1,0))/4;
double kd1=(iClose(NULL,PERIOD_D1,1)+iOpen(NULL,PERIOD_D1,1)+iHigh(NULL,PERIOD_D1,1)+iLow(NULL,PERIOD_D1,1))/4;
double kd2=(iClose(NULL,PERIOD_D1,2)+iOpen(NULL,PERIOD_D1,2)+iHigh(NULL,PERIOD_D1,2)+iLow(NULL,PERIOD_D1,2))/4;
double kd3=(iClose(NULL,PERIOD_D1,3)+iOpen(NULL,PERIOD_D1,3)+iHigh(NULL,PERIOD_D1,3)+iLow(NULL,PERIOD_D1,3))/4;
double kd4=(iClose(NULL,PERIOD_D1,4)+iOpen(NULL,PERIOD_D1,4)+iHigh(NULL,PERIOD_D1,4)+iLow(NULL,PERIOD_D1,4))/4;
double kd5=(iClose(NULL,PERIOD_D1,5)+iOpen(NULL,PERIOD_D1,5)+iHigh(NULL,PERIOD_D1,5)+iLow(NULL,PERIOD_D1,5))/4;
double kd6=(iClose(NULL,PERIOD_D1,6)+iOpen(NULL,PERIOD_D1,6)+iHigh(NULL,PERIOD_D1,6)+iLow(NULL,PERIOD_D1,6))/4;
double kd7=(iClose(NULL,PERIOD_D1,7)+iOpen(NULL,PERIOD_D1,7)+iHigh(NULL,PERIOD_D1,7)+iLow(NULL,PERIOD_D1,7))/4;
double kd8=(iClose(NULL,PERIOD_D1,8)+iOpen(NULL,PERIOD_D1,8)+iHigh(NULL,PERIOD_D1,8)+iLow(NULL,PERIOD_D1,8))/4;
double kd9=(iClose(NULL,PERIOD_D1,9)+iOpen(NULL,PERIOD_D1,9)+iHigh(NULL,PERIOD_D1,9)+iLow(NULL,PERIOD_D1,9))/4;
double kd10=(iClose(NULL,PERIOD_D1,10)+iOpen(NULL,PERIOD_D1,10)+iHigh(NULL,PERIOD_D1,10)+iLow(NULL,PERIOD_D1,10))/4;

double pd1=kd0;
double pd2=(kd0+kd1)/2;
double pd3=(kd0+kd1+kd2)/3;
double pd4=(kd0+kd1+kd2+kd3)/4;
double pd5=(kd0+kd1+kd2+kd3+kd4)/5;
double pd6=(kd0+kd1+kd2+kd3+kd4+kd5)/6;
double pd7=(kd0+kd1+kd2+kd3+kd4+kd5+kd6)/7;
double pd8=(kd0+kd1+kd2+kd3+kd4+kd5+kd6+kd7)/8;
double pd9=(kd0+kd1+kd2+kd3+kd4+kd5+kd6+kd7+kd8)/9;

double pd10=(kd0+kd1+kd2+kd3+kd4+kd5+kd6+kd7+kd8+kd9)/10;//----------------十日均价
double pd11=(kd1+kd2+kd3+kd4+kd5+kd6+kd7+kd8+kd9+kd10)/10;//--------------前十日均价///自己理解下5日怎么弄，

23581321给我写的，有点激动，谢谢你花费了宝贵的时间，而且对我很有启发。因为我今天还没有时间去写，在这只能表示感谢。

zbchen:

AA:=MA(CLOSE,5);

BB:=REF(AA,1);

//---其实很简单，参考：

```double GetMaDiff(int index)
{
double diff = iMA(Symbol(),0,5,0,MODE_SMA,PRICE_CLOSE,index) - iMA(Symbol(),0,5,0,MODE_SMA,PRICE_CLOSE,index+1);
return(diff);
}```

zbchen:

23581321给我写的，有点激动，谢谢你花费了宝贵的时间，而且对我很有启发。因为我今天还没有时间去写，在这只能表示感谢。

double pd5=(kd0+kd1+kd2+kd3+kd4)/5;//----------------五日均价

double ppd5=(kd1+kd2+kd3+kd4+kd5)/5;//--------------前一个五日均价

double kd0=(iClose(NULL,PERIOD_CURRENT,0)+iOpen(NULL,PERIOD_CURRENT,0)+iHigh(NULL,PERIOD_CURRENT,0)+iLow(NULL,PERIOD_CURRENT,0))/4;

23581321:
//--------------------------------------------------------------------------------------------------------------
double kd0=(iClose(NULL,PERIOD_D1,0)+iOpen(NULL,PERIOD_D1,0)+iHigh(NULL,PERIOD_D1,0)+iLow(NULL,PERIOD_D1,0))/4;
double kd1=(iClose(NULL,PERIOD_D1,1)+iOpen(NULL,PERIOD_D1,1)+iHigh(NULL,PERIOD_D1,1)+iLow(NULL,PERIOD_D1,1))/4;
double kd2=(iClose(NULL,PERIOD_D1,2)+iOpen(NULL,PERIOD_D1,2)+iHigh(NULL,PERIOD_D1,2)+iLow(NULL,PERIOD_D1,2))/4;
double kd3=(iClose(NULL,PERIOD_D1,3)+iOpen(NULL,PERIOD_D1,3)+iHigh(NULL,PERIOD_D1,3)+iLow(NULL,PERIOD_D1,3))/4;
double kd4=(iClose(NULL,PERIOD_D1,4)+iOpen(NULL,PERIOD_D1,4)+iHigh(NULL,PERIOD_D1,4)+iLow(NULL,PERIOD_D1,4))/4;
double kd5=(iClose(NULL,PERIOD_D1,5)+iOpen(NULL,PERIOD_D1,5)+iHigh(NULL,PERIOD_D1,5)+iLow(NULL,PERIOD_D1,5))/4;
double kd6=(iClose(NULL,PERIOD_D1,6)+iOpen(NULL,PERIOD_D1,6)+iHigh(NULL,PERIOD_D1,6)+iLow(NULL,PERIOD_D1,6))/4;
double kd7=(iClose(NULL,PERIOD_D1,7)+iOpen(NULL,PERIOD_D1,7)+iHigh(NULL,PERIOD_D1,7)+iLow(NULL,PERIOD_D1,7))/4;
double kd8=(iClose(NULL,PERIOD_D1,8)+iOpen(NULL,PERIOD_D1,8)+iHigh(NULL,PERIOD_D1,8)+iLow(NULL,PERIOD_D1,8))/4;
double kd9=(iClose(NULL,PERIOD_D1,9)+iOpen(NULL,PERIOD_D1,9)+iHigh(NULL,PERIOD_D1,9)+iLow(NULL,PERIOD_D1,9))/4;
double kd10=(iClose(NULL,PERIOD_D1,10)+iOpen(NULL,PERIOD_D1,10)+iHigh(NULL,PERIOD_D1,10)+iLow(NULL,PERIOD_D1,10))/4;

double pd1=kd0;
double pd2=(kd0+kd1)/2;
double pd3=(kd0+kd1+kd2)/3;
double pd4=(kd0+kd1+kd2+kd3)/4;
double pd5=(kd0+kd1+kd2+kd3+kd4)/5;
double pd6=(kd0+kd1+kd2+kd3+kd4+kd5)/6;
double pd7=(kd0+kd1+kd2+kd3+kd4+kd5+kd6)/7;
double pd8=(kd0+kd1+kd2+kd3+kd4+kd5+kd6+kd7)/8;
double pd9=(kd0+kd1+kd2+kd3+kd4+kd5+kd6+kd7+kd8)/9;

double pd10=(kd0+kd1+kd2+kd3+kd4+kd5+kd6+kd7+kd8+kd9)/10;//----------------十日均价
double pd11=(kd1+kd2+kd3+kd4+kd5+kd6+kd7+kd8+kd9+kd10)/10;//--------------前十日均价///自己理解下5日怎么弄，

double pd5=(kd0+kd1+kd2+kd3+kd4)/5;//----------------五日均价

double ppd5=(kd1+kd2+kd3+kd4+kd5)/5;//--------------前一个五日均价

double kd0=(iClose(NULL,PERIOD_CURRENT,0)+iOpen(NULL,PERIOD_CURRENT,0)+iHigh(NULL,PERIOD_CURRENT,0)+iLow(NULL,PERIOD_CURRENT,0))/4;

Ziheng Zhuang:

//---其实很简单，参考：