初学编程,写了一段加仓的代码,但是运行时发现,加仓正常,不正常的是,只要没有单子,必开一买单。而卖出和卖出的加仓都正常。
看了很久看不出是哪里出错了,请各位高手给予指点,谢谢!
void openorders() {
if(lastopensellprice - Bid > Pips*gi_176*Point) {
OrderSend(Symbol(), OP_SELL, Lots, Bid, 3, Bid + ST* Point * gi_176, Bid - TP * gi_176 * Point, \"\", magic, 0, Green);
}
if(Ask - lastopenbuyprice > Pips*gi_176*Point) {
OrderSend(Symbol(), OP_BUY, Lots, Ask, 3, Ask - ST* Point * gi_176, Ask + TP * gi_176 * Point, \"\", magic, 0, Black);
}
}
void countorders() {
l_count_0 = 0;
l_count_1 = 0;
lastopenbuyprice = 0;
lastopensellprice = 0;
for(int i = 0;i < OrdersTotal();i++) {
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol() == Symbol() && OrderMagicNumber() == magic) {
if(OrderType() == OP_BUY) {
l_count_0++;
lastopenbuyprice = OrderOpenPrice();
}
if(OrderType() == OP_SELL) {
l_count_1++;
lastopensellprice = OrderOpenPrice();
}
}
}
} |