Immediate execution

 
Hi,

I am using metatrader 4 for system trading. I have a
problem instantly execute order through my system. It
seems like the system will run the expert advisor only
when there is a tick. How could i execute the expert
advisor even there is no tick happening? For example,
execute a buy order at 10.00AM (execute command at
range from 10.00.00AM to 10.00.30AM even there is no
ticks). So the system run base on the time, not tick.

Thank you
 
Use a script with infinite loop.

void start()
{
  while (!IsStopped())
  {
    ...
  }
}



 
Thanks for the help. I tried it up with some easy code for the script. Since it still require a tick to start the script before it run continuously, I made sure that the script has been started (ticks before the time I need it to execute order.) However my script got some problems. For example on this script below, it suppose to execute an order at monday 4.15 but sometimes it does, sometimes doesn't. Same thing happen to the close order. Sometimes it does close the order, sometimes it closes after few min and sometimes just won't at all. Can anyone help to point what is my mistake here? The script is attached on usd/jpy 30min chart. Thank you

CalculateCurrentOrders()
{
...
}
double LotsOptimized()
{
..
}

void start()
{
while (!IsStopped())
{
if(CalculateCurrentOrders(Symbol())==0)
{
CheckForOpen();
}
else CheckForClose();
}
}

void CheckForOpen()
{
int res;
if(TimeDayOfWeek(Time[0])==1 && TimeHour(Time[0])==4 && TimeMinute(iTime("USDJPY",PERIOD_M1,0))==15)
res=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,(Ask-TStop),(Ask+TLim),"",MAGICMA,0,Blue);
return;
}

void CheckForClose()
{
int res;
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;
if(TimeHour(Time[0])==4 && TimeMinute(iTime("USDJPY",PERIOD_M1,0))>=17)
OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
break;
}
}
Reason: