有您的持续关注
我们会做得更好

比较全面的函数平仓和删除订单的函数模块



比较全面的函数平仓和删除订单的函数模块
void CloseAllOrders(string a_symbol_0, int a_magic_8, int a_magic_12, int a_magic_16, bool
ai_20, int ai_24) {
int l_cmd_28 = 0;
int li_unused_32 = 0;
while (CountAll(a_symbol_0, a_magic_8, a_magic_12, a_magic_16, ai_20, ai_24) > 0) {
for (int l_pos_36 = OrdersTotal() – 1; l_pos_36 >= 0; l_pos_36–) {
OrderSelect(l_pos_36, SELECT_BY_POS, MODE_TRADES);
if (!ai_24 || OrderSymbol() == a_symbol_0) {
if (!ai_20) {
l_cmd_28 = OrderType();
li_unused_32 = 0;
switch (l_cmd_28) {
case OP_BUY:
Wait();
li_unused_32
=
OrderClose(OrderTicket(),
OrderLots(),
MarketInfo(OrderSymbol(), MODE_BID), 10, CLR_NONE);
break;
case OP_SELL:
Wait();
li_unused_32
=
OrderClose(OrderTicket(),
OrderLots(),
MarketInfo(OrderSymbol(), MODE_ASK), 10, CLR_NONE);
break;
case OP_BUYLIMIT:
case OP_BUYSTOP:
case OP_SELLLIMIT:
case OP_SELLSTOP:
Wait();
li_unused_32 = OrderDelete(OrderTicket());
}
} else {
if (a_magic_16 != 0) {
if (a_magic_16 == OrderMagicNumber()) {
l_cmd_28 = OrderType();
li_unused_32 = 0;
switch (l_cmd_28) {
case OP_BUY:
Wait();
li_unused_32
=
OrderClose(OrderTicket(),
OrderLots(),
MarketInfo(OrderSymbol(), MODE_BID), 10, CLR_NONE);
break;
case OP_SELL:
Wait();
li_unused_32
=
OrderClose(OrderTicket(),
OrderLots(),
MarketInfo(OrderSymbol(), MODE_ASK), 10, CLR_NONE);
break;
case OP_BUYLIMIT:
case OP_BUYSTOP:
case OP_SELLLIMIT:
case OP_SELLSTOP:
Wait();
li_unused_32 = OrderDelete(OrderTicket());
}
}
} else {
if (OrderMagicNumber() == a_magic_8 || OrderMagicNumber() ==
a_magic_12) {
l_cmd_28 = OrderType();
li_unused_32 = 0;
switch (l_cmd_28) {
case OP_BUY:
Wait();
li_unused_32
=
OrderClose(OrderTicket(),
OrderLots(),
MarketInfo(OrderSymbol(), MODE_BID), 10, CLR_NONE);
break;
case OP_SELL:
Wait();
li_unused_32
=
OrderClose(OrderTicket(),
OrderLots(),
MarketInfo(OrderSymbol(), MODE_ASK), 10, CLR_NONE);
break;
case OP_BUYLIMIT:
case OP_BUYSTOP:
case OP_SELLLIMIT:
case OP_SELLSTOP:
Wait();
li_unused_32 = OrderDelete(OrderTicket());
}
}
}
}
}
}
}
GlobalVariableDel(a_magic_8 + “CHAMELEON-START-TRAIL”);
}
int CountAll(string a_symbol_0, int a_magic_8, int a_magic_12, int a_magic_16, bool ai_20, int
ai_24) {
int l_count_28 = 0;
for (int l_pos_32 = OrdersTotal() – 1; l_pos_32 >= 0; l_pos_32–) {
OrderSelect(l_pos_32, SELECT_BY_POS, MODE_TRADES);
if (!ai_24 || OrderSymbol() == a_symbol_0) {
if (!ai_20) l_count_28++;
else {
if (a_magic_16 != 0) {
if (a_magic_16 == OrderMagicNumber()) l_count_28++;
else
if (OrderMagicNumber() == a_magic_8 || OrderMagicNumber() ==
a_magic_12) l_count_28++;
}
}
}
}
return (l_count_28);
}

如您喜欢此文章请点下面分享按钮↴峰汇在线 » 比较全面的函数平仓和删除订单的函数模块
上一篇:
下一篇:
分享到:更多 ()

评论 抢沙发

评论前必须登录!