Strategy Tester ReportEA Superstar v9.9MetaQuotes-Demo (Build 1361)
交易品种 EURUSD (Euro vs US Dollar) 时间周期 15 分钟图 2020.01.01 22:00 – 2021.12.30 23:45 (2020.01.01 – 2022.01.01) 复盘模型 每个即时价格(基于所有可利用的最小时段的每一个价格的分形插值计算) 参数 magic=1; lot_initial=0.01; multiplier=2; takeprofit=20; distance_pips=15; maxlayer=100; display_info=true; kolor_display=Yellow; fontsize=10; 经测试过的柱数 50080 用于复盘的即时价数量 904424 复盘模型的质量 90.00% 输入图表错误 0 起始资金 10000.00 点差 3 总净盈利 -6977.68 总获利 3465.33 总亏损 -10443.01 盈利比 0.33 预期盈利 -6.50 绝对亏损 6977.68 最大亏损 8704.03 (74.23%) 相对亏损 74.23% (8704.03) 交易单总计 1074 卖单 (%获利百分比) 546 (68.50%) 买单 (%获利百分比) 528 (64.77%) 盈利交易(%占总百分比) 716 (66.67%) 亏损交易(%占总百分比) 358 (33.33%) 最大: 获利交易 512.00 亏损交易 -3496.96 平均 获利交易 4.84 亏损交易 -29.17 最大: 连续获利金额 22 (35.00) 连续亏损金额 11 (-8734.42) 最多: 连续获利次数 576.00 (2) 连续亏损次数 -8734.42 (11) 平均: 连续获利 4 连续亏损 2
//+——————————————————————+
//| JOHN ANAK ANTHONY.mq4 |
//| https://t.me/Astrologe |
//| https://t.me/Astrologe |
//+——————————————————————+
#property copyright “https://t.me/Astrologe 28.5.2017”
#property link “https://t.me/Astrologe”
#property version “9.99”
#property strict
#property description ” New Version: Created for JOHN ANAK ANTHONY 2.5.2017″string EA;
string EA1 = “EA Superstar v99.9″; // Comment To Dispaly In Order
extern int magic = 1; // Magic Number
extern double lot_initial = 0.01; // Lot Started
extern double multiplier = 2.0; // Multiplier
extern int takeprofit = 20; // TakeProfit (Pips)
extern int distance_pips = 15; // Distance Open Position (Pips)
extern int maxlayer = 100; // Max Position(layer) Per Side
extern bool display_info = true; // Show Info On Chart
extern color kolor_display = clrYellow; // Info’s Text Color
extern int fontsize = 10; // Font Sizedouble lotsbuy[];
double lotssell[];string buy = ” buy “;
string sell= ” sell “;//+——————————————————————+
//| Expert initialization function |
//+——————————————————————+
int OnInit()
{
//— create timer
OnTick();
//—
return(INIT_SUCCEEDED);
}
//+——————————————————————+
//| Expert deinitialization function |
//+——————————————————————+
void OnDeinit(const int reason)
{
//— destroy timer
ObjectsDeleteAll();}
//+——————————————————————+
//| Expert tick function |
//+——————————————————————+
void OnTick()
{
//—if (magic==0 || magic >999999999)
Comment(” Pls Adjust Ur Magic Number, EA is DISABLE for good”);
else setup();}
//+——————————————————————+
//| Timer function |
//+——————————————————————+
void OnTimer()
{
//—}
//+——————————————————————+
//| Tester function |
//+——————————————————————+
double OnTester()
{
//—
double ret=0.0;
//—//—
return(ret);
}
//+——————————————————————+
//| ChartEvent function |
//+——————————————————————+
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
//—}
//+——————————————————————+
double stoplvl()
{
double value = 0;
double value1 = MarketInfo(Symbol(),MODE_STOPLEVEL);
double value2 = MarketInfo(Symbol(),MODE_FREEZELEVEL);if (value1 > value2) value = value1;else
if (value1 < value2) value = value2;return(value*Point);
}// end stplvl
//+——————————————————————+
int dec(){ int decimal; if (Digits==3|| Digits==5) decimal=10; else decimal=1; return(decimal);}
//+——————————————————————+
double ask(){RefreshRates();return(nl(MarketInfo(Symbol(),MODE_ASK)));}//
//——————————————————————–+
double bid(){RefreshRates();return(nl(MarketInfo(Symbol(),MODE_BID)));}//
//+——————————————————————+
double minlot(){return(MarketInfo(Symbol(),MODE_MINLOT));}
//+——————————————————————+
double maxlot(){return(MarketInfo(Symbol(),MODE_MAXLOT));}
//+——————————————————————+void openorder( int type, double Lot,double price,double SLvalue, double TPvalue, color kolor)
{
if (Lot < minlot()) Print( ” periksa saiz lot = “, DoubleToStr(Lot,2),” kecil.. minimum lot broker= “, minlot());
if (Lot > maxlot()) Print( ” periksa saiz lot = “, DoubleToStr(Lot,2),” besar.. maximum lot broker= “, maxlot());if (AccountFreeMarginCheck(Symbol(),type,Lot)>0)
{
Comment(“”);
bool order = OrderSend(Symbol() ,type ,Lot ,price ,3*dec() ,SLvalue ,TPvalue ,EA ,magic ,0 ,kolor);
if (!order) Print(Symbol() ,”, Orderticket = “,OrderTicket(),”, type= “,type,”, ERROR=”, GetLastError());
}
else Comment(“Bro.. Pls check ur account margin..”);
}// end
//——————————————————————–+int counter(int type, int magicnumber)
{
int count = 0;
for (int x=0;x<OrdersTotal();x++)
{
if(OrderSelect (x,SELECT_BY_POS,MODE_TRADES) )
if (OrderSymbol() != Symbol()) continue;
if( OrderMagicNumber()!= magicnumber) continue;
if (OrderType() != type) continue;
count++;
}// for loop
return(count);
}// end
//——————————————————————–+
void array_resize()
{
int max = maxlayer ;
int reserved = max+100;
ArrayResize(lotsbuy ,max,reserved);
ArrayResize(lotssell,max,reserved);}// end
//——————————————————————–+void initialize_lotbuy()
{
lotsbuy[0]= lot_initial;
lotsbuy[1]= lot_initial;for(int x=2; x<maxlayer ; x++)
lotsbuy[x] = lotsbuy[x-1]*multiplier;for(int x=0; x<maxlayer ; x++)
lotsbuy[x] = NormalizeDouble(lotsbuy[x],2);}// end
//+——————————————————————+void initialize_lotsell()
{
lotssell[0]= lot_initial;
lotssell[1]= lot_initial;for(int x=2; x<maxlayer; x++)
lotssell[x] = lotssell[x-1]*multiplier;for(int x=0; x<maxlayer ; x++)
lotssell[x] = NormalizeDouble(lotssell[x],2);}// end
//+——————————————————————+double latest_openprice(int type)
{
double value=0;
int ticket = get_latest_ticket(type);
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
value= OrderOpenPrice();return(value);
}// end
//——————————————————————–+double nextlayer_pricebuy()
{
double value = latest_openprice(OP_BUY) – dist();
return(nl(value));
}// end
//+——————————————————————+double nextlayer_pricesell()
{
double value = latest_openprice(OP_SELL) + dist();
return(nl(value));
}// end
//+——————————————————————+double dist()
{return(distance_pips *dec() *Point);}//+——————————————————————+
double nl(double value)
{return(NormalizeDouble(value,Digits));}// end
//+——————————————————————+int get_latest_ticket(int type)
{
int ticket = 0;
for (int x=0;x<OrdersTotal();x++)
{
if(OrderSelect (x,SELECT_BY_POS,MODE_TRADES))
if(OrderSymbol() != Symbol()) continue;
if(OrderMagicNumber() != magic) continue;
if(OrderType() != type) continue;
if(OrderTicket() > ticket || ticket == 0 )
ticket = OrderTicket();
}// for loopreturn(ticket);
}// end
//——————————————————————–+
double tp_buy()
{
double value = latest_openprice(OP_BUY) + takeprofit * dec()* Point;
if (takeprofit*dec()*Point < stoplvl())
value = 0;
return(nl(value));
}//
//+——————————————————————+double tp_sell()
{
double value = latest_openprice(OP_SELL) – takeprofit * dec()* Point;
if (takeprofit*dec()*Point < stoplvl())
value = 0;
return(nl(value));
}//
//+——————————————————————+void put_tp(double tp_cal)
{double tp = nl(tp_cal);
for(int x=0; x<OrdersTotal(); x++)
{
RefreshRates();if(OrderSelect (x,SELECT_BY_POS,MODE_TRADES))
if(OrderSymbol() == Symbol())
if(OrderMagicNumber() == magic )
{
//————————————————
if(OrderType() == OP_BUY)
if(tp > 0)
if(tp != OrderTakeProfit())
if(tp > ask() + stoplvl()){
bool modify = OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),tp,0,clrNONE);
if (!modify) Print(“tp: “,nl(tp),”, Failed To Insert Tp For Buy Trade. error# “, GetLastError());
}//————————————————
if(OrderType() == OP_SELL)
if(tp > 0)
if(tp != OrderTakeProfit())
if(tp < bid() – stoplvl())
{
bool modify = OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),tp,0,clrNONE);
if (!modify) Print(OrderTicket(),”tp: “,nl(tp),”, Failed To Insert TP for Sell Trade. error# “, GetLastError());
}
}// if select
}// for loop
}// end//——————————————————————–+
string floating(int type)
{
double floating = 0;
for (int x=0;x<OrdersTotal();x++)
{
if(OrderSelect (x,SELECT_BY_POS,MODE_TRADES) )
if (OrderSymbol() != Symbol()) continue;
if( OrderMagicNumber()!= magic) continue;
if (OrderType() != type) continue;
floating += OrderProfit();
}// for loop
return(DoubleToStr(floating,2));
}// end
//+——————————————————————+
double totlot(int type)
{
double value = 0;
for (int x=0;x<OrdersTotal();x++)
{
if (OrderSelect (x,SELECT_BY_POS,MODE_TRADES) )
if (OrderSymbol() != Symbol()) continue;
if (OrderMagicNumber()!= magic) continue;
if (OrderType() != type) continue;
value += OrderLots();
}// for loop
return(value);
}// end
//——————————————————————–+void setup()
{
array_resize();
initialize_lotbuy();
initialize_lotsell();//– initial simultaneous orders
if (counter(OP_BUY,magic)==0)
{
EA=EA1+buy+IntegerToString(counter(OP_BUY,magic));
openorder(OP_BUY, lot_initial,ask(),0,0,clrBlue);
}if (counter(OP_SELL,magic)==0)
{
EA=EA1+sell+IntegerToString(counter(OP_SELL,magic));
openorder(OP_SELL,lot_initial,bid(),0,0,clrRed);
}//–layering sell martingale orders
if (counter(OP_SELL,magic) > 0)
if (counter(OP_SELL,magic) < maxlayer)
if (bid() >= nextlayer_pricesell())
{
EA=EA1+sell+IntegerToString(counter(OP_SELL,magic));
openorder(OP_SELL,lotssell[counter(OP_SELL,magic)],bid(),0,0,clrRed);
}//–layering buy martingale orders
if (counter(OP_BUY,magic) > 0)
if (counter(OP_BUY,magic) < maxlayer)
if (ask() <= nextlayer_pricebuy())
{
EA=EA1+buy+IntegerToString(counter(OP_BUY,magic));
openorder(OP_BUY,lotsbuy[counter(OP_BUY,magic)],ask(),0,0,clrBlue);
}//– put tp
if (counter(OP_BUY,magic)>0)
put_tp(tp_buy());
if (counter(OP_SELL,magic)>0)
put_tp(tp_sell());if(display_info)
display();else {ObjectsDeleteAll(0,OBJ_RECTANGLE_LABEL); ObjectsDeleteAll(0,OBJ_LABEL);}
}// end//——————————————————————–+
void display()
{int x=160; int x2=80; int x3=40;
int y=50;int yt=14;rec_label(“pak”,170,25,clrSeaGreen);
text(“paktex” ,x ,y+yt*-1,EA1);
text(“balance”,x ,y+yt*1,”BALANCE: “) ;text(“bal” ,x2,y+yt*1 ,DoubleToStr(AccountBalance(),2));
text(“lvg” ,x ,y+yt*2,”LEVERAGE: “) ;text(“levg” ,x2,y+yt*2 ,DoubleToStr(AccountLeverage(),0));
text(“fmargin”,x ,y+yt*3,”F.MARGIN: “) ;text(“freemargin” ,x2,y+yt*3 ,DoubleToStr(AccountFreeMargin(),2));
text(“margin” ,x ,y+yt*4,”MARGIN: “) ;text(“Margin” ,x2,y+yt*4 ,DoubleToStr(AccountMargin(),2));
text(“equity” ,x ,y+yt*5,”EQUITY: “) ;text(“Equity” ,x2,y+yt*5 ,DoubleToStr(AccountEquity(),2));text(“buy” ,x ,y+yt*7,”BUY: “) ;text(“countbuy”,x2,y+yt*7,IntegerToString(counter(OP_BUY,magic)));
text(“lotbuy” ,x3,y+yt*7,”(“+DoubleToStr(totlot(OP_BUY),2)+”)”);text(“sell” ,x ,y+yt*8,”SELL: “) ;text(“countsell”,x2,y+yt*8,IntegerToString(counter(OP_SELL,magic)));
text(“lotsell”,x3,y+yt*8,”(“+DoubleToStr(totlot(OP_SELL),2)+”)”);text(“fbuy” ,x,y+yt*10,”FL.BUY: “) ;text(“flbuy”,x2,y+yt*10,floating(OP_BUY));
text(“fsell” ,x,y+yt*11,”FL.SELL: “) ;text(“flsell”,x2,y+yt*11,floating(OP_SELL));}// end
//——————————————————————–+
void rec_label(string name, int xD,int yD,color warna)
{
//ObjectDelete(name);
ObjectCreate(0,name,OBJ_RECTANGLE_LABEL,0,0,0);
ObjectSetInteger(0,name,OBJPROP_XDISTANCE,xD);
ObjectSetInteger(0,name,OBJPROP_YDISTANCE,yD);
ObjectSetInteger(0,name,OBJPROP_XSIZE,170);
ObjectSetInteger(0,name,OBJPROP_YSIZE,200);
ObjectSetInteger(0,name,OBJPROP_BGCOLOR,warna);
ObjectSetInteger(0,name,OBJPROP_BORDER_TYPE,STYLE_SOLID);
ObjectSetInteger(0,name,OBJPROP_CORNER,CORNER_RIGHT_UPPER);
ObjectSetInteger(0,name,OBJPROP_COLOR,clrSilver);
ObjectSetInteger(0,name,OBJPROP_STYLE,BORDER_SUNKEN);
ObjectSetInteger(0,name,OBJPROP_WIDTH,5);
ObjectSetInteger(0,name,OBJPROP_BACK,true);
ObjectSetInteger(0,name,OBJPROP_SELECTABLE,false);
ObjectSetInteger(0,name,OBJPROP_SELECTED,false);
ObjectSetInteger(0,name,OBJPROP_HIDDEN,true);
}
//+——————————————————————+
void text(string name2, int xDtext, int yDtext,string text)
{
ObjectDelete(name2);
ObjectCreate(0,name2,OBJ_LABEL,0,0,0);
ObjectSetInteger(0,name2,OBJPROP_XDISTANCE,xDtext);
ObjectSetInteger(0,name2,OBJPROP_YDISTANCE,yDtext);
ObjectSetInteger(0,name2,OBJPROP_CORNER,CORNER_RIGHT_UPPER);
ObjectSetString(0,name2,OBJPROP_TEXT,text);
ObjectSetString(0,name2,OBJPROP_FONT,”Arial”);
ObjectSetInteger(0,name2,OBJPROP_FONTSIZE,fontsize);
ObjectSetInteger(0,name2,OBJPROP_COLOR,kolor_display);
ObjectSetInteger(0,name2,OBJPROP_BACK,false);
ObjectSetInteger(0,name2,OBJPROP_SELECTABLE,false);
ObjectSetInteger(0,name2,OBJPROP_SELECTED,false);
ObjectSetInteger(0,name2,OBJPROP_HIDDEN,true);}// end text
//+——————————————————————+
相关资源
暂无评论...