Mam problem ze swoim EA - tester strategii ciągle wypluwa mi na końcu: 2013.10.12 16:00:43 There were 1 passes done during optimization.
Testowałem na Demie przez tydzień i wysyłał po kilka pending orders, które póżniej były aktywowane, więc nie mam pojęcia dlaczego w Testerze jest tylko jedno passes.
Dodam tylko, że w Testerze ustawiłem metode co Tick i sprawdzałem na różnych TF i zawsze ten sam log w dzienniku.
Kod:
Kod: Zaznacz cały
int GodzinaStart1;
int GodzinaStart2;
int GodzinaStart3;
int GodzinaStop1;
int GodzinaStop2;
int GodzinaStop3;
int MinutaStart1;
int MinutaStart2;
int MinutaStart3;
int MinutaStop1;
int MinutaStop2;
int MinutaStop3;
int Count_OP_BUY;
int Count_OP_BUYLIMIT;
int Count_OP_BUYSTOP;
int Count_OP_SELL;
int Count_OP_SELLLIMIT;
int Count_OP_SELLSTOP;
int IndeksPary;
int IndeksCzasu;
int IndeksHandlu;
int DepoCalcMode;
int StopoutCalcMode;
int StopoutLevel;
double StopoutLevelVal;
string Symb;
datetime CzasStart;
datetime CzasStop;
datetime CzasStart1;
datetime CzasStop1;
datetime CzasStart2;
datetime CzasStop2;
datetime CzasStart3;
datetime CzasStop3;
double DostepneSrodki;
double UzywaneSrodki;
double PotrzebneSrodkiSELL;
double PotrzebneSrodkiBUY;
double TPBUY;
double SLBUY;
double GG;
double DG;
double BUYLIMIT;
double SELLLIMIT;
double TPSELL;
double SLSELL;
double TPBUY1;
double SLBUY1;
double GG1;
double DG1;
double BUYLIMIT1;
double SELLLIMIT1;
double TPSELL1;
double SLSELL1;
double TPBUY2;
double SLBUY2;
double GG2;
double DG2;
double BUYLIMIT2;
double SELLLIMIT2;
double TPSELL2;
double SLSELL2;
double TPBUY3;
double SLBUY3;
double GG3;
double DG3;
double BUYLIMIT3;
double SELLLIMIT3;
double TPSELL3;
double SLSELL3;
double BIDSTART;
double ASKSTART;
int Shift;
double cena;
datetime czas;
double CenaCurrBID;
double CenaCurrASK;
double LotSize;
double TickValue;
int n;
int WszystkieZlecenia;
int TicketBUY;
int TicketSELL;
int AccountStopoutLev;
int AccountRatioBUY;
int AccountRatioSELL;
double LotSizeBUY;
double LotSizeSELL;
double AccountMarginForNewBUY;
double AccountMarginForNewSELL;
double TickSize;
double PipsValue;//dla 1.0 lota
int CheckError;
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
int init()
{
//----
MessageBox("TimeCurrent()="+TimeToStr(TimeCurrent())+"\nTimeLocal()="+TimeToStr(TimeLocal())+"\nTimeHour&TimeMinute()="+TimeHour(TimeCurrent())+":"+TimeMinute(TimeCurrent()));
MessageBox("CzasStart1="+TimeToStr(StrToTime(TimeYear(TimeLocal())+"/"+TimeMonth(TimeLocal())+"/"+TimeDay(TimeLocal())+" "+"17:10:00")));
//StrToTime(StringConcatenate(TimeHour(TimeCurrent())),":",TimeMinute(TimeCurrent()));
//----
return(0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
int start()
{
if (Checktime()==True) Dane_Handlowe1();
else
{
return;
}
if (Dane_Handlowe1()==True)
{
Check_GG_DG();
if(ObjectsTotal()==0)
{
ObjectCreate("DG", OBJ_HLINE,DG,DG,DG);
ObjectCreate("GG", OBJ_HLINE,GG,GG,GG);
}
}
else return;
if (Check_GG_DG()==True) Check_Margin_For_New();
else return;
if (Check_Margin_For_New()==True) Pending_Trade_Status();
else return;
if(Checktime()==true && Check_GG_DG()==true && Check_Margin_For_New()==true) Trade();
else return;
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
bool Checktime()
{
DaneCzasowe();
if (TimeLocal()>=CzasStart1 && TimeLocal()<=CzasStop1 && DayOfWeek()!=0 && DayOfWeek()!=6)
{
CzasStart=CzasStart1;
CzasStop=CzasStop1;
return(true);
}
else return(false);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
bool DaneCzasowe()
{
Symb=Symbol();
CzasStart1=StrToTime(TimeYear(TimeLocal())+"/"+TimeMonth(TimeLocal())+"/"+TimeDay(TimeLocal())+" "+"17:10:00");
CzasStop1=StrToTime(TimeYear(TimeLocal())+"/"+TimeMonth(TimeLocal())+"/"+TimeDay(TimeLocal())+" "+"18:35:00");
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
bool Dane_Handlowe1()
{
TPBUY1=3;
SLBUY1=-12;
TPSELL1=-3;
SLSELL1=12;
GG1=2;
DG1=-2;
IndeksHandlu=6;
cena=iClose(Symb,PERIOD_M5,iBarShift(Symb,PERIOD_M5,CzasStart));
czas=iTime(Symb, PERIOD_M5,iBarShift(Symb,PERIOD_M5,CzasStart));
GG=cena+GG1*Point;
DG=cena+DG1*Point;
TPBUY=DG+TPBUY1*Point;
SLBUY=DG+SLBUY1*Point;
TPSELL=GG+TPSELL1*Point;
SLSELL=GG+SLSELL1*Point;
return(true);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
bool Check_GG_DG()
{
CenaCurrBID=Bid;
CenaCurrASK=Ask;
if ((Bid>=DG && Bid<=GG && DG!=0 && GG!=0)&&(Ask>=DG&&Ask<=GG && DG!=0 && GG!=0)) return (true);
else return(false);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
bool Check_Margin_For_New()
{
Symb=Symbol();
Lot_Size();
AccountStopoutLev=AccountStopoutLevel();
if(AccountMargin()==0)
{
AccountMarginForNewBUY=NormalizeDouble((AccountEquity()-AccountFreeMarginCheck(Symb,0,LotSizeBUY)),2);
if (AccountFreeMarginCheck(Symb,0,LotSizeBUY) <= 0) SendError();
AccountMarginForNewSELL=NormalizeDouble((AccountEquity()-AccountFreeMarginCheck(Symb,1,LotSizeSELL)),2);
if (AccountFreeMarginCheck(Symb,1,LotSizeSELL)<=0) SendError();
AccountRatioBUY=NormalizeDouble((AccountEquity()/AccountMarginForNewBUY)*100,2);
AccountRatioSELL=NormalizeDouble((AccountEquity()/AccountMarginForNewSELL)*100,2);
if(AccountRatioBUY > AccountStopoutLev) return(true);
if(AccountRatioSELL > AccountStopoutLev) return(true);
else return(false);
}
else
{
AccountMarginForNewBUY=NormalizeDouble((AccountEquity()-AccountFreeMarginCheck(Symb,0,LotSizeBUY)),2);
if (AccountFreeMarginCheck(Symb,0,LotSizeBUY)<=0) SendError();
AccountMarginForNewSELL=NormalizeDouble((AccountEquity()-AccountFreeMarginCheck(Symb,1,LotSizeSELL)),2);
if (AccountFreeMarginCheck(Symb,1,LotSizeSELL)<=0) SendError();
AccountRatioBUY=NormalizeDouble((AccountEquity()/(AccountMargin()+AccountMarginForNewBUY)*100),2);
AccountRatioSELL=NormalizeDouble((AccountEquity()/(AccountMargin()+AccountMarginForNewSELL)*100),2);
if(AccountRatioBUY > AccountStopoutLev) return(true);
if(AccountRatioSELL > AccountStopoutLev) return(true);
else return(false);
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
bool Lot_Size()
{
TickValue=(MarketInfo(Symb,MODE_TICKVALUE)/Point)*MarketInfo(Symb,MODE_TICKSIZE);
TickSize=MarketInfo(Symb,MODE_TICKSIZE);
PipsValue=TickValue*10;
LotSizeBUY=NormalizeDouble((AccountEquity()/(-SLBUY1*PipsValue*100)),2);
LotSizeSELL=NormalizeDouble((AccountEquity()/(SLSELL1*PipsValue*100)),2);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
int Pending_Trade_Status()
{
Count_OP_BUY=0;
Count_OP_BUYLIMIT=0;
Count_OP_BUYSTOP=0;
Count_OP_SELL=0;
Count_OP_SELLLIMIT=0;
Count_OP_SELLSTOP=0;
WszystkieZlecenia = OrdersTotal();
if (WszystkieZlecenia==0) return(0);
else
{
for(n=0;n<WszystkieZlecenia;n++)
{
if(OrderSelect(n,SELECT_BY_POS)==true && OrderSymbol()==Symb)
{
if(OrderType()==OP_BUY) Count_OP_BUY=Count_OP_BUY+1;
if(OrderType()==OP_BUYLIMIT) Count_OP_BUYLIMIT=Count_OP_BUYLIMIT+1;
if(OrderType()==OP_BUYSTOP) Count_OP_BUYSTOP=Count_OP_BUYSTOP+1;
if(OrderType()==OP_SELL) Count_OP_SELL=Count_OP_SELL+1;
if(OrderType()==OP_SELLLIMIT) Count_OP_SELLLIMIT=Count_OP_SELLLIMIT+1;
if(OrderType()==OP_SELLSTOP) Count_OP_SELLSTOP=Count_OP_SELLSTOP+1;
}
}
if (Count_OP_BUY==0 && Count_OP_BUYLIMIT==0 && Count_OP_BUYSTOP==0) return(2);
if (Count_OP_SELL==0 && Count_OP_SELLLIMIT==0 && Count_OP_SELLSTOP==0) return(1);
else return(3);
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
int Trade()
{
if(Checktime()==true && Check_GG_DG()==true && Check_Margin_For_New()==true)
{
if(Pending_Trade_Status()==2)
{
TicketBUY=OrderSend(Symb,OP_BUYLIMIT,LotSizeBUY,DG,2,SLBUY,TPBUY,NULL,TimeLocal(),CzasStop,CLR_NONE);//BUYLIMIT
Alert("\nTrade()_1_SYMB=",Symb,"\nTrade()_1_TicketBUY=",TicketBUY,"\nTrade()_1_Cena=",DG,"\nTrade()_1_SLBUY=",SLBUY,"\nTrade()_1_TPBUY=",TPBUY);
return(TicketBUY);
}
if(Pending_Trade_Status()==1)
{
TicketSELL=OrderSend(Symb,OP_SELLLIMIT,LotSizeSELL,GG,2,SLSELL,TPSELL,NULL,TimeLocal(),CzasStop,CLR_NONE);//SELLLIMIT
Alert("\nTrade()_1_SYMB=",Symb,"\nTrade()_1_TicketSELL=",TicketBUY,"\nTrade()_1_Cena=",GG,"\nTrade()_1_SLBUY=",SLSELL,"\nTrade()_1_TPBUY=",TPSELL);
return(TicketSELL);
}
if(Pending_Trade_Status()==0)
{
TicketBUY=OrderSend(Symb,OP_BUYLIMIT,LotSizeBUY,DG,2,SLBUY,TPBUY,NULL,TimeLocal(),CzasStop,CLR_NONE);//BUYLIMIT
SendError();
TicketSELL=OrderSend(Symb,OP_SELLLIMIT,LotSizeSELL,GG,2,SLSELL,TPSELL,NULL,TimeLocal(),CzasStop,CLR_NONE);//SELLLIMIT
SendError();
Alert("\nTrade()_1_SYMB=",Symb,"\nTrade()_1_TicketBUY=",TicketBUY,"\nTrade()_1_Cena=",DG,"\nTrade()_1_SLBUY=",SLBUY,"\nTrade()_1_TPBUY=",TPBUY);
Alert("\nTrade()_1_SYMB=",Symb,"\nTrade()_1_TicketSELL=",TicketSELL,"\nTrade()_1_Cena=",GG,"\nTrade()_1_SLBUY=",SLSELL,"\nTrade()_1_TPBUY=",TPSELL);
return(11);
}
else return(3);
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
int SendError()
{
int CheckError;
CheckError=GetLastError();
MessageBox("Error nr="+CheckError);
}