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
  • lefeuvr3

    Variante du GAPOUNET en ajoutant Stop Loss ,Take Profit ,Trailing Stop.

    Merci d'améliorer cette version

    Code
    //+------------------------------------------------------------------+ //| GAPOUNET TP+SL+TS.mq4 | | //| | //+------------------------------------------------------------------+ extern int MagicNumber=20190209; extern double StopLoss=35; extern double TakeProfit=20; extern int TrailingStop=46; extern int Slippage=3; extern int min_gapsize = 3; extern double LotFactor = 52; //lotsize factor double lot; //---- extern string ti="TIME"; //---- extern bool PERIOD_M1=true; extern bool PERIOD_M5=true; extern bool PERIOD_M15=true; extern bool PERIOD_M30=true; extern bool PERIOD_H1=true; extern bool PERIOD_H4=true; extern bool PERIOD_D1=true; //---- 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; //---- //---- 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 initialization function | //+------------------------------------------------------------------+ int init() { //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- return(0); } //+------------------------------------------------------------------+ // expert start function //+------------------------------------------------------------------+ int start() { // Defining the variables to decide.PERIODE M1 Print("order time", order_timeM1); double current_openprice = iOpen(Symbol(),PERIOD_M1, 0); double previous_highprice = iHigh(Symbol(),PERIOD_M1, 1); double previous_lowprice = iLow(Symbol(),PERIOD_M1, 1); double point_gap = MarketInfo(Symbol(), MODE_POINT); int spread_gap = MarketInfo(Symbol(), MODE_SPREAD); datetime current_time = iTime(Symbol(),PERIOD_M1, 0); // double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; double TheStopLoss=0; double TheTakeProfit=0; if( TotalOrdersCount()==0 ) { int result=0; //catching the gap on buy down gap if(PERIOD_M1==true) if(current_openprice < previous_lowprice - (min_gapsize + spread_gap)*point_gap && current_time != order_timeM1) if (!IsTradeContextBusy() && IsTradeAllowed()) { int ticketM1= OrderSend(Symbol(),OP_BUY,NR(Lot_Volume()),Ask,0,0,previous_lowprice - spread_gap*point_gap,"EA.QPG",MagicNumber,0,Blue); order_timeM1= iTime(Symbol(),PERIOD_M1, 0); Print("I am inside (buy) :-)", order_timeM1); if(ticketM1 < 0) { Print("OrderSend failed with error #", GetLastError()); } 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)) bool modif1= OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } // catching the gap on sell upper gap if(PERIOD_M1==true) if(current_openprice > previous_highprice + (min_gapsize + spread_gap)*point_gap && current_time != order_timeM1) if (!IsTradeContextBusy() && IsTradeAllowed()) { result=OrderSend(Symbol(), OP_SELL, NR(Lot_Volume()), Bid,0,0,previous_highprice + spread_gap*point_gap,"EA.QPG",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()); } } 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)) bool modif2=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } // Defining the variables to decide.PERIODE M5 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); // // if(Digits==3 || Digits==5) MyPoint=Point*10; if( TotalOrdersCount()==0 ) { //catching the gap on buy down gap if(PERIOD_M5==true) if(current_openprice < previous_lowprice - (min_gapsize + spread_gap)*point_gap && current_time != order_timeM5) if (!IsTradeContextBusy() && IsTradeAllowed()) { int ticketM5= OrderSend(Symbol(),OP_BUY,NR(Lot_Volume()),Ask,0,0,previous_lowprice - spread_gap*point_gap,"EA.QPG",MagicNumber,0,Blue); order_timeM5= iTime(Symbol(),PERIOD_M5, 0); Print("I am inside (buy) :-)", order_timeM1); if(ticketM5 < 0) { Print("OrderSend failed with error #", GetLastError()); } 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)) bool modif7= OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } // catching the gap on sell upper gap if(PERIOD_M5==true) if(current_openprice > previous_highprice + (min_gapsize + spread_gap)*point_gap && current_time != order_timeM5) if (!IsTradeContextBusy() && IsTradeAllowed()) { result =OrderSend(Symbol(), OP_SELL, NR(Lot_Volume()), Bid,0,0,previous_highprice + spread_gap*point_gap,"EA.QPG",MagicNumber,0,Red); order_timeM5 = iTime(Symbol(),PERIOD_M5, 0); Print("I am inside (sell) :-)", order_timeM1); //---- if(ticketM5 < 0) { Print("OrderSend failed with error #", GetLastError()); } } 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)) bool modif8=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } // Defining the variables to decide.PERIODE M15 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); // if(Digits==3 || Digits==5) MyPoint=Point*10; if( TotalOrdersCount()==0 ) { //catching the gap on buy down gap if(PERIOD_M15==true) if(current_openprice < previous_lowprice - (min_gapsize + spread_gap)*point_gap && current_time != order_timeM15) if (!IsTradeContextBusy() && IsTradeAllowed()) { int ticketM15= OrderSend(Symbol(),OP_BUY,NR(Lot_Volume()),Ask,0,0,previous_lowprice - spread_gap*point_gap,"EA.QPG",MagicNumber,0,Blue); order_timeM15= iTime(Symbol(),PERIOD_M15, 0); Print("I am inside (buy) :-)", order_timeM15); if(ticketM15 < 0) { Print("OrderSend failed with error #", GetLastError()); } 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)) bool modif9= OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } // catching the gap on sell upper gap if(PERIOD_M15==true) if(current_openprice > previous_highprice + (min_gapsize + spread_gap)*point_gap && current_time != order_timeM15) if (!IsTradeContextBusy() && IsTradeAllowed()) { result=OrderSend(Symbol(), OP_SELL, NR(Lot_Volume()), Bid,0,0,previous_highprice + spread_gap*point_gap,"EA.QPG",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()); } } 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)) bool modif10=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } // Defining the variables to decide.PERIODE M30 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); // if(Digits==3 || Digits==5) MyPoint=Point*10; if( TotalOrdersCount()==0 ) { //catching the gap on buy down gap if(PERIOD_M30==true) if(current_openprice < previous_lowprice - (min_gapsize + spread_gap)*point_gap && current_time != order_timeM30) if (!IsTradeContextBusy() && IsTradeAllowed()) { int ticketM30= OrderSend(Symbol(),OP_BUY,NR(Lot_Volume()),Ask,0,0,previous_lowprice - spread_gap*point_gap,"EA.QPG",MagicNumber,0,Blue); order_timeM30= iTime(Symbol(),PERIOD_M30, 0); Print("I am inside (buy) :-)", order_timeM30); if(ticketM30 < 0) { Print("OrderSend failed with error #", GetLastError()); } 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)) bool modif11= OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } // catching the gap on sell upper gap if(PERIOD_M30==true) if(current_openprice > previous_highprice + (min_gapsize + spread_gap)*point_gap && current_time != order_timeM30) if (!IsTradeContextBusy() && IsTradeAllowed()) { result =OrderSend(Symbol(), OP_SELL, NR(Lot_Volume()), Bid,0,0,previous_highprice + spread_gap*point_gap,"EA.QPG",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()); } } 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)) bool modif12=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } // Defining the variables to decide.PERIODE H1 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); // if(Digits==3 || Digits==5) MyPoint=Point*10; if( TotalOrdersCount()==0 ) { //catching the gap on buy down gap if(PERIOD_H1==true) if(current_openprice < previous_lowprice - (min_gapsize + spread_gap)*point_gap && current_time != order_timeH1) if (!IsTradeContextBusy() && IsTradeAllowed()) { int ticketH1= OrderSend(Symbol(),OP_BUY,NR(Lot_Volume()),Ask,0,0, previous_lowprice - spread_gap*point_gap,"EA.QPG",MagicNumber,0,Blue); order_timeH1= iTime(Symbol(),PERIOD_H1, 0); Print("I am inside (buy) :-)", order_timeH1); if(ticketH1 < 0) { Print("OrderSend failed with error #", GetLastError()); } 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)) bool modif13= OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } // catching the gap on sell upper gap if(PERIOD_H1==true) if(current_openprice > previous_highprice + (min_gapsize + spread_gap)*point_gap && current_time != order_timeH1) if (!IsTradeContextBusy() && IsTradeAllowed()) { result=OrderSend(Symbol(), OP_SELL, NR(Lot_Volume()), Bid,0,0,previous_highprice + spread_gap*point_gap,"EA.QPG",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()); } } 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)) bool modif14=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } // Defining the variables to decide.PERIODE H4 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); if(Digits==3 || Digits==5) MyPoint=Point*10; if( TotalOrdersCount()==0 ) { //catching the gap on buy down gap if(PERIOD_H4==true) if(current_openprice < previous_lowprice - (min_gapsize + spread_gap)*point_gap && current_time != order_timeH4) if (!IsTradeContextBusy() && IsTradeAllowed()) { int ticketH4= OrderSend(Symbol(),OP_BUY,NR(Lot_Volume()),Ask,0,0,previous_lowprice - spread_gap*point_gap,"EA.QPG",MagicNumber,0,Blue); order_timeH4= iTime(Symbol(),PERIOD_H4, 0); Print("I am inside (buy) :-)", order_timeH4); if(ticketH4 < 0) { Print("OrderSend failed with error #", GetLastError()); } 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)) bool modif15= OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } // catching the gap on sell upper gap if(PERIOD_H4==true) if(current_openprice > previous_highprice + (min_gapsize + spread_gap)*point_gap && current_time != order_timeH4) if (!IsTradeContextBusy() && IsTradeAllowed()) { result=OrderSend(Symbol(), OP_SELL, NR(Lot_Volume()), Bid,0,0,previous_highprice + spread_gap*point_gap,"EA.QPG",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()); } } 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)) bool modif16=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } // Defining the variables to decide.PERIODE D1 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); // if(Digits==3 || Digits==5) MyPoint=Point*10; if( TotalOrdersCount()==0 ) { //catching the gap on buy down gap if(PERIOD_D1==true) if(current_openprice < previous_lowprice - (min_gapsize + spread_gap)*point_gap && current_time != order_timeD1) if (!IsTradeContextBusy() && IsTradeAllowed()) { int ticketD1= OrderSend(Symbol(),OP_BUY,NR(Lot_Volume()),Ask,0,0,previous_lowprice - spread_gap*point_gap,"EA.QPG",MagicNumber,0,Blue); order_timeD1= iTime(Symbol(),PERIOD_D1, 0); Print("I am inside (buy) :-)", order_timeD1); if(ticketD1 < 0) { Print("OrderSend failed with error #", GetLastError()); } 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)) bool modif17= OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } // catching the gap on sell upper gap if(PERIOD_D1==true) if(current_openprice > previous_highprice + (min_gapsize + spread_gap)*point_gap && current_time != order_timeD1) if (!IsTradeContextBusy() && IsTradeAllowed()) { result=OrderSend(Symbol(), OP_SELL, NR(Lot_Volume()), Bid,0,0,previous_highprice + spread_gap*point_gap,"EA.QPG",MagicNumber,0,Red); order_timeD1 = iTime(Symbol(),PERIOD_D1, 0); Print("I am inside (sell) :-)", order_timeM1); //---- if(ticketD1 < 0) { Print("OrderSend failed with error #", GetLastError()); } } 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)) bool modif18=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)) if(OrderType()<=OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber ) { if(OrderType()==OP_BUY) { 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(TrailingStop>0) { if((OrderOpenPrice()-Ask)>(MyPoint*TrailingStop)) { if((OrderStopLoss()>(Ask+MyPoint*TrailingStop)) || (OrderStopLoss()==0)) { bool modif4=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)) 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); } //+-----------------------------------------------------------
    lefeuvr3 a joint une image
    gapounet-mtf-11095
  • Mikiburger

    Bonjour Lefeuvre,

    Merci pour cet EA. Ainsi que pour tous les autres d'ailleurs.

    Bien à toi,