新手求教

 

我写的是指标,定义数组mav13[],保存当5和13天均线交叉时候 ma13的值,保存后的数组里有0值,怎么把0值都去掉,只保留非0的...

谢谢!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

double ma13v[]={0.0};

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;
//---- main loop
for(int i=0; i<limit; i++)

{
//---- ma_shift set to 0 because SetIndexShift called abowe

double ma05,ma013, ma5,ma13;
ma05=iMA(NULL,0,5,0,MODE_SMA,PRICE_CLOSE,i+1) ;
ma013=iMA(NULL,0,13,0,MODE_SMA,PRICE_CLOSE,i+1) ;
ma5=iMA(NULL,0,5,0,MODE_SMA,PRICE_CLOSE,i+2) ;
ma13=iMA(NULL,0,13,0,MODE_SMA,PRICE_CLOSE,i+2) ;
if((ma05>ma013&&ma5<ma13)|| (ma013>ma05&&ma13<ma5))

ma13v[i]=ma13;

}