# 穿越0轴的画线问题

19
2010.03.14 07:51

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Green
#property indicator_level1 0.00
extern int FMA=12;
extern int SMA=26;
double buf1[];
double buf2[];
double buftemp;
int init()
{
SetIndexBuffer(0,buf1);
SetIndexBuffer(1,buf2);
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);

return(0);
}
int start()
{
int limit=Bars-IndicatorCounted();
for(int i=0; i<limit; i++)
{
buftemp=iMA(NULL,0,FMA,0,1,0,i)-iMA(NULL,0,SMA,0,1,0,i);
if (buftemp<0) buf1=buftemp;
if (buftemp>0) buf2=buftemp;
}
return(0);
}

91
2010.03.14 08:52

44
2010.03.14 09:35

```//+------------------------------------------------------------------+
//|                                                         zero.mq4 |
//|                                            du_steven@hotmail.com |
//+------------------------------------------------------------------+

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Green
#property indicator_level1 0.00

extern int FMA=12;
extern int SMA=26;
double buf1[];
double buf2[];
double buftemp,buftemp1;
int init()
{
SetIndexBuffer(0,buf1);
SetIndexBuffer(1,buf2);
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);

return(0);
}
int start()
{
int limit=Bars-IndicatorCounted();
for(int i=0; i<limit; i++)
{
buftemp=iMA(NULL,0,FMA,0,1,0,i)-iMA(NULL,0,SMA,0,1,0,i);
buftemp1=iMA(NULL,0,FMA,0,1,0,i+1)-iMA(NULL,0,SMA,0,1,0,i+1);

if (buftemp<0)
{
buf1[i]=buftemp;
if(buftemp1>0)
buf1[i+1] = buftemp1;
}

if(buftemp>0)
{
buf2[i]=buftemp;
if(buftemp1<0)
buf2[i+1] = buftemp1;
}

}
return(0);
}```
19
2010.03.14 12:42

44
2010.03.15 14:14

/