استاذ سمير لقد وجد هذا الكود في موقع mql5
للمساعدة فقط
كود:
Here is a four simple steps to do what you want :
#include <stdlib.mqh>
// this will help with error description
/*
You need to copy/paste #include <stdlib.mqh> if not already done so
Then copy/paste the CloseThisSymbolAll function to the end of your EA
Change the name of the variable "MagicNumber " to the name you use in
your EA for magic number
Then modify your line (copy/pste) to match the following :
*/
if ( (CloseAfterHourFriday != 0) && (DayOfWeek() == 5) && (Hour() >= CloseAfterHourFriday) && (AccountProfit()>= CloseProfitFriday) )
CloseThisSymbolAll();
//========================================================================
void CloseThisSymbolAll()
{
int trade;
for(trade=OrdersTotal();trade>=0;trade--)
{
OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);
// if(OrderSymbol()!=Symbol()) continue;
// if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
{
if(OrderType()==OP_BUY)OrderClose(OrderTicket(),OrderLots(),Bid,slip,Blue);
if(OrderType()==OP_SELL)OrderClose(OrderTicket(),OrderLots(),Ask,slip,Red);
if(OrderType()==OP_BUYLIMIT)OrderDelete(OrderTicket(),Blue);
if(OrderType()==OP_SELLLIMIT)OrderDelete(OrderTicket(),Blue);
if(OrderType()==OP_BUYSTOP)OrderDelete(OrderTicket(),Blue);
if(OrderType()==OP_SELLSTOP)OrderDelete(OrderTicket(),Blue);
ErrorDescription(GetLastError());
}
}
}
//========================================================================