請高手指教!!!關於修改程序!!! 請高手幫幫忙,急需中....

 

if(s3>s2 && s2<s1 && s1-s2>5)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"",0,0,Blue);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
}
if(s3<s2 && s2>s1 && s2-s1>5)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"",0,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
}
else Print("Error opening SELL order : ",GetLastError());
return(0);
}
return(0);
}
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL &&
OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY)
{
if(s3<s2 && s2>s1 && s2-s1>5)
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Yellow);
return(0); // exit
}
}
else
{
if(s3>s2 && s2<s1 && s1-s2>5)
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Yellow);
return(0); // exit
}
}
}
}
return(0);
}

請問這個哪不對經了??? 就是關不到交易單!!!請指教!!!!

 
不能平仓还是不能开仓?最好把全部代码都贴出来
 
yyy999 写道 >>
不能平仓还是不能开仓?最好把全部代码都贴出来

是不能平仓....只是修改平仓條件而已,就不能平仓了!!!況且平仓條件是邏輯的....

 

全程代碼如下:

double s1=iStochastic(NULL,0,5,3,3,MODE_SMA,1,MODE_MAIN,0);
double s2=iStochastic(NULL,0,5,3,3,MODE_SMA,1,MODE_MAIN,1);

double s3=iStochastic(NULL,0,5,3,3,MODE_SMA,1,MODE_MAIN,2);

if(s3>s2 && s2<s1 && s1-s2>5)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"",0,0,Blue);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
}
if(s3<s2 && s2>s1 && s2-s1>5)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"",0,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
}
else Print("Error opening SELL order : ",GetLastError());
return(0);
}
return(0);
}
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL &&
OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY)
{
if(s3<s2 && s2>s1 && s2-s1>5)
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Yellow);
return(0); // exit
}
}
else
{
if(s3>s2 && s2<s1 && s1-s2>5)
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Yellow);
return(0); // exit
}
}
}
}
return(0);
}