banner_forum
Devenez membre de la plus grande
communauté francophone sur le Forex
Partagez, échangez et apprenez en gagnant des crédits sur votre compte de trading

Expert Advisor a backtester tous les 15 jours

  • lefeuvr3

    Par experience ,les Ea utilisant des indicateurs dont les périodes peuvent fluctuer donnent d'excellents résultats sur des périodes de 15 jours environs.
    Au bout de 15 jours un nouveau backtest sur une periode de 6 mois doit etre effectué pour avoir les nouveaux paramètres utiles pour les 15 jours a venir

    Code
    //+------------------------------------------------------------------+ //| QPG STOCHASTIC MTF ADX RSI | //+------------------------------------------------------------------+ extern int MagicNumber=20180619; extern string am="AMM"; double lot; //lotsize extern double LotFactor=43; //lotsize factor extern double StopLoss=140; extern double TakeProfit=0; extern int TrailingStop=120; extern int Slippage=3; extern string pe="PERIODS"; extern int PERKM1=5; extern int PERDM1=9; extern int PERKM15=17; extern int PERDM15=3; extern int PERKH1=9; extern int PERDH1=19; extern string sl="SLOW"; extern int SLOW=4; extern string le="LEVELS"; extern int HL=70; extern int LL=10; extern int adxperiod =14; extern int adxthreshold =27; extern int rsiperiod =14; extern int rsilower =35; extern int rsiupper = 65; //---- double TP=0,SL=0,TR; //+------------------------------------------------------------------+ //| Hidden StopLoss Calculations | //+------------------------------------------------------------------+ void StpLoss() { double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; TP=TakeProfit*MyPoint; SL=StopLoss*MyPoint; double OrdP=0,OrdTP=0,OrdSL=0; for(int i=0; i<OrdersTotal(); i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) if(OrderMagicNumber()==MagicNumber && Symbol()==OrderSymbol()) { OrdP=OrderProfit()-MathAbs(OrderSwap())-MathAbs(OrderCommission()); OrdSL=(-1)*SL*OrderLots()*MarketInfo(OrderSymbol(),MODE_TICKVALUE)/Point; OrdTP=TP*OrderLots()*MarketInfo(OrderSymbol(),MODE_TICKVALUE)/Point; if(OrdP>OrdTP || OrdP<OrdSL) { if(OrderType()==OP_BUY) bool OrdClP=OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,clrGreen); if(OrderType()==OP_SELL) bool OrdClL=OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,clrYellow); } } } } //+------------------------------------------------------------------+ // expert start function //+------------------------------------------------------------------+ int start() { double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; double TheStopLoss=0; double TheTakeProfit=0; if( TotalOrdersCount()==0 ) { int result=0; if((iStochastic(NULL,PERIOD_M1,PERKM1,PERDM1,SLOW,MODE_EMA,1,MODE_MAIN,0)<LL)&&(iStochastic(NULL,PERIOD_M1,PERKM1,PERDM1,SLOW,MODE_EMA,1,MODE_SIGNAL,1)>LL)&&(iStochastic(NULL,PERIOD_M15,PERKM15,PERDM15,SLOW,MODE_EMA,1,MODE_MAIN,0)<LL)&&(iStochastic(NULL,PERIOD_M15,PERKM15,PERDM15,SLOW,MODE_EMA,1,MODE_SIGNAL,1)>LL)&&(iStochastic(NULL,PERIOD_H1,PERKH1,PERDH1,SLOW,MODE_EMA,1,MODE_MAIN,0)<LL)&&(iStochastic(NULL,PERIOD_H1,PERKH1,PERDH1,SLOW,MODE_EMA,1,MODE_SIGNAL,1)>LL) // Here is your open buy rule &&(iADX(Symbol(),0,adxperiod,PRICE_CLOSE,MODE_MAIN,0)>adxthreshold ) &&(iRSI(Symbol(),0,rsiperiod,PRICE_CLOSE,0)>rsilower)&&(iRSI(Symbol(),0,rsiperiod,PRICE_CLOSE,0)<rsiupper)) { result=OrderSend(Symbol(),OP_BUY,NR(Lot_Volume()),Ask,Slippage,0,0,"",MagicNumber,0,Blue); if(result>0) { TheStopLoss=0; TheTakeProfit=0; if(TakeProfit>0) TheTakeProfit=Ask+TakeProfit*MyPoint; if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint; if(OrderSelect(result,SELECT_BY_TICKET)==true) bool modif1 = OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } if((iStochastic(NULL,PERIOD_M1,PERKM1,PERDM1,SLOW,MODE_EMA,1,MODE_MAIN,0)>HL)&&(iStochastic(NULL,PERIOD_M1,PERKM1,PERDM1,SLOW,MODE_EMA,1,MODE_SIGNAL,1)<HL)&&(iStochastic(NULL,PERIOD_M15,PERKM15,PERDM15,SLOW,MODE_EMA,1,MODE_MAIN,0)>HL)&&(iStochastic(NULL,PERIOD_M15,PERKM15,PERDM15,SLOW,MODE_EMA,1,MODE_SIGNAL,1)<HL)&&(iStochastic(NULL,PERIOD_H1,PERKH1,PERDH1,SLOW,MODE_EMA,1,MODE_MAIN,0)>HL)&&(iStochastic(NULL,PERIOD_H1,PERKH1,PERDH1,SLOW,MODE_EMA,1,MODE_SIGNAL,1)<HL) &&(iADX(Symbol(),0,adxperiod,PRICE_CLOSE,MODE_MAIN,0)>adxthreshold ) &&(iRSI(Symbol(),0,rsiperiod,PRICE_CLOSE,0)>rsilower)&&(iRSI(Symbol(),0,rsiperiod,PRICE_CLOSE,0)<rsiupper)) // Here is your open Sell rule { result=OrderSend(Symbol(),OP_SELL,NR(Lot_Volume()),Bid,Slippage,0,0,"",MagicNumber,0,Red); if(result>0) { TheStopLoss=0; TheTakeProfit=0; if(TakeProfit>0) TheTakeProfit=Bid-TakeProfit*MyPoint; if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint; if(OrderSelect(result,SELECT_BY_TICKET)==true) bool modif2 = OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } } for(int cnt=0;cnt<OrdersTotal();cnt++) { if(OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)==true) if(OrderType()<=OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber ) { if(OrderType()==OP_BUY) { if((iStochastic(NULL,PERIOD_M1,PERKM1,PERDM1,SLOW,MODE_EMA,1,MODE_MAIN,0)>HL)&&(iStochastic(NULL,PERIOD_M1,PERKM1,PERDM1,SLOW,MODE_EMA,1,MODE_SIGNAL,1)<HL)&&(iStochastic(NULL,PERIOD_M15,PERKM15,PERDM15,SLOW,MODE_EMA,1,MODE_MAIN,0)>HL)&&(iStochastic(NULL,PERIOD_M15,PERKM15,PERDM15,SLOW,MODE_EMA,1,MODE_SIGNAL,1)<HL)&&(iStochastic(NULL,PERIOD_H1,PERKH1,PERDH1,SLOW,MODE_EMA,1,MODE_MAIN,0)>HL)&&(iStochastic(NULL,PERIOD_H1,PERKH1,PERDH1,SLOW,MODE_EMA,1,MODE_SIGNAL,1)<HL) //here is your close buy rule &&(iADX(Symbol(),0,adxperiod,PRICE_CLOSE,MODE_MAIN,0)>adxthreshold ) &&(iRSI(Symbol(),0,rsiperiod,PRICE_CLOSE,0)>rsilower)&&(iRSI(Symbol(),0,rsiperiod,PRICE_CLOSE,0)<rsiupper)) { bool modif4 =OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage,Red); } if(TrailingStop>0) { if(Bid-OrderOpenPrice()>MyPoint*TrailingStop) { if(OrderStopLoss()<Bid-MyPoint*TrailingStop) { bool modif3 =OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green); return(0); } } } } else { if((iStochastic(NULL,PERIOD_M1,PERKM1,PERDM1,SLOW,MODE_EMA,1,MODE_MAIN,0)<LL)&&(iStochastic(NULL,PERIOD_M1,PERKM1,PERDM1,SLOW,MODE_EMA,1,MODE_SIGNAL,1)>LL)&&(iStochastic(NULL,PERIOD_M15,PERKM15,PERDM15,SLOW,MODE_EMA,1,MODE_MAIN,0)<LL)&&(iStochastic(NULL,PERIOD_M15,PERKM15,PERDM15,SLOW,MODE_EMA,1,MODE_SIGNAL,1)>LL)&&(iStochastic(NULL,PERIOD_H1,PERKH1,PERDH1,SLOW,MODE_EMA,1,MODE_MAIN,0)<LL)&&(iStochastic(NULL,PERIOD_H1,PERKH1,PERDH1,SLOW,MODE_EMA,1,MODE_SIGNAL,1)>LL) // here is your close sell rule &&(iADX(Symbol(),0,adxperiod,PRICE_CLOSE,MODE_MAIN,0)>adxthreshold ) &&(iRSI(Symbol(),0,rsiperiod,PRICE_CLOSE,0)>rsilower)&&(iRSI(Symbol(),0,rsiperiod,PRICE_CLOSE,0)<rsiupper)) { bool modif5 =OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage,Red); } if(TrailingStop>0) { if((OrderOpenPrice()-Ask)>(MyPoint*TrailingStop)) { if((OrderStopLoss()>(Ask+MyPoint*TrailingStop)) || (OrderStopLoss()==0)) { bool modif6 = OrderModify(OrderTicket(),OrderOpenPrice(),Ask+MyPoint*TrailingStop,OrderTakeProfit(),0,Red); return(0); } } } } } } return(0); } int TotalOrdersCount() { int result=0; for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS ,MODE_TRADES)==true) if (OrderMagicNumber()==MagicNumber) result++; } return (result); } //+------------------------------------------------------------------+ //Calculates Lot Size based on balance and factor //+------------------------------------------------------------------+ double NR(double thelot) { double maxlots=MarketInfo(Symbol(),MODE_MAXLOT), minilot=MarketInfo(Symbol(),MODE_MINLOT), lstep=MarketInfo(Symbol(),MODE_LOTSTEP); double lots=lstep*NormalizeDouble(thelot/lstep,0); lots=MathMax(MathMin(maxlots,lots),minilot); return (lots); } //+------------------------------------------------------------------+ double Lot_Volume() { lot=AccountBalance() * 0.01 /LotFactor ; return(lot); } //+------------------------------------------------------------------+

    comme nous le voyons ici un backtest sur 6 mois a permis de maintenir une belle performance pendant les 15 jours qui ont suivis avant de redescendre doucement
    lefeuvr3 a joint une image
    0-10961