平仓认不了单,求助啊 新评论 gerlff 2015.05.21 02:45 在持有多个单子时候,平仓函数好像选不中该平的单子,求高手解答开仓函数://---------------开仓--------------------void MYOpen() { double MAN; int res;//--- buy conditions if (Close[0]>MAN) { res=OrderSend(Symbol(), OP_BUY, slotA, Ask, 3, 0, 0, "Order Buy", MAGICMA, 0, Red); PlaySound("2open"); return; }}平仓函数:void YingOrLoseClose() { double MAN; bool yingB=false; bool yingBB=false;//+--------------- for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break; if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue; //--- check order type if(OrderType()==OP_BUY) { if(Close[0]>GetOrderOpenPriceHolding()+YPOINT) //止盈 { yingB=OrderClose(OrderTicket(),slotB,Bid,3,White); if(yingB==true) { PlaySound("2ying"); } if(yingB==False) { Print("OrderClose error ",GetLastError()); } } if(Close[0]<MAN-PPOINT)//止损 { yingBB=OrderClose(OrderTicket(),slotA,Bid,3,White); if(yingBB==true) { PlaySound("2stop"); } if(yingBB==False) { Print("OrderClose error ",GetLastError()); } } break; }} 新人对MQL4和MQL5的任何问题,对算法和代码的帮助和讨论 [存档!]任何菜鸟问题,为了不给论坛添乱。专业人士,不要与它擦肩而过。没有你,哪里都不能去 - 2. EA不会在多对上运行,需要帮助 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
开仓函数:
//---------------开仓--------------------
void MYOpen()
{
double MAN;
int res;
//--- buy conditions
if (Close[0]>MAN)
{
res=OrderSend(Symbol(), OP_BUY, slotA, Ask, 3, 0, 0, "Order Buy", MAGICMA, 0, Red);
PlaySound("2open");
return;
}
}
平仓函数:
void YingOrLoseClose()
{
double MAN;
bool yingB=false;
bool yingBB=false;
//+---------------
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;
//--- check order type
if(OrderType()==OP_BUY)
{
if(Close[0]>GetOrderOpenPriceHolding()+YPOINT) //止盈
{
yingB=OrderClose(OrderTicket(),slotB,Bid,3,White);
if(yingB==true)
{
PlaySound("2ying");
}
if(yingB==False)
{
Print("OrderClose error ",GetLastError());
}
}
if(Close[0]<MAN-PPOINT)//止损
{
yingBB=OrderClose(OrderTicket(),slotA,Bid,3,White);
if(yingBB==true)
{
PlaySound("2stop");
}
if(yingBB==False)
{
Print("OrderClose error ",GetLastError());
}
}
break;
}
}