Looking simple ea

 

Im looking ea what would close all open and pending orders in specific time.

Example I want all orders close at 9 PM GMT???

 

Try to incorporate the following snippet in your code.

In the main body,

if(CurTime() >= expiration) CloseAll();

And the CloseAll routine is:

void CloseAll()

{

int trade, c, err, NumberOfTries=100;

bool closed;

int trades=OrdersTotal();

for(trade=0;trade<trades;trade++)

{

OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);

if(OrderSymbol()!=Symbol()||OrderMagicNumber()!=MagicNumber)

continue;

if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber)

if(OrderType()==OP_SELL || OrderType()==OP_BUY)

for(c = 0 ; c < NumberOfTries ; c++)

{

closed=OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Red);

if break;

err=GetLastError();

if(err==0)

{

break;

}

else

{

if(err==4 || err==137 ||err==146 || err==136) //Busy errors

{

Sleep(5000);

continue;

}

else //normal error

{

break;

}

}

}

}//for

}

 

no i am looking separate ea. I dont want to add anything

 
jyrik:
no i am looking separate ea. I dont want to add anything

So you don't have any EA? do you have your own system? if yes you can ask somebody here or pay somebody outthere to coding it. If no, my suggestion is.. create your system, tweak it until it's profitable in the long run, then learn mql4 programming or pay somebody to create an EA based on it. To write an EA maybe a lot simpler than create or tweak a good system that suit you.

Learn and learn is the only way to survive. Maji already assist you to write that code. Market is always changing, today's best EA may save you for a while, someday it won't suit the market anymore. If you have a proper forex knowledge, you can tweak it until it's profitable again, and create a new EA again. Better to learn fishing rather than asking for a fish.

Just my 2 cents

Reason: