//+------------------------------------------------------------------+
//| LicvidationExp-T01.mq4 |
//| Copyright © 2007, HomeSoft - Tartan Corp. |
//| spiky@transkeino.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, HomeSoft - Tartan Corp."
#property link "spiky@transkeino.ru"
extern double Lots = 1.0;
extern double Stop = 500;
double ssum,bsum,sum;
int s,b,cnt,pl,k,j;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
j=j+1;
if (j==100) j=1;
ssum=0;bsum=0;sum=0;s=0;b=0;
for (cnt=OrdersTotal()-1;cnt>=0 ;cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderType()==OP_SELL && (OrderMagicNumber()==121 || OrderMagicNumber()==122 || OrderMagicNumber()==123 || OrderMagicNumber()==124))
{ s=s+1;ssum=ssum+OrderProfit()+OrderSwap();}
if (OrderType()==OP_BUY && (OrderMagicNumber()==121 || OrderMagicNumber()==122 || OrderMagicNumber()==123 || OrderMagicNumber()==124))
{ b=b+1;bsum=bsum+OrderProfit()+OrderSwap();}
}
ssum=MathRound(ssum);
bsum=MathRound(bsum);
sum=ssum+bsum;
if (s+b==0) {k=0;pl=0;}
if (sum>=Stop*Lots) {pl=1;if (k==0) {k=1;PlaySound("Curants.wav");}}
Comment("\n"," Time=",Hour(),":",Minute()," Tiks=",j," Orders=",s+b," Flag=",pl," GlobalStop=",Stop," GlobalProfit=",sum);
if ( pl==1 )
{
for (cnt=OrdersTotal()-1;cnt>=0 ;cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderType()==OP_SELL && (OrderProfit()+OrderSwap())>0 &&
(OrderMagicNumber()==121 || OrderMagicNumber()==122 || OrderMagicNumber()==123 || OrderMagicNumber()==124))
{ RefreshRates();
OrderClose(OrderTicket(),OrderLots(),Ask,3,Red);
Sleep(10000);
}
if (OrderType()==OP_BUY && (OrderProfit()+OrderSwap())>0 &&
(OrderMagicNumber()==121 || OrderMagicNumber()==122 || OrderMagicNumber()==123 || OrderMagicNumber()==124))
{ RefreshRates();
OrderClose(OrderTicket(),OrderLots(),Bid,3,Red);
Sleep(10000);
}
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
Эксп работал некоректно пришлось править код - Магики пришлось вставить. Мелодию оповещения вставил и просто почистил код.