Rejoindre la communauté
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

GAPOUNET MTF

  • lefeuvr3

    Cet EA trade les gaps sur différentes unites de temps que l'on peut associer ou dissocier avec des résultats différents mais toujours interressants….par exemple en utilisant que le 5 minutes sur le graphique 5 mn on observe un inhabituel "Drawup" comme sur le backtest qui suit
    Ne pas associer trop d'unites de temps peut diminuer le nombre de trades mais accroitre significativement les resultas surtout sur les Unites de temps courtes.
    Code
    //+------------------------------------------------------------------+ //| GAPOUNET.mq4 | //| QPG | //| https://www.mql5.com | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //|GAPS MTF //| //+------------------------------------------------------------------+ #property copyright "QPG Gap MTF." #property link "" extern string mn="MAGIC NUMBER"; extern int MagicNumber=20180821; //magic extern string ip="INPUT PARAMETERS"; extern int min_gapsize = 6; extern string mm="MONEY MANAGEMENT"; double LotSize; //lotsize extern double LotFactor = 1.9; //lotsize factor extern string ti="TIME"; //---- extern bool PERIOD_M1=false; extern bool PERIOD_M5=true; extern bool PERIOD_M15=false; extern bool PERIOD_M30=false; extern bool PERIOD_H1=false; extern bool PERIOD_H4=false; //---- datetime order_timeM1 = 0; datetime order_timeM5 = 0; datetime order_timeM15 = 0; datetime order_timeM30 = 0; datetime order_timeH1 = 0; datetime order_timeH4 = 0; datetime order_timeD1 = 0; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { // Defining the variables to decide. Print("order time", order_timeM1); double current_openpriceM1 = iOpen(Symbol(),PERIOD_M1, 0); double previous_highpriceM1 = iHigh(Symbol(),PERIOD_M1, 1); double previous_lowpriceM1 = iLow(Symbol(),PERIOD_M1, 1); double point_gap = MarketInfo(Symbol(), MODE_POINT); int spread_gap = MarketInfo(Symbol(), MODE_SPREAD); datetime current_timeM1 = iTime(Symbol(),PERIOD_M1, 0); // Print("order time", order_timeM5); double current_openpriceM5 = iOpen(Symbol(),PERIOD_M5, 0); double previous_highpriceM5 = iHigh(Symbol(),PERIOD_M5, 1); double previous_lowpriceM5 = iLow(Symbol(),PERIOD_M5, 1); datetime current_timeM5 = iTime(Symbol(),PERIOD_M5, 0); // Print("order time", order_timeM15); double current_openpriceM15 = iOpen(Symbol(),PERIOD_M15, 0); double previous_highpriceM15 = iHigh(Symbol(),PERIOD_M15, 1); double previous_lowpriceM15 = iLow(Symbol(),PERIOD_M15, 1); datetime current_timeM15 = iTime(Symbol(),PERIOD_M15, 0); // Print("order time", order_timeM30); double current_openpriceM30 = iOpen(Symbol(),PERIOD_M30, 0); double previous_highpriceM30 = iHigh(Symbol(),PERIOD_M30, 1); double previous_lowpriceM30 = iLow(Symbol(),PERIOD_M30, 1); datetime current_timeM30 = iTime(Symbol(),PERIOD_M30, 0); // Print("order time", order_timeH1); double current_openpriceH1 = iOpen(Symbol(),PERIOD_H1, 0); double previous_highpriceH1 = iHigh(Symbol(),PERIOD_H1, 1); double previous_lowpriceH1 = iLow(Symbol(),PERIOD_H1, 1); datetime current_timeH1 = iTime(Symbol(),PERIOD_H1, 0); // Print("order time", order_timeH4); double current_openpriceH4 = iOpen(Symbol(),PERIOD_H4, 0); double previous_highpriceH4 = iHigh(Symbol(),PERIOD_H4, 1); double previous_lowpriceH4 = iLow(Symbol(),PERIOD_H4, 1); datetime current_timeH4 = iTime(Symbol(),PERIOD_H4, 0); // Print("order time", order_timeD1); double current_openpriceD1 = iOpen(Symbol(),PERIOD_D1, 0); double previous_highpriceD1 = iHigh(Symbol(),PERIOD_D1, 1); double previous_lowpriceD1 = iLow(Symbol(),PERIOD_D1, 1); datetime current_timeD1 = iTime(Symbol(),PERIOD_D1, 0); //+-----------------------------------------------------------------+ // catching the gap on sell upper gap M1 if(PERIOD_M1==true) if(current_openpriceM1 > previous_highpriceM1 + (min_gapsize + spread_gap)*point_gap && current_timeM1 != order_timeM1) { int ticketM1 = OrderSend(Symbol(), OP_SELL, NR(Lot_Volume()), Bid, 0, 0, previous_highpriceM1 + spread_gap*point_gap, "", MagicNumber, 0, Red); order_timeM1 = iTime(Symbol(),PERIOD_M1, 0); Print("I am inside (sell) :-)", order_timeM1); //---- if(ticketM1 < 0) { Print("OrderSend failed with error #", GetLastError()); } } // catching the gap on sell upper gap M5 if(PERIOD_M5==true) if(current_openpriceM5 > previous_highpriceM5 + (min_gapsize + spread_gap)*point_gap && current_timeM5 != order_timeM5) { int ticketM5 = OrderSend(Symbol(), OP_SELL, NR(Lot_Volume()), Bid, 0, 0, previous_highpriceM5 + spread_gap*point_gap, "", MagicNumber, 0, Red); order_timeM5 = iTime(Symbol(),PERIOD_M5, 0); Print("I am inside (sell) :-)", order_timeM5); //---- if(ticketM5 < 0) { Print("OrderSend failed with error #", GetLastError()); } } // catching the gap on sell upper gap M15 if(PERIOD_M15==true) if(current_openpriceM15 > previous_highpriceM15 + (min_gapsize + spread_gap)*point_gap && current_timeM15 != order_timeM15) { int ticketM15 = OrderSend(Symbol(), OP_SELL, NR(Lot_Volume()), Bid, 0, 0, previous_highpriceM15 + spread_gap*point_gap, "", MagicNumber, 0, Red); order_timeM15 = iTime(Symbol(),PERIOD_M15, 0); Print("I am inside (sell) :-)", order_timeM15); //---- if(ticketM15 < 0) { Print("OrderSend failed with error #", GetLastError()); } } // catching the gap on sell upper gap M30 if(PERIOD_M30==true) if(current_openpriceM30 > previous_highpriceM30 + (min_gapsize + spread_gap)*point_gap && current_timeM30 != order_timeM30) { int ticketM30 = OrderSend(Symbol(), OP_SELL, NR(Lot_Volume()), Bid, 0, 0, previous_highpriceM30 + spread_gap*point_gap, "", MagicNumber, 0, Red); order_timeM30 = iTime(Symbol(),PERIOD_M30, 0); Print("I am inside (sell) :-)", order_timeM30); //---- if(ticketM30 < 0) { Print("OrderSend failed with error #", GetLastError()); } } // catching the gap on sell upper gap H1 if(PERIOD_H1==true) if(current_openpriceH1 > previous_highpriceH1 + (min_gapsize + spread_gap)*point_gap && current_timeH1 != order_timeH1) { int ticketH1 = OrderSend(Symbol(), OP_SELL, NR(Lot_Volume()), Bid, 0, 0, previous_highpriceH1 + spread_gap*point_gap, "", MagicNumber, 0, Red); order_timeH1 = iTime(Symbol(),PERIOD_H1, 0); Print("I am inside (sell) :-)", order_timeH1); //---- if(ticketH1 < 0) { Print("OrderSend failed with error #", GetLastError()); } } // catching the gap on sell upper gap H4 if(PERIOD_H4==true) if(current_openpriceH4 > previous_highpriceH4 + (min_gapsize + spread_gap)*point_gap && current_timeH4 != order_timeH4) { int ticketH4 = OrderSend(Symbol(), OP_SELL, NR(Lot_Volume()), Bid, 0, 0, previous_highpriceH4 + spread_gap*point_gap, "", MagicNumber, 0, Red); order_timeH4 = iTime(Symbol(),PERIOD_H4, 0); Print("I am inside (sell) :-)", order_timeH4); //---- if(ticketH4< 0) { Print("OrderSend failed with error #", GetLastError()); } } // catching the gap on sell upper gap D1 if(PERIOD_D1==true) if(current_openpriceD1 > previous_highpriceD1 + (min_gapsize + spread_gap)*point_gap && current_timeD1 != order_timeD1) { int ticketD1 = OrderSend(Symbol(), OP_SELL, NR(Lot_Volume()), Bid, 0, 0, previous_highpriceD1 + spread_gap*point_gap, "", MagicNumber, 0, Red); order_timeD1 = iTime(Symbol(),PERIOD_D1, 0); Print("I am inside (sell) :-)", order_timeM15); //---- if(ticketD1< 0) { Print("OrderSend failed with error #", GetLastError()); } } //+-----------------------------------------------------------------+ //catching the gap on buy down gap M1 if(PERIOD_M1==true) if(current_openpriceM1 < previous_lowpriceM1 - (min_gapsize + spread_gap)*point_gap && current_timeM1 != order_timeM1) { ticketM1 = OrderSend(Symbol(), OP_BUY, NR(Lot_Volume()), Ask, 0, 0, previous_lowpriceM1 - spread_gap*point_gap, "", MagicNumber, 0, Green); order_timeM1 = iTime(Symbol(),PERIOD_M1, 0); Print("I am inside (buy) :-)", order_timeM1); if(ticketM1 < 0) { Print("OrderSend failed with error #", GetLastError()); } } //catching the gap on buy down gap M5 if(PERIOD_M5==true) if(current_openpriceM5 < previous_lowpriceM5 - (min_gapsize + spread_gap)*point_gap && current_timeM5 != order_timeM5) { ticketM5 = OrderSend(Symbol(), OP_BUY, NR(Lot_Volume()), Ask, 0, 0, previous_lowpriceM5 - spread_gap*point_gap, "", MagicNumber, 0, Green); order_timeM5 = iTime(Symbol(),PERIOD_M5, 0); Print("I am inside (buy) :-)", order_timeM5); if(ticketM5 < 0) { Print("OrderSend failed with error #", GetLastError()); } } //catching the gap on buy down gap M15 if(PERIOD_M15==true) if(current_openpriceM15 < previous_lowpriceM15 - (min_gapsize + spread_gap)*point_gap && current_timeM15 != order_timeM15) { ticketM15 = OrderSend(Symbol(), OP_BUY, NR(Lot_Volume()), Ask, 0, 0, previous_lowpriceM15 - spread_gap*point_gap, "", MagicNumber, 0, Green); order_timeM15 = iTime(Symbol(),PERIOD_M15, 0); Print("I am inside (buy) :-)", order_timeM15); if(ticketM15 < 0) { Print("OrderSend failed with error #", GetLastError()); } } //catching the gap on buy down gap M30 if(PERIOD_M30==true) if(current_openpriceM30 < previous_lowpriceM30 - (min_gapsize + spread_gap)*point_gap && current_timeM30 != order_timeM30) { ticketM30 = OrderSend(Symbol(), OP_BUY, NR(Lot_Volume()), Ask, 0, 0, previous_lowpriceM30 - spread_gap*point_gap, "", MagicNumber, 0, Green); order_timeM30 = iTime(Symbol(),PERIOD_M30, 0); Print("I am inside (buy) :-)", order_timeM30); if(ticketM30 < 0) { Print("OrderSend failed with error #", GetLastError()); } } //catching the gap on buy down gap H1 if(PERIOD_H1==true) if(current_openpriceH1 < previous_lowpriceH1 - (min_gapsize + spread_gap)*point_gap && current_timeH1 != order_timeH1) { ticketH1 = OrderSend(Symbol(), OP_BUY, NR(Lot_Volume()), Ask, 0, 0, previous_lowpriceH1 - spread_gap*point_gap, "", MagicNumber, 0, Green); order_timeH1 = iTime(Symbol(),PERIOD_H1, 0); Print("I am inside (buy) :-)", order_timeH1); if(ticketH1 < 0) { Print("OrderSend failed with error #", GetLastError()); } } //catching the gap on buy down gap H4 if(PERIOD_H4==true) if(current_openpriceH4 < previous_lowpriceH4 - (min_gapsize + spread_gap)*point_gap && current_timeH4 != order_timeH4) { ticketH4 = OrderSend(Symbol(), OP_BUY, NR(Lot_Volume()), Ask, 0, 0, previous_lowpriceH4 - spread_gap*point_gap, "", MagicNumber, 0, Green); order_timeH4 = iTime(Symbol(),PERIOD_H4, 0); Print("I am inside (buy) :-)", order_timeH4); if(ticketH4 < 0) { Print("OrderSend failed with error #", GetLastError()); } } //catching the gap on buy down gap D1 if(PERIOD_D1==true) if(current_openpriceD1 < previous_lowpriceD1 - (min_gapsize + spread_gap)*point_gap && current_timeD1 != order_timeD1) { ticketD1 = OrderSend(Symbol(), OP_BUY, NR(Lot_Volume()), Ask, 0, 0, previous_lowpriceD1 - spread_gap*point_gap, "", MagicNumber, 0, Green); order_timeD1 = iTime(Symbol(),PERIOD_D1, 0); Print("I am inside (buy) :-)", order_timeD1); if(ticketD1 < 0) { Print("OrderSend failed with error #", GetLastError()); } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ return(0); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //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() { double lot; if (AccountBalance()>=25) lot=0.01; if (AccountBalance()>=50) lot=0.02; if (AccountBalance()>=75) lot=0.03; if (AccountBalance()>=100) lot=0.04; if (AccountBalance()>=125) lot=0.05; if (AccountBalance()>=150) lot=0.06; if (AccountBalance()>=175) lot=0.07; if (AccountBalance()>=200) lot=0.08; if (AccountBalance()>=225) lot=0.09; if (AccountBalance()>=250) lot=0.1; if (AccountBalance()>=275) lot=0.11; if (AccountBalance()>=300) lot=0.12; if (AccountBalance()>=325) lot=0.13; if (AccountBalance()>=350) lot=0.14; if (AccountBalance()>=375) lot=0.15; if (AccountBalance()>=400) lot=0.16; if (AccountBalance()>=425) lot=0.17; if (AccountBalance()>=450) lot=0.18; if (AccountBalance()>=475) lot=0.19; if (AccountBalance()>=500) lot=0.2; if (AccountBalance()>=525) lot=0.21; if (AccountBalance()>=550) lot=0.22; if (AccountBalance()>=575) lot=0.23; if (AccountBalance()>=600) lot=0.24; if (AccountBalance()>=625) lot=0.25; if (AccountBalance()>=650) lot=0.26; if (AccountBalance()>=675) lot=0.27; if (AccountBalance()>=700) lot=0.28; if (AccountBalance()>=725) lot=0.29; if (AccountBalance()>=750) lot=0.30; if (AccountBalance()>=800) lot=0.32; if (AccountBalance()>=825) lot=0.33; if (AccountBalance()>=850) lot=0.34; if (AccountBalance()>=875) lot=0.35; if (AccountBalance()>=900) lot=0.36; if (AccountBalance()>=925) lot=0.37; if (AccountBalance()>=950) lot=0.38; if (AccountBalance()>=975) lot=0.39; if (AccountBalance()>=1000) lot=0.4; if (AccountBalance()>=1025) lot=0.41; if (AccountBalance()>=1050) lot=0.42; if (AccountBalance()>=1075) lot=0.43; if (AccountBalance()>=1100) lot=0.44; if (AccountBalance()>=1125) lot=0.45; if (AccountBalance()>=1150) lot=0.46; if (AccountBalance()>=1175) lot=0.47; if (AccountBalance()>=1200) lot=0.48; if (AccountBalance()>=1225) lot=0.49; if (AccountBalance()>=1250) lot=0.5; if (AccountBalance()>=1275) lot=0.51; if (AccountBalance()>=1300) lot=0.52; if (AccountBalance()>=1325) lot=0.53; if (AccountBalance()>=1350) lot=0.54; if (AccountBalance()>=1350) lot=0.55; if (AccountBalance()>=1400) lot=0.56; if (AccountBalance()>=1450) lot=0.58; if (AccountBalance()>=1500) lot=0.6; if (AccountBalance()>=1550) lot=0.62; if (AccountBalance()>=1600) lot=0.64; if (AccountBalance()>=1650) lot=0.66; if (AccountBalance()>=1700) lot=0.68; if (AccountBalance()>=1750) lot=0.7; if (AccountBalance()>=1800) lot=0.72; if (AccountBalance()>=1850) lot=0.74; if (AccountBalance()>=1900) lot=0.76; if (AccountBalance()>=1950) lot=0.78; if (AccountBalance()>=2000) lot=0.8; if (AccountBalance()>=2025) lot=0.81; if (AccountBalance()>=2050) lot=0.82; if (AccountBalance()>=2075) lot=0.83; if (AccountBalance()>=2100) lot=0.84; if (AccountBalance()>=2150) lot=0.86; if (AccountBalance()>=2175) lot=0.87; if (AccountBalance()>=2200) lot=0.88; if (AccountBalance()>=2225) lot=0.89; if (AccountBalance()>=2250) lot=0.9; if (AccountBalance()>=2275) lot=0.91; if (AccountBalance()>=2300) lot=0.92; if (AccountBalance()>=2350) lot=0.94; if (AccountBalance()>=2400) lot=0.96; if (AccountBalance()>=2450) lot=0.98; if (AccountBalance()>=2500) lot=1.0; if (AccountBalance()>=2550) lot=1.02; if (AccountBalance()>=2600) lot=1.04; if (AccountBalance()>=2700) lot=1.08; if (AccountBalance()>=2800) lot=1.12; if (AccountBalance()>=2900) lot=0.16; if (AccountBalance()>=3000) lot=1.2; if (AccountBalance()>=3100) lot=1.24; if (AccountBalance()>=3200) lot=1.28; if (AccountBalance()>=3300) lot=1.32; if (AccountBalance()>=3400) lot=1.36; if (AccountBalance()>=3500) lot=1.4; if (AccountBalance()>=4000) lot=1.6; if (AccountBalance()>=4500) lot=1.8; if (AccountBalance()>=5000) lot=2.0; if (AccountBalance()>=5500) lot=2.2; if (AccountBalance()>=6000) lot=2.4; if (AccountBalance()>=6500) lot=2.6; if (AccountBalance()>=7000) lot=2.8; if (AccountBalance()>=7500) lot=3; if (AccountBalance()>=8000) lot=3.2; if (AccountBalance()>=8500) lot=3.4; if (AccountBalance()>=9000) lot=3.6; if (AccountBalance()>=9500) lot=3.8; if (AccountBalance()>=10000) lot=4.0; if (AccountBalance()>=10100) lot=4.04; if (AccountBalance()>=10200) lot=4.08; if (AccountBalance()>=10300) lot=4.12; if (AccountBalance()>=10400) lot=4.16; if (AccountBalance()>=10500) lot=4.2; if (AccountBalance()>=10600) lot=4.26; if (AccountBalance()>=10700) lot=4.3; if (AccountBalance()>=10800) lot=4.34; if (AccountBalance()>=10900) lot=4.38; if (AccountBalance()>=11000) lot=4.4; if (AccountBalance()>=12000) lot=4.8; if (AccountBalance()>=13000) lot=5.2; if (AccountBalance()>=14000) lot=5.6; if (AccountBalance()>=15000) lot=6.0; if (AccountBalance()>=20000) lot=8.0; if (AccountBalance()>=30000) lot=12; if (AccountBalance()>=40000) lot=16; if (AccountBalance()>=50000) lot=20; if (AccountBalance()>=60000) lot=24; if (AccountBalance()>=70000) lot=28; if (AccountBalance()>=80000) lot=32; if (AccountBalance()>=90000) lot=36; if (AccountBalance()>=100000) lot=40; if (AccountBalance()>=200000) lot=80; LotSize=lot/LotFactor; return(LotSize); }
    lefeuvr3 a joint une image
    gapounet-mtf-10954
  • lefeuvr3

    et en utilisant seulement l'unite de temps 1 minute de temps en même temps on obtient ce backtest
    Modifié le 2018-08-30 13:41:51 par lefeuvr3
    lefeuvr3 a joint une image
    gapounet-mtf-10955
  • lefeuvr3

    Dernier backtest en associant toutes les unites de temps
    lefeuvr3 a joint une image
    gapounet-mtf-10956