Появился советник.
//+------------------------------------------------------------------+
//| BBands-T02.mq4 |
//| Copyright © 2008, HomeSoft-Tartan Corp. |
//| http://www.fxexpert.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, HomeSoft-Tartan Corp."
#property link "http://www.fxexpert.ru"
// EurUsd TF=D1 test 2007 to now USDJPY GBPUSD
extern double Lots = 1.0; // 1.0; // 1.0;
extern double StopLoss = 400; // 300; // 150;
extern double TakeProfit = 350; // 50; // 100;
extern double Magic = 121; // 122; // 123;
extern double MinMarg = 45000; // 5000; // 5000;
extern double Stop = 2000; // 500; // 1000;
extern int Del = 30; // 25; // 35;
extern int Tone = 6; // 4; // 14;
extern int Ttwo = 19; // 18; // 19;
// Last opt EurUsd D1
// 97 48649.00 220 1.30 221.13 8234.50 7.45% StopLoss=400 TakeProfit=350
// MinMarg=45000 Stop=2000 Del=30 Tone=6 Ttwo=19 Lots=1 Magic=121
double ssum,bsum,sum,mlot,fmarg;
int ts,tb,cnt,ssig,bsig,s,b,tiket,pl,trend,mord;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
Comment("");
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
Comment("");
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
mlot=Lots;
fmarg=NormalizeDouble(AccountFreeMargin(),0);
if (Close[0]>Close[1]) trend=1;
if (Close[0]<Close[1]) trend=-1;
if (Close[0]==Close[1]) trend=0;
s=0;b=0;ssum=0;bsum=0;sum=0;
for (cnt=OrdersTotal();cnt>=0;cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==Magic) { s=s+1;ssum=ssum+OrderProfit()+OrderSwap(); }
if (OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderMagicNumber()==Magic) { b=b+1;bsum=bsum+OrderProfit()+OrderSwap(); }
}
ssum=MathRound(ssum);
bsum=MathRound(bsum);
sum=ssum+bsum;
if (mord<s+b) mord=s+b;
if (s+b>0 && sum>Stop*mlot) pl=1;
if (s+b==0) pl=0;
if ( pl==1 )
{
for (cnt=OrdersTotal();cnt>=0 ;cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderType()==OP_SELL && OrderMagicNumber()==Magic)
{ RefreshRates();
OrderClose(OrderTicket(),OrderLots(),Ask,3,Red);
Sleep(10000);
return(0);
}
if (OrderSymbol()==Symbol() && OrderType()==OP_BUY && OrderMagicNumber()==Magic)
{ RefreshRates();
OrderClose(OrderTicket(),OrderLots(),Bid,3,Red);
Sleep(10000);
return(0);
}
}
}
if (Hour()==0) {ts=0;tb=0;}
if (Hour()>=Tone && Hour()<=Ttwo && ts+tb==0)
{
if ( ((Close[0]-Open[0])/Point)>=Del && bsum>=0) bsig=1; else bsig=0;
if ( ((Open[0]-Close[0])/Point)>=Del && ssum>=0) ssig=1; else ssig=0;
}
else
{ssig=0;bsig=0;}
if (fmarg>MinMarg && ts+tb==0)
{
if (ssig==1 && trend==-1)
{
RefreshRates();
tiket=OrderSend(Symbol(),OP_SELL,mlot,Bid,5,Bid+StopLoss*Point,Bid-TakeProfit*Point,"HaosTrend",Magic,0,Red);
ts=1;Sleep(10000);
return(0);
}
if (bsig==1 && trend==1)
{
RefreshRates();
tiket=OrderSend(Symbol(),OP_BUY,mlot,Ask,5,Ask-StopLoss*Point,Ask+TakeProfit*Point,"HaosTrend",Magic,0,Red);
tb=1;Sleep(10000);
return(0);
}
}
Comment(" MOrd=",mord," Orders=",s+b," Trend=",trend," FreeMarg=",fmarg," SSum=",ssum," BSum=",bsum," Profit=",sum);
//----
return(0);
}
//+------------------------------------------------------------------+