任务编号:131642
悬赏任务2H币
悬赏任务 : 按雇主需求进行任务后提交稿件,被采纳后即获得佣金。
距截止:
00天00时00分00秒
雇主已托管赏金:2 H币
雇主发布需求24.11.23
雇主托管佣金24.11.23
投稿者投稿
雇主开始选稿
任务完成
任务大厅共需1个合格投稿 | 每稿将获得2 H币 | 每人交稿次数不限 可多次任务
投诉举报
联系Ta
我来承接
已有0 个投稿 | 已采纳0 稿 | 拒绝0 稿 | 还需要1 稿
任务需求:
EA开单是马丁 0.01 0.02 0.03 0.04 ... 0.1
1,在开多空单时,盈利平仓是从大手数0.1顺序到0.01平仓!
2,平仓代码我已经找出来,在下面!
3,修改代码,盈利平仓时,多单(空单)平仓时是同时平,不是顺序平!
4,是多单(空单)同时平,不是多空单一起同时平!
- int CloseOrders(string symbol,
- int mag,
- ENUM_ORDER_TYPES type,
- string com,
- int slippage = 0,
- color arrow_color = clrFireBrick,
- int cycles = 2)
- {
- ResetLastError();
- int cnt = 0;
- bool Res;
- for(int j = 1; j <= cycles; j++)
- {
- ::RefreshRates();
- bool res = true;
- int total = ::OrdersTotal();
- for(int i = total; i >= 0; i--)
- {
- if(::OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == true)
- if(symbol == NULL || ::OrderSymbol() == symbol)
- if(mag == -1 || ::OrderMagicNumber() == mag)
- if(com == NULL || com == "" || ::StringFind(::OrderComment(), com) == 0 || ::OrderComment() == com)
- if(CheckType(OrderType(), type) == true)
- {
- if(OrderType() < 2)
- {
- Res = ::OrderClose(::OrderTicket(), ::OrderLots(), ::OrderClosePrice(), slippage, arrow_color);
- if(Res == false)
- {
- res = false;
- if(j == cycles)
- ::PrintFormat("%d,Position Closed failed, code =%d", ::OrderTicket(), ::GetLastError());
- }
- else
- {
- cnt++;
- }
- }
- else
- {
- Res = ::OrderDelete(::OrderTicket(), arrow_color);
- if(Res == false)
- {
- res = false;
- if(j == cycles)
- ::PrintFormat("%d,pending order delete failed, code =%d", ::OrderTicket(), ::GetLastError());
- }
- else
- {
- cnt++;
- }
- }
- }
- }
- if(res == true)
- {
- break;
- }
- else
- {
- ::Sleep(200);
- }
- }
- return(cnt);
- }
复制代码
|