Im having a bit of trouble with some code and going round and round in circles!!!! any help much appreciated before i go totally mad!!
What im trying to do, is check to see if there is an open order already, before it sends another order at the same price (yes, im working on a grid trader!!)
The code i have come up with so far finds the last order OrderOpenPrice ok, but i need it to find an order if it exists with the same price, NOT just the last one placed - make any sense??
Thanks for any help
Mark
Code: Select all
bool DoesBuyTradeExist()
{
int TicketNo = 0;
double BuyOrderPrice=0;
if (OrdersTotal() == 0) return(false);
for (int cc = OrdersTotal() - 1; cc >= 0 ; cc--)
{
if (!OrderSelect(cc,SELECT_BY_POS,MODE_TRADES)) continue;
if (OrderMagicNumber() != MagicNumber) continue;
if (OrderSymbol() != Symbol()) continue;
if (OrderType() == OP_BUY)
{
TicketNo = OrderTicket();
BuyOrderPrice = OrderOpenPrice();
}
return(true);
}//for (int cc = OrdersTotal() - 1; cc >= 0 ; cc--)
return(false);
}//End bool DoesBuyTradeExist()