# DxdCn老师,你在吗？还是不行啊！

165
2013.04.03 05:37

165
2013.04.03 05:44
#property indicator_chart_window #property indicator_buffers 2 double buffer1[]; double buffer2[]; int init() { SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,buffer1); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,buffer2); return(0); } int deinit() { return(0); } int start() { for(int i=0;i<4;i++) { buffer1[i]=iMA(NULL,0,5,0,MODE_SMMA,PRICE_MEDIAN,i); buffer2[i]=iMA(NULL,0,8,0,MODE_SMMA,PRICE_MEDIAN,i); } if(LineCrossedLine(buffer1,buffer2)) {Print("穿过"); Alert("穿穿"); } return(0); } //+------------------------------------------------------------------+ bool LineCrossedLine(double ExtBuffer1[],double ExtBuffer2[]) //均线Buffer1上穿均线Buffer2（这个上穿是确定性的穿过） { double ma1=iMAOnArray(ExtBuffer1,0,1,0,MODE_LWMA,0); double ma2=iMAOnArray(ExtBuffer2,0,1,0,MODE_LWMA,0); double ma3=iMAOnArray(ExtBuffer1,0,1,0,MODE_LWMA,1); double ma4=iMAOnArray(ExtBuffer2,0,1,0,MODE_LWMA,1); Print("ma1=",ma1," ","ma2=",ma2," ","ma3=",ma3," ","ma4=",ma4," ",);if(ma3<ma4 && ma1>=ma2) return(true); else return(false); },这是我的完整程序。我陷进这个思路里面了，没人帮助好像出不来。
165
2013.04.03 05:46
DxdCn老师,虽然print出不来，但是Alert 还是对的，差一点是计算机的时间设置出差了。再次谢谢您，
165
2013.04.04 06:32
DxdCn老师,不光是print出不来，而且是时灵时不灵的。一会有Alert，一会没有的，不重新进入就没有Alert提示
1630
2013.04.12 00:52

1630
2013.04.18 14:01
```
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Aqua
#property indicator_color2 Red
extern int ma1=5;
extern int ma2=18;

double buffer1[];
double buffer2[];

int init()
{
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,buffer1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,buffer2);
return(0);
}
int deinit() { return(0); }
int start()
{

int    counted_bars=IndicatorCounted();
int Limit = Bars-counted_bars+1;
for ( int i = Limit; i>=0;i--)
{
buffer1[i]=iMA(NULL,0,ma1,0,MODE_SMMA,PRICE_MEDIAN,i);
buffer2[i]=iMA(NULL,0,ma2,0,MODE_SMMA,PRICE_MEDIAN,i);
}
if(LineCrossedLine(buffer1,buffer2))
{
Print("穿过");
Alert("上穿 在 "+TimeToStr(Time[1])); //时间是服务器时间，不是北京时间！
}
return(0);
}
//+------------------------------------------------------------------+
bool LineCrossedLine(double ExtBuffer1[],double ExtBuffer2[])
//均线Buffer1上穿均线Buffer2（这个上穿是确定性的穿过）
{
double ma1=iMAOnArray(ExtBuffer1,0,1,0,MODE_LWMA,0);
double ma2=iMAOnArray(ExtBuffer2,0,1,0,MODE_LWMA,0);
double ma3=iMAOnArray(ExtBuffer1,0,1,0,MODE_LWMA,3);
double ma4=iMAOnArray(ExtBuffer2,0,1,0,MODE_LWMA,3);
Print("ma1=",ma1," ","ma2=",ma2," ","ma3=",ma3," ","ma4=",ma4," ");

if((ma3<ma4) && (ma1>=ma2))
return(true);
else
return(false);
}
```
1630
2013.04.18 14:06

/