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

164

164

#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); },这是我的完整程序。我陷进这个思路里面了，没人帮助好像出不来。
164

164

1638

1638

#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("穿过");
}
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);
}
1638