# 再请教一个问题

22
2007.12.29 10:19

SUM（mathmax（high - Pre_close),0),12)

22
2007.12.29 11:12

```void sma()
{
double sum=0;
int    i,pos=Bars-ExtCountedBars-1;
//---- initial accumulation
if(pos<MA_Period) pos=MA_Period;
for(i=1;i<MA_Period;i++,pos--)
sum+=Close[pos];
//---- main calculation loop
while(pos>=0)
{
sum+=Close[pos];
ExtMapBuffer[pos]=sum/MA_Period;
sum-=Close[pos+MA_Period-1];
pos--;
}```

11562
2008.01.07 11:11
I think you mean something like that:
```
start()
{
double val;
for (i=limit;i>=0;i--)
{
val=0;
if (High[i]>Close[i+1]) val=High[i]-Close[i+1];
difference[i]=val;
summ=summ+val-difference[i+period];
SummBuffer[i]=summ;
}
}```
25
2008.05.26 13:54
start() { double val; for (i=limit;i>=0;i--)//int limit=Bars-ExtCountedBars-1 ? { val=0; if (High[i]>Close[i+1]) val=High[i]-Close[i+1]; difference[i]=val; summ=summ+val-difference[i+period];//period是我设定的周期吧？ SummBuffer[i]=summ; } } //------------------+ ROSH,这样的代码得不到结果呀！ 我想实现的是累计一个数值My_sum,你可以用我的例子再举一个程式吗？ A_sum[ i ] = ( High[0] + Low[0] ) / 2 * ( Close[0] - Close[1] ) ; My_sum = sum ( A_sum, 36 ) ; //累计36周期的My_sum的和值.
25
2008.05.26 14:00
```int 输入的参数;
A_sum[ i ] = ( High[0] + Low[0] ) / 2 * ( Close[0] - Close[1] ) ;
My_sum = sum ( A_sum, 输入的参数 ) ; //累计36周期的My_sum的和值.```
/