extern int MaxOrder =1;
extern double sl=30;
extern double tp=30;
extern double lots = 0.1;
int start()
{
double lastZigZag=0,preZigZag=0,lastZigZag1=0,preZigZag1=0;
int amount=0;
int temp[3];
double tem,tem1;
for(int i=0 ;i<5000;i++)
{
tem=iCustom(NULL, 0, "ZigZag",28,0,0,i);
if ( lastZigZag !=0 && tem !=0 )
{ preZigZag = tem;
break; }
if ( lastZigZag == 0 && tem != 0 )
lastZigZag = tem ; }
tem1=iCustom(NULL, 0, "ZigZag",12,0,0,i);
if ( lastZigZag1 !=0 && tem1 !=0 )
{ preZigZag1 = tem1;
break;}
if ( lastZigZag1 == 0 && tem1 != 0 )
lastZigZag1 = tem1 ; }
}
if(OrdersTotal()<MaxOrder)
{
if( preZigZag < lastZigZag )
{
direct=1;
Comment("preZigZag = " + preZigZag + " lastZigZag = " + lastZigZag + "Zigzag UP" );
}
if(preZigZag > lastZigZag)
{
direct=2;
Comment("preZigZag = " + preZigZag + " lastZigZag = " + lastZigZag + "Zigzag Down" );
}
if ( preZigZag1 < lastZigZag1)
{
direct=3;
Comment("preZigZag1 = " + preZigZag1 + " lastZigZag1 = " + lastZigZag1 + "Zigzag UP" );
}
if ( preZigZag1 > lastZigZag1)
{
direct=4;
Comment("preZigZag1 = " + preZigZag1 + " lastZigZag1 = " + lastZigZag1 + "Zigzag Down" );
}
}
if(direct==1)||(direct==3)
{if (( preZigZag ==preZigZag1) && (lastZigZag ==lastZigZag1))
OrderSend(Symbol(),OP_BUY,lots,Ask,3,Ask-Point*sl,Ask+Point*tp,"EA Creator",123,0,Green);
}
if(direct==2)||(direct==4)
{ if (( preZigZag ==preZigZag1) && (lastZigZag ==lastZigZag1))
OrderSend(Symbol(),OP_SELL,lots,Bid,3,Bid+Point*sl,Bid-Point*tp,"EA Creator",123,0,Red);
}
}
return(0)
}
ประมาณนี้ป่าวค่ะ
ช่วยแนะนำด้วยค่ะ
แต่มัน error ค่ะ รบกวนช่วยดูว่าัมันผิดตรงไหนอะคะ
ขอบคุณมาก ๆค่ะ