well just save
1) the ticket_number = oderSend() and
2) lot_size and
3) the tmeDel = sending time + 300 sec of the pending order and
4) if (TimeCurrent()>tmeDel) OrderDelete(ticket_number,...)
Donson,
the following should work better than your code.
for(cnt=0;cnt<total;cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol()==Symbol()) { if(OrderType() ==OP_SELLSTOP || OrderType()==OP_BUYSTOP) { if (OrderCloseTime() < TimeCurrent() - 5 * 60) { OrderDelete(OrderTicket(),Yellow); } } } }
Rgds.
Sorry, OrderOpenTime() instead of OrderCloseTime().
donson: Here's the code, can u help me? where am i wrong?
for(cnt=0;cnt<total;cnt++)
- You must count down when closing/deleting in a position loop. Get in the habit of always counting down. Loops and Closing or Deleting Orders - MQL4 forum
if(OrderType()==OP_SELLSTOP && Hour()==h1 && Minute()==m1)
What if there is no tick in that minute?if(OrderType()==OP_BUYSTOP && Hour()==h1 && Minute()==m1)
What if there is not a second tick in that minute?- Just remember when you opened the orders. When 5 minutes have passed, then close everything.
static datetime pendingsCreated; : if(ticket>0){ pendingsCreated = TimeCurrent(); : if(TimeCurrent() > pendingsCreated + 5*60){ // Begin closing
gadget:
I don't see how this is better than his code. Could you explain how?
Donson,
the following should work better than your code.
Rgds.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi, i'm newbie here, i have developed simple EA wchich place pending orders at specific time. the broker dont allow to have expiration time less than 1 hour so i want EA to delete these orders 5 min after placing.
Here's the code, can u help me? where am i wrong?