客服热线:18391752892

持仓订单全部平仓包括删除挂掉的完整函数

   日期:2019-01-12     浏览:165    
马上注册,结交更多好友,下载更多资源

您需要 登录 才可以下载或查看,没有帐号?注册 持仓订单全部平仓包括删除挂掉的完整函数。

bool CloseOrder(int Ticket, double Lots, int myOrderType,string myOrderSymbol)
{
bool res;
int ErrorCode;
double Price;
bool Status = false;
if(myOrderType == OP_BUYLIMIT || myOrderType == OP_BUYSTOP ||
myOrderType == OP_SELLLIMIT || myOrderType == OP_SELLSTOP)
{
OrderDelete(OrderTicket());
return(true);
}
if (myOrderType == OP_BUY) Price = MarketInfo(myOrderSymbol,MODE_BID);
if (myOrderType == OP_SELL) Price = MarketInfo(myOrderSymbol,MODE_ASK);
if (MarketInfo(myOrderSymbol,MODE_DIGITS) 0)
Price = NormalizeDouble(Price, MarketInfo(myOrderSymbol,MODE_DIGITS));
int cnt = 0;
while (!Status) {
if (IsTradeAllowed() == true) {
res = OrderClose(Ticket, Lots, Price, MarketInfo(myOrderSymbol,MODE_SPREAD),
Violet);
ErrorCode = GetLastError();
} else cnt++;
if (res == true) Status = true;
ErrorCode = GetLastError();
switch (ErrorCode) {
case 0:
Status = true;
break;
case 4:
case 6:
case 129:
case 136:
case 137:
case 146:
case 128:
RefreshRates();
cnt++;
break;
case 135:
case 138:
RefreshRates();
continue;
default:
Status = TRUE;
}
if (cnt 20) Status = TRUE; //10 time try
if (!Status)
{
Sleep(500);
RefreshRates();
}
}
if (res == true || ErrorCode == 0) return (true);
Print( Error closing order : ( , ErrorCode, ) + ErrorDescription(ErrorCode));
return (false);
}复制代码

外汇交易有很大的风险性,本站所有资源均来自网络,请选择使用,如若出现亏损,本站不承担任何责任!


特别提示:本信息由相关企业自行提供,真实性未证实,仅供参考。请谨慎采用,风险自负。


0相关评论
相关行情快递
推荐行情快递
点击排行