J'ai dégotté un EA qui a de bons résultats(voir la courbe jointe).
Il tourne en H1 et prend une position par heure.
Mais je ne comprends pas son fonctionnement et ne sais pas sur quel critères , il entre en position.
Voici le code:
extern string LotPerAccount = "100eur_lot=0.01 - 1000eur_lot=0.1 - 10000eur_lot=1.0";
extern double lot = 0.1;
extern int TradeTime = 18;
extern int TakeProfit_BUY = 36;
extern int StopLoss_BUY = 123;
extern int TakeProfit_SELL = 26;
extern int StopLoss_SELL = 174;
extern int MaxOpenTime_BUY = 167;
extern int MaxOpenTime_SELL = 121;
extern string LotSell = "LotSell=(lot/lot)*multiplier .......... allways=multiplier";
extern double Multiplier_Lot_SELL = 0.01;
extern string LotBuy = "LotBuy=lot*multiplier";
extern double Multiplier_Lot_BUY = 1.5;
int gi_152 = 1;
double g_pips_156 = 9.0;
double g_pips_164 = 10.5;
int gi_172 = 7;
int gi_176 = 2;
int g_slippage_180 = 10;
bool gi_184 = TRUE;
int g_ticket_188;
int g_ord_total_192;
int g_pos_196;
double g_bid_200;
double gd_208;
int OpenLong(double a_lots_0 = 0.1) {
string l_comment_8 = "Forex_EAv1.7,long";
int l_magic_16 = 0;
g_ticket_188 = OrderSend(Symbol(), OP_BUY, a_lots_0, Ask, g_slippage_180, Ask - StopLoss_BUY * Point, Ask + TakeProfit_BUY * Point, l_comment_8, l_magic_16, 0, Green);
if (g_ticket_188 > 0) {
if (OrderSelect(g_ticket_188, SELECT_BY_TICKET, MODE_TRADES)) return (0);
Print("OpenLong(),OrderSelect(): ", GetLastError());
return (-1);
}
Print("Error opening Buy order : ", GetLastError());
return (-1);
}
int OpenShort(double a_lots_0 = 0.1) {
string l_slippage_8 = 10;
string l_comment_12 = "Forex_EAv1.7,short";
int l_magic_20 = 0;
g_ticket_188 = OrderSend(Symbol(), OP_SELL, a_lots_0, Bid, l_slippage_8, Bid + StopLoss_SELL * Point, Bid - TakeProfit_SELL * Point, l_comment_12, l_magic_20, 0, Red);
if (g_ticket_188 > 0) {
if (OrderSelect(g_ticket_188, SELECT_BY_TICKET, MODE_TRADES)) return (0);
Print("OpenShort(),OrderSelect(): ", GetLastError());
return (-1);
}
Print("Error opening Sell order : ", GetLastError());
return (-1);
}
int init() {
return (0);
}
int deinit() {
return (0);
}
int start() {
if (TimeHour(TimeCurrent()) > TradeTime) gi_184 = TRUE;
g_ord_total_192 = OrdersTotal();
if (g_ord_total_192 < gi_152) {
if (TimeHour(TimeCurrent()) == TradeTime && gi_184) {
if (Open[gi_172] - Open[gi_176] > g_pips_164 * Point) {
if (AccountFreeMarginCheck(Symbol(), OP_SELL, lot / lot * Multiplier_Lot_SELL) <= 0.0 || GetLastError() == 134/* NOT_ENOUGH_MONEY */) {
Print("Not enough money");
return (0);
}
OpenShort(lot / lot * Multiplier_Lot_SELL);
gi_184 = FALSE;
return (0);
}
if (Open[gi_176] - Open[gi_172] > g_pips_156 * Point) {
if (AccountFreeMarginCheck(Symbol(), OP_BUY, lot * Multiplier_Lot_BUY) <= 0.0 || GetLastError() == 134/* NOT_ENOUGH_MONEY */) {
Print("Not enough money");
return (0);
}
OpenLong(lot * Multiplier_Lot_BUY);
gi_184 = FALSE;
return (0);
}
}
}
if (MaxOpenTime_BUY > 0) {
for (g_pos_196 = 0; g_pos_196 < g_ord_total_192; g_pos_196++) {
if (OrderSelect(g_pos_196, SELECT_BY_POS, MODE_TRADES)) {
gd_208 = (TimeCurrent() - OrderOpenTime()) / 3600.0;
if (NormalizeDouble(gd_208, 8) - MaxOpenTime_BUY >= 0.0) {
RefreshRates();
if (OrderType() == OP_BUY) g_bid_200 = Bid;
if (OrderClose(OrderTicket(), OrderLots(), g_bid_200, 10, Yellow)) {
Print("CloseLong(),OrderSelect():", OrderTicket());
OrderPrint();
} else Print("Error close Long order :", GetLastError());
}
} else Print("TimeOver", GetLastError());
}
}
if (MaxOpenTime_SELL > 0) {
for (g_pos_196 = 0; g_pos_196 < g_ord_total_192; g_pos_196++) {
if (OrderSelect(g_pos_196, SELECT_BY_POS, MODE_TRADES)) {
gd_208 = (TimeCurrent() - OrderOpenTime()) / 3600.0;
if (NormalizeDouble(gd_208, 8) - MaxOpenTime_SELL >= 0.0) {
RefreshRates();
if (OrderType() == OP_SELL) g_bid_200 = Ask;
if (OrderClose(OrderTicket(), OrderLots(), g_bid_200, 10, Yellow)) {
Print("CloseShort(),OrderSelect():", OrderTicket());
OrderPrint();
} else Print("Error close Sell order :", GetLastError());
}
} else Print("TimeOver", GetLastError());
}
}
return (0);
}
Il manque un "MAGIC number" pour pouvoir le faire tourner correctement. Et pour l'instant, il ne prends qu'une position à la fois.
Quelqu'un a une idée de la façon dont-il fonctionne ? Parce que je ne sais pas si ses bons résultats sont dus à ses qualités intrasèques ou à mon opimisation. Merci d'avance.
Année 2009: EURUSD et USDCHF avec prise de position chaque jour à 21 heures
![]() |
|


LinkBack URL
About LinkBacks
Répondre avec citation
sur mes autres EA 
