PDA

View Full Version : Auto time exit system



Migwlcampelas
11-18-2009 21:12, 09:12 PM
Hey guys, is it possible to programme a system which automatically shuts or exits your open commerce in a programmed period .example:you've got an open commerce but it's not yet hit some of your halt levels and you wish to give it a little time before you depart but sadly you can't hang around to observe the market.Can one get a system which is going to be able to leave the exchange for you in the programmed time when it wasn't hit your stop or goal

pabloycmiss
01-30-2022 19:47, 07:47 PM
I use this function in all of my EA's whenever I need it ... It works very well.

If(Hour()==22 Minute()gt;50)
DeleteAllOrders()

...
...
...

emptiness DeleteAllOrders()
int total = OrdersTotal();
for(int I=total-1;igt;=0;I--)
OrderSelect(I, SELECT_BY_POS);
int form = OrderType();
bool result = false;

switch(type)
case OP_BUY : outcome = OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red);
split;

case OP_SELL : outcome = OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red);
split;
case OP_BUYLIMIT :
case OP_BUYSTOP :
case OP_SELLLIMIT :
case OP_SELLSTOP : outcome = OrderDelete(OrderTicket());


if(result == false)
Alert(Order , OrderTicket() , failed to shut. Error: , GetLastError() );
// Sleep(3000);



return(0);