help me ,i just run two pending order ,but only one is appear

 
//+------------------------------------------------------------------+
//| GlennKing.mq4 |
//| Copyright ?2009, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2009, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"

extern double _number = 1.0;//
extern int _second = 5000;/
extern double _buyPendPrice = 0.0;/
extern double _sellPendPrice = 0.0;//
extern double _buyLossPrice = 0.0;//
extern double _buyGetPrice = 0.0;//
extern double _sellLossPrice = 0.0;//
extern double _sellGetPrice = 0.0;//
extern int _pendingPoint = 2000;//
extern int _getPoint = 1000;//
extern int _lossPoint = 1000;//
extern double Lots = 1;
extern int ChasStart = 10;
extern int ChasStop = 22;
extern int Step = 25;
extern int TP = 40;

int _curTime;
int _curTimeNew;
extern int prevtime = -10000;
int OrderCountOtlA ;
int OrderCountOtlB;
int start()
{

int i = 0;
int total = OrdersTotal();
for (i = 0; i <= total; i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() == 12321)
{
if (OrderType()==2)
OrderCountOtlA=1;
if(OrderType()==3)
OrderCountOtlB=1;
}
}
if (false)
{
for (i = 0; i <= total; i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() == 12321)
{
if (OrderType() > 1)
{
// OrderDelete(OrderTicket());
}
}
}
}



int LARGENUMBER = 100000;
int _orderIdBuy = -1;
int _orderIdSell = -1;
//step1
if (OrderCountOtlA==0)//if the Order number exists,then do it
{
_orderIdBuy = OrderSend(Symbol(), OP_BUYSTOP, _number, Bid + _pendingPoint * Point, 0, Bid + _pendingPoint * Point - _lossPoint * Point, Bid + _pendingPoint * Point + _getPoint * Point, "some comment", 12321, 0, Green);
OrderCountOtlA=1;

}
if(OrderCountOtlB==0)
{
_orderIdSell = OrderSend(Symbol(), OP_SELLSTOP, _number, Ask - _pendingPoint * Point, 0, Ask - _pendingPoint * Point + _lossPoint * Point, Ask + _pendingPoint * Point - _getPoint * Point, "some comment", 12321, 0, Green);
OrderCountOtlB=1;
}

//step2
for (int j = 0; j < LARGENUMBER; j++)
{
Sleep(_second);

//step3


OrderSelect(_orderIdBuy,SELECT_BY_TICKET);







if (OrderSelect(_orderIdBuy, SELECT_BY_TICKET) == true)
{
if (OrderType() == OP_BUY)
{
// OrderDelete(_orderIdSell);
// break;
}
}

else if (OrderSelect(_orderIdSell, SELECT_BY_TICKET) == true)
{
// if (OrderType()==OP_SELL)
// {
// OrderDelete(_orderIdBuy);
// break;
//}
}
else
{
OrderModify(_orderIdBuy, Bid + _pendingPoint * Point, Bid + _pendingPoint * Point - _lossPoint * Point, Bid + _pendingPoint * Point + _getPoint * Point,0, Blue);
OrderModify(_orderIdSell, Ask - _pendingPoint * Point, Ask - _pendingPoint * Point + _lossPoint * Point, Ask + _pendingPoint * Point - _getPoint * Point, 0,Blue);
}

}



return (0);
}
//+------------------------------------------------------------------+


//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return (0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return (0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
 
_orderIdBuy = 
OrderSend(Symbol(), 
	OP_BUYSTOP, 
	_number, 
	Bid + _pendingPoint * Point, 
	0, 
	Bid + 	_pendingPoint * Point - _lossPoint * Point, 
	Bid + _pendingPoint * Point + _getPoint * Point, 
	"some comment"
	, 12321, 0, Green);


hmm; first problem; Long positions should base ASK as price. So Instead of Bid, take ASK. Normally it will work in buystop because normally stop price has space. But its anyways bad style. Second problem is slippage. Not all brokers like the 0 slippage. 0 means guaranteed price and if broker refuses the entry then your position will keep out. I dont know what _losspoint and _getpoint may get values but i would look inside those variables with Print() on time of OrderSend. I may imagine they get values <10. As you know many broker want minimium pip on pending orders. So for example you cannot enter and quit within 4 pips automatically because they require 5 pips distance from entry, exit. This is valid for sl and tp too. So understand your brokers requirements.

 
Once you have sorted out all the fundamental problems fx1 has pointed out you need to consider error checking to prevent one server request from immediately following another. The server is a serial device that only does one thing at a time and it takes time to do each job so if you ask it to place an order then ask it again it won't have finished the first request and an error will be generated and the order lost. Sorting this area out is where all the coding really starts if you want a reliable system.
 
...
for (i = 0; i <= total; i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() == 12321)
{
if (OrderType()==2) OrderCountOtlA=1;
if(OrderType()==3) OrderCountOtlB=1;
}
}

...

if (OrderSelect(_orderIdBuy, SELECT_BY_TICKET) == true)

{

if (OrderType() == OP_BUY) {

// OrderDelete(_orderIdSell);
// break;
}
}

...
OrderModify(_orderIdBuy, Bid + _pendingPoint * Point, Bid + _pendingPoint * Point - _lossPoint * Point, Bid + _pendingPoint * Point + _getPoint * Point,0, Blue);

On startup if there is a pending order, OrderCountOtlA gets set to one, but orderIdBuy is never set. Likewise for sell. Therefor the OrderModify always modified the same order (0)