# ADD LOT Problem

1453

Hi Guys,

i`m struggling upon something -  its an add lot function. Can you help me make it start only one additional order per main order? Mine starts like a million additional orders. I`d really appreciate the help.

Best Regards

18257

1. Do you really expect an answer? We can't see your broken code. There are no mind readers here and our crystal balls are cracked.

2. Don't looking at a signal. Act on a change of signal.
MQL4 (in Strategy Tester) - double testing of entry conditions - Strategy Tester - Expert Advisors and Automated Trading - MQL5 programming forum
1453

```void addlot_execute(double lot_step,double lot_size,double pnt)
{

//===================================================
for (int i=OrdersTotal()-1; i>=0; i--)
{
continue;
if( OrderMagicNumber()== magic && OrderSymbol()==Symbol())
{
//-------------------------------------
{
if(tkt > 0) Print("Additional Order BUY Opened !!! ");
else Print("Error Opening Additional order BUY !!!");
}
//-----------------------------------------
else if(OrderType()==OP_SELL && Bid<OrderOpenPrice()- lot_step *pnt && already_added==false) // SELL
{
int tkt = OrderSend(Symbol(),OP_SELL,lot_size,Bid,5,OrderStopLoss(),OrderTakeProfit(),NULL,magic+1,0,clrRed);
if(tkt > 0) Print("Additional Order SELL Opened !!! ");
else Print("Error Opening Additional order SELL !!!");
}
}
}
return;
}// END ```
1751

Stanislav Ivanov:

whroeder's gonna say you need to program your EA to recover, and he's right. You need to count how many orders in the pool.

```bool canTrade(int order_type, int max_number_of_orders)
{
int count=0;
for (int i = OrdersTotal() - 1; i >= 0; i--)
if (OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == _Symbol && OrderMagicNumber() == MAGIC && OrderType()==order_type)
count++;
return count < max_number_of_orders;
}```
1453

Mark Watkins:

whroeder's gonna say you need to program your EA to recover, and he's right. You need to count how many orders in the pool.

thanks