## 有二个单子，第一单止赢后，删除第二个LIMIT订单！请大师帮我！

 4 liusong 2011.06.07 08:30   有二个单子，第一单止赢后，删除第二个LIMIT！请大师帮我！
 196 liu2730 2011.06.07 09:51 #   如果只有两张单子，if orderbuy+ ordersell==0 删除挂单
 4 liusong 2011.06.07 13:08 #   if (Predict() == 2.0 || Predict2() == 2.0 && Bid > (ld_512 + ld_520) / 2.0 && li_444 && l_istochastic_256 > 55.0) li_564 = 3; if (li_564 == 1 || li_564 == 2 || li_564 == 3) { if (l_price_552 > 0.0) l_price_552 = Bid + StopLoss * g_point_368; if (li_564 == 1) g_price_352 = Bid - gd_360 * g_point_368; if (li_564 == 2) g_price_352 = Bid - TakeProfit * g_point_368; if (li_564 == 3) g_price_352 = Bid - gd_360 * g_point_368; if(DayOfWeek()!=5) { l_ticket_4 = OrderSend(Symbol(), OP_SELL, LotsOptimized(), Bid, g_slippage_376, 0, 0, "Euro_Blaster", MagicNo, 0, Red); 此行是下一个卖单，并且开仓成交 ticket_y = OrderSend(Symbol(), OP_SELLLIMIT, LotsOptimized()+0.1, Bid+0.0100, g_slippage_376, 0, 0, "Euro_Blaster", MagicNo, 0, Red); 此行是下一个卖LIMIT订单 if (l_ticket_4 > 0) { if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("SELL order opened : ", OrderOpenPrice()); OrderModify(OrderTicket(), OrderOpenPrice(), l_price_552, g_price_352, 0, CLR_NONE); } else Print("Error opening SELL order : ", GetLastError()); if (ticket_y > 0) { if (OrderSelect(ticket_y, SELECT_BY_TICKET, MODE_TRADES)) Print("SELL order opened : ", OrderOpenPrice()); OrderDelete(ticket_y); } else Print("Error opening SELL order : ", GetLastError()); 　此行是删除刚才的LIMT订单。　问题是第一个卖单还未止赢，就删除了LIMT订单，我要求：如果第一个订单止赢后，就删除LIMT订单! 但是我放置的位置不对，请大师帮我看一下应该放置在那个位置？下面是程序的完整代码，请大师我帮！ } return (0); } return (0); } if (Profit_Protection && AccountEquity() > AccountBalance() * (Percent_Over_Balance / 100.0 + 1.0)) Close_All(); for (int l_pos_0 = 0; l_pos_0 < l_count_16; l_pos_0++) { li_unused_572 = 0; OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES); if (OrderType() <= OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNo) { l_price_576 = OrderStopLoss(); if (OrderType() == OP_BUY) { if (AccountFreeMargin() <= 0.0 || (Balance_Protection && AccountEquity() + AccountMargin() < AccountBalance() * (1 - RiskPercent / 100.0))) { OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_376, Violet); return (0); } if (TrailingStop <= 0.0) continue; if (TrailingStop < l_stoplevel_548) TrailingStop = l_stoplevel_548; if (Bid - OrderOpenPrice() <= g_point_368 * TrailingStop) continue; if (NormalizeDouble(l_price_576, Digits) >= NormalizeDouble(Bid - g_point_368 * TrailingStop, Digits)) continue; l_price_576 = Bid - g_point_368 * TrailingStop; l_price_24 = OrderTakeProfit(); if (TrailingProfit && li_440 && l_istochastic_256 < 70.0) l_price_24 = OrderTakeProfit() + TrailingPips * g_point_368; OrderModify(OrderTicket(), OrderOpenPrice(), l_price_576, l_price_24, 0, Blue); return (0); } if (AccountFreeMargin() <= 0.0 || (Balance_Protection && AccountEquity() + AccountMargin() < AccountBalance() * (1 - RiskPercent / 100.0))) { OrderClose(OrderTicket(), OrderLots(), Ask, g_slippage_376, Violet); return (0); } if (TrailingStop > 0.0) { if (TrailingStop < l_stoplevel_548) TrailingStop = l_stoplevel_548; if (OrderOpenPrice() - Ask > g_point_368 * TrailingStop) { if (NormalizeDouble(l_price_576, Digits) > NormalizeDouble(Ask + g_point_368 * TrailingStop, Digits) || NormalizeDouble(l_price_576, Digits) == 0.0) { l_price_576 = Ask + g_point_368 * TrailingStop; l_price_24 = OrderTakeProfit(); if (TrailingProfit && li_444 && l_istochastic_256 > 30.0) l_price_24 = OrderTakeProfit() - TrailingPips * g_point_368; OrderModify(OrderTicket(), OrderOpenPrice(), l_price_576, l_price_24, 0, Red); return (0); } } } } } return (0); } double LotsOptimized() { if (!MM) return (LotSize); if (Max_Lot_Size > 0.0) gd_316 = Max_Lot_Size; double ld_ret_0 = AccountFreeMargin() * RiskPercent / 400.0; ld_ret_0 = NormalizeDouble(MathFloor(ld_ret_0 / gd_340) * g_lotstep_332, 2); if (ld_ret_0 < g_minlot_324) ld_ret_0 = g_minlot_324; if (ld_ret_0 > gd_316) ld_ret_0 = gd_316; return (ld_ret_0); if (LotSize < g_minlot_324) LotSize = g_minlot_324; if (LotSize > gd_316) LotSize = gd_316; return (LotSize); } void Close_All() { int l_cmd_4; bool l_ord_close_8; for (int li_0 = OrdersTotal() - 1; li_0 >= 0; li_0--) { l_cmd_4 = OrderType(); l_ord_close_8 = FALSE; if (OrderMagicNumber() == MagicNo || (OrderMagicNumber() != MagicNo && ProtectAll)) { switch (l_cmd_4) { case OP_BUY: l_ord_close_8 = OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), g_slippage_376, Pink); break; case OP_SELL: l_ord_close_8 = OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), g_slippage_376, Pink); } if (l_ord_close_8 == 0) Sleep(1000); } } Print("Account Profit Reached. All Open Trades Have Been Closed"); } bool isTradeTime() { int l_str2time_4; int l_str2time_8; int l_datetime_0 = TimeCurrent(); if (Use_Time_Mgmt) { l_str2time_4 = StrToTime(TradeStartHour + ":" + TradeStartMinutes); l_str2time_8 = StrToTime(TradeEndHour + ":" + TradeEndMinutes); if (l_str2time_4 < l_str2time_8 && l_datetime_0 < l_str2time_4 || l_datetime_0 >= l_str2time_8) return (FALSE); if (l_str2time_4 > l_str2time_8 && (l_datetime_0 < l_str2time_4 && l_datetime_0 >= l_str2time_8)) return (FALSE); } return (TRUE); } void closeExpiredOrders() { int l_datetime_0; int l_ord_total_4; if (gi_384) { if (Use_Time_Mgmt) { l_datetime_0 = TimeCurrent(); l_ord_total_4 = OrdersTotal(); for (int l_pos_8 = l_ord_total_4 - 1; l_pos_8 >= 0; l_pos_8--) { if (!OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES) || OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNo || OrderType() > OP_SELL) continue; if (l_datetime_0 - OrderOpenTime() > gi_348) OrderClose(OrderTicket(), OrderLots(), d_if(OrderType() == OP_BUY, Bid, Ask), g_slippage_376); } } } } double d_if(bool ai_0, double ad_4, double ad_12) { if (ai_0) return (ad_4); return (ad_12); }
 14 weewas 2011.08.21 19:20 #   很简单啊，不需要这么负责的。 另起一段程序，然后 检查有无 已开单 和有无 挂单，如果没有已开的单，就删除挂单。