mais on peu faire en sorte qu'il en ouvre plusieurs non? j'ai lu au dessus. cela fonction?
je suis nouveau je ne c'est pas fair de backtest :s
je suis nouveau je ne c'est pas fair de backtest :s
La garantie Forexagone permet de vous assurer que votre gain ne soit pas perdu. Nous négocions les meilleurs taux avec les brokers agréés par l’AMF.
////////////////////////////////////////////////////////////////////////
//+------------------------------------------------------------------+//
//| Robot pour trading automatique et semi-automatique |//
//| EearlyTakeProfitv1.01 du 21/11/2010 |//
//|EA basé sur EarlyTopProrate, téléchargeable dans la librairie MT4 |//
//| Copyright © 2010-2011 ,Furax, membre Forexagone |//
//| Lien du site : http://www.forexagone.com |//
//+------------------------------------------------------------------+//
////////////////////////////////////////////////////////////////////////
#property copyright "All Members" // membre Forexagone.com
#property link "http://www.forexagone.com"
////////////////////////////////////////////////////////////////////////
//+------------------------------------------------------------------+//
//| Définition des variables horaires |//
//+------------------------------------------------------------------+//
////////////////////////////////////////////////////////////////////////
extern int Heure_Depart = 1; //Heure d'ouverture de la bourse sur la paire choisie. Ex : EUR/USD ouverture à 10:00 (Heure_Depart = 10)
extern int Heure_Fin = 22; //Heure de fin d'ouverture sur la paire choisie. Ex : EUR/USD fin d'ouverture à 17:00 (Heure_Fin = 17)
extern int Heure_Fermeture = 23; //Heure de bouclage de positions. Prise de bénéfice ou perte... (Heure_Fermeture = 23)
extern int GMT = 0; //Gestion du GMT. Par defaut laisser à 0 . ( GMT Greenwitch Midde Time )
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
//+------------------------------------------------------------------+//
//| Définition des variables générales |//
//+------------------------------------------------------------------+//
////////////////////////////////////////////////////////////////////////
double Volumes = 0.1; //Par défaut 0.1
//////////////////////////////////
//| Définition des Take Profit |//
//////////////////////////////////
int TP1 = 8; //Take Profit Phase 1 -- Defaut : 25 // was Furax 45
int TP2 = 10; //Take Profit Phase 2 -- Defaut : 50 // was Furax 75
int TP3 = 15; //Take Profit Phase 3 -- Defaut : 70 // was Furax 105
int setTP = 15; //Defaut : 35 // was Furax 85
//////////////////////////////////
//////////////////////////////////
//| Définition des Stop Loss |//
//////////////////////////////////
int setSL0 = 100;//100; // SL=> +/-50 // was 100
int setSL1 = 75;//35; // Stop Loss // was 35
int setSL2 = 200;//100; // Stop Loss // was 60
int modiSL = 25; // setSL2-35=25 // was 25
//////////////////////////////////
//////////////////////////////////
//| Définition des Ratios |//
//////////////////////////////////
int Ratio1 = 30;
int Ratio2 = 70;
int Ratio3 = 100;
int Phase = 0; // was 0
//////////////////////////////////
int Magic = 121110; // was 121110
bool Signal_Achat = true; // was = false;
bool Signal_Vente = true; // was = false;
string Tendance = "Inconnue";
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
//+------------------------------------------------------------------+//
//| Définition du Manager D'Argent |//
//+------------------------------------------------------------------+//
////////////////////////////////////////////////////////////////////////
extern int MAType = 3; //1=Mode Risque Faible //2=Mode Risque Moyenne //3=Mode Risque Exponentiel (Par défaut)
int FacteurMA = 3; // was int FacteurMA = 3;
int RisqueMA = 35; // was int RisqueMA = 50;
////////////////////////////////////////////////////////////////////////
double o1, h1, l1;
double MAtrend, MAtrend1;
double Calcul_Volume, varLots, opLongLots, opShortLots;
string ProfitPoints;
int i;
//+------------------------------------------------------------------+
int init()
{ return(0); }
//+------------------------------------------------------------------+
int deinit()
{ return(0); }
//+------------------------------------------------------------------+
int start()
{
modiSL = setSL2-35; // was modiSL = setSL2-35; // was Furax -70
// ---- Nombre de positions ouvertes / Type
int cnt, cntOpPos, cntOpLong=0, cntOpShort=0;
double Prof;
for(cnt=0; cnt<OrdersTotal(); cnt++)
{
OrderSelect(cnt,SELECT_BY_POS);
if(OrderType()==OP_BUY && OrderSymbol()==Symbol())
{ cntOpLong=cntOpLong+1; cntOpPos=cntOpPos+1; }
if(OrderType()==OP_SELL && OrderSymbol()==Symbol())
{ cntOpShort=cntOpShort+1; cntOpPos=cntOpPos+1; }
}
if (cntOpPos<1) { Phase=0; opLongLots=0; opShortLots=0; ProfitPoints=(TP1+", "+TP2+", "+TP3); }
// ----
int x1=0;
h1 = iHigh(NULL,1618,x1); // was 1440 // 30
l1 = iLow(NULL,1618,x1); // was 1440 // 30
o1 = iOpen(NULL,1618,x1); // was 1440 // 30
if( (h1-o1)>(o1-l1) ) Tendance="Haussière"; else
if( (h1-o1)>(o1-l1) ) Tendance="Baissière"; else Tendance="Plane";
// ---- *** INVERSEMENT ACHAT / VENTE ***
if (Bid>o1
&& Tendance=="Baissière" // was "Haussière"
&& cntOpPos<1) // was && cntOpPos<1)
{
Signal_Vente=true; // was Signal_Achat=true;
}
// ----
if (Ask<o1
&& Tendance=="Haussière" // was "Baissière"
&& cntOpPos<1) // was && cntOpPos<1)
{
Signal_Achat=true; // was Signal_Vente=true;
}
////////////////////////////////////////////////////////////////////////
//+------------------------------------------------------------------+//
//| Manager D'Argent |//
//+------------------------------------------------------------------+//
////////////////////////////////////////////////////////////////////////
if (Signal_Achat==true || Signal_Vente==true)
{
if (MAType >3) {MAType=0;}
if (MAType<=1 && OrdersTotal()<1){ Volumes=Volumes;} //Mode Risque Faible
if (MAType==2 && OrdersTotal()<1){ Volumes=0.1*MathSqrt(AccountBalance()/1000)*FacteurMA;} //Mode Risque Moyen (Par défaut)
if (MAType==3 && OrdersTotal()<1){ Volumes=AccountEquity()/Close[0]/1000*RisqueMA/375;} //Mode Risque Exponentiel // was RisqueMA/100;}
if(MAType>=2)
{
Volumes = Calcul_Volume(Volumes);
double minLot = MarketInfo(Symbol(), MODE_MINLOT);
double maxLot = MarketInfo(Symbol(), MODE_MAXLOT);
if (Volumes<minLot)Volumes=minLot;
if (Volumes>maxLot)Volumes=maxLot;
}
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
//+------------------------------------------------------------------+//
//| Manager D'Ordres |//
//+------------------------------------------------------------------+//
////////////////////////////////////////////////////////////////////////
if(Hour()>=Heure_Depart && Hour()<Heure_Fin)
{
if (Signal_Achat==true && cntOpLong==0 && cntOpPos==0)
{
OrderSend(Symbol(),OP_BUY,Volumes,Ask,0,0,0,"[ACHAT] ETP v1.01",Magic,0,Blue); // ,Blue
Signal_Achat=false;
cntOpPos=1;
}
// --
if (Signal_Vente==true && cntOpShort==0 && cntOpPos==0)
{
OrderSend(Symbol(),OP_SELL,Volumes,Bid,0,0,0,"[VENTE] ETP v1.01",Magic,0,Red); // ,Red
Signal_Vente=false;
}
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
//+------------------------------------------------------------------+//
//| Commentaire Sur Le Graphique |//
//+------------------------------------------------------------------+//
////////////////////////////////////////////////////////////////////////
Comment ("\n"+
"[ ETP v1.01 Par Furax]\n"+
"Manager D'argent Type "+MAType+"\n"+
"Volumes : "+DoubleToStr(Volumes,1)+" -- Phase : "+Phase+"\n"+
"Tendance : "+Tendance+"\n"+
"Horaire Trade : De "+(Heure_Depart+GMT)+":00H à "+(Heure_Fin+GMT)+":00H / Fermeture à "+(Heure_Fermeture+GMT)+":00 H\n"
);
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
//+------------------------------------------------------------------+//
//| Valeurs des positions ouvertes / Court terme |//
//+------------------------------------------------------------------+//
////////////////////////////////////////////////////////////////////////
double opShortPos=0, opLongPos=0;
int shortTP=0,longTP=0;
color col1=Gray, col2=Gray, col1a=Gray, col2a=Gray;
if(OrdersTotal()!=0)
{
for(cnt=0; cnt<OrdersTotal(); cnt++)
{
OrderSelect(cnt,SELECT_BY_POS);
if(OrderType()==OP_SELL && OrderSymbol()==Symbol())
{ opShortPos=OrderOpenPrice(); shortTP=(opShortPos-Ask)/Point; col1=Red;}
if(OrderType()==OP_BUY && OrderSymbol()==Symbol())
{ opLongPos=OrderOpenPrice(); longTP= (Bid-opLongPos)/Point; col2=SpringGreen; }
}
}
ObjectDelete("longTP"); ObjectDelete("longTP_Label");
ObjectDelete("shortTP"); ObjectDelete("shortTP_Label");
ObjectDelete("opLong"); ObjectDelete("opLong_Label");
ObjectDelete("opShort"); ObjectDelete("opShort_Label");
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
//+------------------------------------------------------------------+//
//| Objets |//
//+------------------------------------------------------------------+//
////////////////////////////////////////////////////////////////////////
if(opShortPos==0) {shortTP=0; col1=Gray; col1a=Gray;} else col1a=Silver;
if(opLongPos==0) {longTP=0; col2=Gray; col2a=Gray;} else col2a=Silver;
// ----
if(opShortPos!=0)
{
ObjectCreate("opShort", OBJ_LABEL, 0, 0, 0);
ObjectSetText("opShort",DoubleToStr(opShortPos,Digits-1),9,"Tahoma", col1);
ObjectSet("opShort", OBJPROP_CORNER, 0);
ObjectSet("opShort", OBJPROP_XDISTANCE, 3);
ObjectSet("opShort", OBJPROP_YDISTANCE, 11);
ObjectCreate("shortTP", OBJ_LABEL, 0, 0, 0);
ObjectSetText("shortTP","("+DoubleToStr(shortTP/10,0)+")",9,"Tahoma", col1a);
ObjectSet("shortTP", OBJPROP_CORNER, 0);
ObjectSet("shortTP", OBJPROP_XDISTANCE, 44);
ObjectSet("shortTP", OBJPROP_YDISTANCE, 11);
}
if(opLongPos!=0)
{
ObjectCreate("opLong", OBJ_LABEL, 0, 0, 0);
ObjectSetText("opLong",DoubleToStr(opLongPos,Digits-1),9,"Tahoma", col2);
ObjectSet("opLong", OBJPROP_CORNER, 0);
ObjectSet("opLong", OBJPROP_XDISTANCE, 85);
ObjectSet("opLong", OBJPROP_YDISTANCE, 11);
ObjectCreate("longTP", OBJ_LABEL, 0, 0, 0);
ObjectSetText("longTP","("+DoubleToStr(longTP/10,0)+")",9,"Tahoma", col2a);
ObjectSet("longTP", OBJPROP_CORNER, 0);
ObjectSet("longTP", OBJPROP_XDISTANCE, 126);
ObjectSet("longTP", OBJPROP_YDISTANCE, 11);
}
//----
//return(0);
//} // int start()
//+------------------------------------------------------------------+
if (cntOpPos>0)
{
for (cnt=0;cnt<OrdersTotal();cnt++)
{
OrderSelect(cnt, SELECT_BY_POS);
if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if (OrderType()==OP_BUY)
{
opLongLots=OrderLots();
/*
//---- SL- u. TP-Modify
if (OrderStopLoss()==0)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-modiSL*10*Point,OrderTakeProfit(),0);
return(0);
}
*/
//---- setTP **** 35 **** / TP auf OrderOpenPrice() setzen
if (setTP>0
&& Bid-OrderOpenPrice()<=-setTP*10*Point
&& OrderTakeProfit()==0)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),OrderOpenPrice(),0);
return(0);
}
//---- setSL0 **** 100 **** / BUY-SL od. TP setzen
if (setSL0>0
&& Bid-OrderOpenPrice()<=-setSL0*10*Point)
{
//OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-50*10*Point,OrderTakeProfit(),0);
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),OrderOpenPrice()-50*10*Point,0);
return(0);
}
//---- setSL1 / BUY-SL erhöhen auf OrderOpenPrice()
if (setSL1>0
&& Bid-OrderOpenPrice()>=setSL1*10*Point
&& OrderStopLoss()<OrderOpenPrice())
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0);
return(0);
}
//---- setSL2 / BUY-SL erhöhen auf OrderOpenPrice()+modiSL
if (setSL2>0
&& Bid-OrderOpenPrice()>=setSL2*10*Point
&& OrderStopLoss()<OrderOpenPrice()+modiSL*10*Point)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+modiSL*10*Point,OrderTakeProfit(),0);
return(0);
}
//---- TP1
if(Bid-OrderOpenPrice()>=TP1*10*Point
&& Phase==0
&& TP1>0)
{
OrderClose(OrderTicket(),Calcul_Volume(OrderLots()*Ratio1/100),Bid,0);
Phase=1;
return(0);
}
//---- TP2
if(Bid-OrderOpenPrice()>=TP2*10*Point
&& Phase==1
&& TP2>0)
{
OrderClose(OrderTicket(),Calcul_Volume(OrderLots()*Ratio2/100),Bid,0);
Phase=2;
return(0);
}
//---- TP3 **** 75 ****
if(Bid-OrderOpenPrice()>=TP3*10*Point
&& Phase==2
&& TP3>0)
{
OrderClose(OrderTicket(),Calcul_Volume(OrderLots()*Ratio3/100),Bid,0);
Phase=3;
return(0);
}
} // if (OrderType()==OP_BUY)
// ----
if (OrderType()==OP_SELL)
{
opShortLots=OrderLots();
/*
//---- SL- u. TP-Modify
if (OrderStopLoss()==0)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+modiSL*10*Point,OrderTakeProfit(),0);
return(0);
}
*/
//---- setTP **** 35 **** / TP auf OrderOpenPrice() setzen
if (setTP>0
&& OrderOpenPrice()-Ask<=-setTP*10*Point
&& OrderTakeProfit()==0)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),OrderOpenPrice(),0);
return(0);
}
//---- setSL0 **** 100 **** / SELL-SL od. TP setzen
if (setSL0>0
&& OrderOpenPrice()-Ask<=-setSL0*10*Point)
{
//OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+50*10*Point,OrderTakeProfit(),0);
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),OrderTakeProfit()+50*10*Point,0);
return(0);
}
//---- setSL1 / SELL-SL senken auf OrderOpenPrice()
if (setSL1>0
&& OrderOpenPrice()-Ask>=setSL1*10*Point
&& OrderStopLoss()>OrderOpenPrice())
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0);
return(0);
}
//---- setSL2 / SELL-SL senken auf OrderOpenPrice()-modiSL
if (setSL2>0
&& OrderOpenPrice()-Ask>=setSL2*10*Point
&& OrderStopLoss()>OrderOpenPrice()-modiSL*10*Point)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-modiSL*10*Point,OrderTakeProfit(),0);
return(0);
}
//---- TP1
if(OrderOpenPrice()-Ask>=TP1*10*Point
&& Phase==0
&& TP1>0)
{
OrderClose(OrderTicket(),Calcul_Volume(OrderLots()*Ratio1/100),Ask,0);
Phase=1;
return(0);
}
//---- TP2
if(OrderOpenPrice()-Ask>=TP2*10*Point
&& Phase==1
&& TP2>0)
{
OrderClose(OrderTicket(),Calcul_Volume(OrderLots()*Ratio2/100),Ask,0);
Phase=2;
return(0);
}
//---- TP3 **** 75 ****
if(OrderOpenPrice()-Ask>=TP3*10*Point
&& Phase==2
&& TP3>0)
{
OrderClose(OrderTicket(),Calcul_Volume(OrderLots()*Ratio3/100),Ask,0);
Phase=3;
return(0);
}
}
{
if (opLongLots==Volumes || opShortLots==Volumes
|| (opLongLots==0 && opShortLots==0) ) { Phase=0; ProfitPoints=(TP1+", "+TP2+", "+TP3); } else
if((opLongLots >Volumes/2 && opShortLots==0)
|| (opShortLots>Volumes/2 && opLongLots ==0)) { Phase=1; ProfitPoints=(TP2+", "+TP3); } else
if((opLongLots <Volumes/2 && opShortLots==0)
|| (opShortLots<Volumes/2 && opLongLots ==0)) { Phase=2; ProfitPoints=TP3; } else
{ Phase=3; ProfitPoints="k.A."; }
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
//+------------------------------------------------------------------+//
//| Fermeture de la bourse |//
//+------------------------------------------------------------------+//
////////////////////////////////////////////////////////////////////////
if(Heure_Fermeture!=0)
{
if (OrderType()==OP_BUY && Hour()>=Heure_Fermeture)
OrderClose(OrderTicket(),opLongLots,Bid,0); // nicht: OrderLots() 0.1
if (OrderType()==OP_SELL && Hour()>=Heure_Fermeture)
OrderClose(OrderTicket(),opShortLots,Ask,0); // nicht: OrderLots() 0.1
} // if(Heure_Fermeture!=0)
// ----
} // if (OrderSymbol()
} // for (int cnt
} // if (cntOpPos>0)
//----
return(0);
} // int start()
////////////////////////////////////////////////////////////////////////+
////////////////////////////////////////////////////////////////////////
//+------------------------------------------------------------------+//
//| Calcul des volumes (Manager D'Argent) |//
//+------------------------------------------------------------------+//
////////////////////////////////////////////////////////////////////////
double Calcul_Volume(double varLots)
{
double lotStep = MarketInfo(Symbol(), MODE_LOTSTEP);
double tempDouble = varLots + lotStep/2;
tempDouble /= lotStep;
int tempInt = tempDouble;
return (tempInt*lotStep);
}
////////////////////////////////////////////////////////////////////////
// ******************************************************************************