下载MetaTrader 5
要添加评论,请登录注册
提供8种语言的MQL5 参考。通过最适合您的语言学习MQL5!
ice665683
55
ice665683 2008.10.31 18:26 

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
175
yyy999 2008.11.03 14:12  
不能平仓还是不能开仓?最好把全部代码都贴出来
ice665683
55
ice665683 2008.11.04 05:23  
yyy999 写道 >>
不能平仓还是不能开仓?最好把全部代码都贴出来

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

ice665683
55
ice665683 2008.11.04 05:30  

全程代碼如下:

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);
}

/
要添加评论,请登录注册