Need help, how to make delay between placing orders

 
Hello, I found great EA, but I need a little change code.. It always open two orders, but at the same time, problem is that I need that it open each order with delay between them- 20 seconds.
Could someone code it? :)

(sorry about my english)
Files:
 
Its a compiled file. Post the code and your attempt to change where it didn't work...
 

I don't know line where need to add that I need just to delay between orders.

extern int Step=120;
extern double FirstLot=0.1;
extern double IncLot=0;
extern double MinProfit=450;
extern int Magic = 2008;

double gLotSell=0;
double gLotBuy=0;
double LSP,LBP;

int init()
{
Comment("Waddah Attar Win");
GlobalVariableSet("OldBalance",AccountBalance());
return(0);
}
int deinit()
{
Comment("");
return(0);
}
int start()
{
double i;
double sl,p;

if (AccountEquity()>=GlobalVariableGet("OldBalance")+MinProfit)
{
DeletePendingOrders(Magic);
CloseOrders(Magic);
GlobalVariableSet("OldBalance",0);
}

GlobalVariableSet("OldBalance",AccountBalance());

if (MyOrdersTotal(Magic)==0)
{
OrderSend(Symbol(),OP_BUYLIMIT,FirstLot,Ask-Step*Point,3,0,0,"",Magic,0,Green);
OrderSend(Symbol(),OP_SELLLIMIT,FirstLot,Bid+Step*Point,3,0,0,"",Magic,0,Red);
}

LSP=GetLastSellPrice(Magic);
LBP=GetLastBuyPrice(Magic);
if((LSP-Bid)<=5*Point)
{
OrderSend(Symbol(),OP_SELLLIMIT,gLotSell+IncLot,LSP+Step*Point,3,0,0,"",Magic,0,Red);
}

if((Ask-LBP)<=5*Point)
{
OrderSend(Symbol(),OP_BUYLIMIT,gLotBuy+IncLot,LBP-Step*Point,3,0,0,"",Magic,0,Red);
}

return(0);
}

int DeletePendingOrders(int Magic)
{
int total = OrdersTotal();
for (int cnt = total-1 ; cnt >= 0 ; cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol() && (OrderType()!=OP_BUY || OrderType()!=OP_SELL))
{
OrderDelete(OrderTicket());
}
}
return(0);
}

int CloseOrders(int Magic)
{
int total = OrdersTotal();
for (int cnt = total-1 ; cnt >= 0 ; cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol())
{
if (OrderType()==OP_BUY)
{
OrderClose(OrderTicket(),OrderLots(),Bid,3);
}
if (OrderType()==OP_SELL)
{
OrderClose(OrderTicket(),OrderLots(),Ask,3);
}
}
}
return(0);
}

int MyOrdersTotal(int Magic)
{
int c=0;
int total = OrdersTotal();

for (int cnt = 0 ; cnt < total ; cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol())
{
c++;
}
}
return(c);
}

double GetLastBuyPrice(int Magic)
{
int total=OrdersTotal()-1;

for (int cnt = total ; cnt >=0 ; cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol() && (OrderType()==OP_BUYLIMIT || OrderType()==OP_BUY))
{
gLotBuy=OrderLots();
return(OrderOpenPrice());
break;
}
}
return(0);
}

double GetLastSellPrice(int Magic)
{
int total=OrdersTotal()-1;

for (int cnt = total ; cnt >=0 ; cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol() && (OrderType()==OP_SELLLIMIT ||OrderType()==OP_SELL))
{
gLotSell=OrderLots();
return(OrderOpenPrice());
break;
}
}
return(100000);
}

 

Before posting please read some of the other threads . . . then you would have seen numerous requests like this one:

Please use this to post code . . . it makes it easier to read.

 
RaptorUK:

Before posting please read some of the other threads . . . then you would have seen numerous requests like this one:

Please use this to post code . . . it makes it easier to read.


I have updated my post ;)
 
I found this, but where I need to add this part of code?

int WaitTime = 10;  // 10 Min.
static int TimeSent;
if (TimeCurrent() >= TimeSent + (WaitTime * 60))
   {
   OrderSend(.....);
   TimeSent = TimeCurrent();
   }
else
   return(0);
 

If you just a want a 20 sec delay add . . .

Sleep(20000);

. . . after the first Order is placed.

 
You also need to read and implement this: What are Function return values ? How do I use them ?
Reason: