ลองเอาไปดูครับ
extern double Lots=0.1;
extern int SL=20;
extern int TP=10;
static double one;
static double two;
static double three;
int check (double stosignal ,double stomain)
{ static int lastway =0;
static int way =0;
if(stosignal > stomain)
{
way=1;
}
if(stosignal < stomain)
{
way=2;
}
if(way!= lastway)
{
lastway = way;
if( ( one == 0) && (two == 0) && (three== 0) )
{
one=Bid;
return(0);
}
if( ( one != 0) && (two == 0) && (three== 0) )
{
two=Bid;
return(0);
}
if( ( one != 0) && (two != 0) && (three== 0) )
{
three=Bid;
return(0);
}
if( ( one != 0) && (two != 0) && (three!= 0) )
{ one=Bid;
two=0;
three=0;
return(0);
}
}
return (0);
}
int start()
{
double stomain=iStochastic(Symbol(),30,5,5,5,MODE_SMA,1,MODE_MAIN,0);
double stosignal=iStochastic(Symbol(),30,5,5,5,MODE_SMA,1,MODE_SIGNAL,0);
int kway = check(stosignal,stomain);
int total =OrdersTotal();
if(total==0)
{
if(one > (two > three) )
{
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-Point*SL,Ask+Point*TP,"smaaa",0,0,Green);
}
if(one < (two < three) )
{
OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+Point*SL,Bid-Point*TP,"smaaa",555,0,Red);
}
}
return(0);
}