pending orders on EA

 

Hi,


My EA places pending orders (it's channel breakout system). However, once the pending order gets filled and is stopped out, the EA will open another pending order. Can anyone help me to add a function so that the EA only open one pending order during one trading session? On the demo, it works fine; i.e it places one pending order, and once the order gets stopped out or reached the target, it does not open another pending order.


Thanks,


Cassia Chen

 

CC


Something like this to get the count of any pending orders.
If count > 0 then dont open any more?


OTTOMH ;)



//+------------------------------------------------------------------+
int CountPendingOrders(int MN)
{
int numord = 0;
//----
for(int i = 0; i < OrdersTotal(); i++)
{
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == false)
break;
//----
if((OrderSymbol()==Symbol()) && (OrderType()>1) && (OrderMagicNumber()==MN))
numord ++;
}
return(numord);
}
//+------------------------------------------------------------------+



Good Luck

-BB-

 
BarrowBoy:

CC


Something like this to get the count of any pending orders.
If count > 0 then dont open any more?


OTTOMH ;)



//+------------------------------------------------------------------+
int CountPendingOrders(int MN)
{
int numord = 0;
//----
for(int i = 0; i < OrdersTotal(); i++)
{
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == false)
break;
//----
if((OrderSymbol()==Symbol()) && (OrderType()>1) && (OrderMagicNumber()==MN))
numord ++;
}
return(numord);
}
//+------------------------------------------------------------------+



Good Luck

-BB-

Hi BB,

Thank you very much. I will try that.

CC

Reason: