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

Nouveau Bot pour fêter l'entrée en 2020

  • lefeuvr3

    Code
    //+------------------------------------------------------------------+ //| MODULOLG SH TP SL MULTIBUY MULTISELL .mq4 | //| Copyright 2020, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2020, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" //+------------------------------------------------------------------+ //| PARAMETRES EURUSD 1 MN | //+------------------------------------------------------------------+ int MagicNumber=01012020; //magic extern string Name_EA = "MODULOLG SH TP SL MULTIBUY MULTISELL"; extern double LotFactorLONG=300 ; // double LotFactorSHORT = 130; //lotsize factor extern double MultiplierLONG = 0; // double MultiplierSHORT = 0.7; //from 0.04...to 0.09 extern double multiplier1=10; extern double multiplier2=9; extern double multiplier3=3; extern double multiplier4=3; extern double multiplier5=6; extern double multiplier6=4; int long_courtLONG=1; // 0 = Long & 1 = Court int long_courtSHORT=1; // 0 = Long & 1 = Court extern int gainLONG=300; // no comment ;) extern int gainSHORT=300; // no comment ;) input int ecartLONG=82;// Ecart : 150, 1000, ou 1500 selon les paires.. int ecartSHORT=18;// Ecart : 150, 1000, ou 1500 selon les paires extern bool trail=true; extern double TrailingStop=48; double pips = 0.00001; //leave as default for 5 digit brokers int stopOK = 0; // ne pas modifier int sendOK = 0; // ne pas modifier int hour=23; int c=0; double LotSizeLONG; //lotsize double SizeLotLONG; double LotSizeSHORT; //lotsize double SizeLotSHORT; int stop =75; extern int Slippage =0; //---- double TP=0,SL=0,TR; //+------------------------------------------------------------------+ //| Hidden StopLoss Calculations | //+------------------------------------------------------------------+ void StopLoss() { double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; SL=stop*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); } } } } //+------------------------------------------------------------------+ //| Trailing Stoploss après Breakeven | //+------------------------------------------------------------------+ void trail() { for (int i = OrdersTotal()-1; i >= 0; i --) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) if(OrderSymbol()==Symbol()) { if(OrderType()==OP_BUY) { if(Bid - OrderOpenPrice() > TrailingStop *10* MarketInfo(OrderSymbol(),MODE_POINT)) { if(((OrderStopLoss() < Bid - TrailingStop *10* MarketInfo(OrderSymbol(), MODE_POINT))&& ((Bid-OrderOpenPrice())>(Point*TrailingStop)))|| (OrderStopLoss()==0)) { bool modify1=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*10*MarketInfo(OrderSymbol(),MODE_POINT),OrderTakeProfit(),Red); } } } else if(OrderType()==OP_SELL) { if(OrderOpenPrice()-Ask>TrailingStop*10*MarketInfo(OrderSymbol(),MODE_POINT)) { if(((OrderStopLoss()>Ask+TrailingStop*10*MarketInfo(OrderSymbol(),MODE_POINT))&& ((OrderOpenPrice()-Ask)>(Point*TrailingStop)))|| (OrderStopLoss()==0)) { bool modify2=OrderModify(OrderTicket(),OrderOpenPrice(), Ask+TrailingStop*10*MarketInfo(OrderSymbol(),MODE_POINT),OrderTakeProfit(),Red); } } } } } } //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { if(trail) trail(); double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; if(IsNewCandle()) { Lot_Volume(); //calc lotsize return(0); } //MODIF*********** if(c==0){if(OrderSend(Symbol(), OP_BUY, SizeLotLONG, Ask, 0, Ask - (stop * Point),0, "MODULOLG SH TP SL MULTIBUY MULTISELL"))c=1;} // if(c==0){if(OrderSend(Symbol(), OP_BUY, SizeLotSHORT, Ask, 0, Ask - (stop * Point),0, "MODULOLG SH TP SL MULTIBUY MULTISELL"))c=1;} // //MODIF*********** Comment(AccountEquity() - AccountBalance()); int type = OrderType(); int type2 = OrderType(); if (Hour()==1 && Minute()==1 && Seconds()==1 && sendOK==0) { sendOK=1;stopOK=0; //+------------------------------------------------------------------+ if(long_courtLONG==1) { { { { { { { { { { { { int ticket1= OrderSend(Symbol(), OP_SELLSTOP, LotSizeLONG, Bid-ecartLONG*multiplier1*pips, 0, 0, 0, 0); int ticket2= OrderSend(Symbol(), OP_SELLSTOP, LotSizeLONG, Bid-ecartLONG*multiplier2*pips, 0, 0, 0, 0); int ticket3= OrderSend(Symbol(), OP_SELLSTOP, LotSizeLONG, Bid-ecartLONG*multiplier3*pips, 0, 0, 0, 0); int ticket4= OrderSend(Symbol(), OP_SELLSTOP, LotSizeLONG, Bid-ecartLONG*multiplier4*pips, 0, 0, 0, 0); int ticket5= OrderSend(Symbol(), OP_SELLSTOP, LotSizeLONG, Bid-ecartLONG*multiplier5*pips, 0, 0, 0, 0); int ticket6= OrderSend(Symbol(), OP_SELLSTOP, LotSizeLONG, Bid-ecartLONG*multiplier6*pips, 0, 0, 0, 0); if(long_courtSHORT==1) { { { { { { { { { { { { int ticket7= OrderSend(Symbol(), OP_SELLSTOP, LotSizeSHORT, Bid-ecartSHORT*multiplier1*pips, 0, 0, 0,0); int ticket8= OrderSend(Symbol(), OP_SELLSTOP, LotSizeSHORT, Bid-ecartSHORT*multiplier2*pips, 0, 0, 0,0); int ticket9= OrderSend(Symbol(), OP_SELLSTOP, LotSizeSHORT, Bid-ecartSHORT*multiplier3*pips, 0, 0, 0,0); int ticket10= OrderSend(Symbol(), OP_SELLSTOP, LotSizeSHORT, Bid-ecartSHORT*multiplier4*pips, 0, 0, 0,0); int ticket11= OrderSend(Symbol(), OP_SELLSTOP, LotSizeSHORT, Bid-ecartSHORT*multiplier5*pips, 0, 0, 0,0); int ticket12= OrderSend(Symbol(), OP_SELLSTOP, LotSizeSHORT, Bid-ecartSHORT*multiplier6*pips, 0, 0, 0,0); if(ticket1<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket2<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket3<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } } } } if(ticket4<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket5<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket6<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } } } } if(ticket7<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket8<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket9<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } } } } if(ticket10<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket11<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket12<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } } } } //+------------------------------------------------------------------+ if(long_courtLONG==0) { { { { { { { { { { { { int ticket13= OrderSend(Symbol(), OP_BUYSTOP, LotSizeLONG, Ask+ecartLONG*1*pips, 0, 0, 0,0); int ticket14= OrderSend(Symbol(), OP_BUYSTOP, LotSizeLONG, Ask+ecartLONG*2*pips, 0, 0, 0,0); int ticket15= OrderSend(Symbol(), OP_BUYSTOP, LotSizeLONG, Ask+ecartLONG*3*pips, 0, 0, 0,0); int ticket16= OrderSend(Symbol(), OP_BUYSTOP, LotSizeLONG, Ask+ecartLONG*1*pips, 0, 0, 0,0); int ticket17= OrderSend(Symbol(), OP_BUYSTOP, LotSizeLONG, Ask+ecartLONG*2*pips, 0, 0, 0,0); int ticket18= OrderSend(Symbol(), OP_BUYSTOP, LotSizeLONG, Ask+ecartLONG*3*pips, 0, 0, 0,0); if(long_courtSHORT==0) // if (!IsTradeContextBusy() && IsTradeAllowed()) { { { { { { { { { { { { int ticket19= OrderSend(Symbol(), OP_BUYSTOP, LotSizeSHORT, Ask+ecartSHORT*1*pips, 0, 0, 0,0); int ticket20= OrderSend(Symbol(), OP_BUYSTOP, LotSizeSHORT, Ask+ecartSHORT*2*pips, 0, 0, 0,0); int ticket21= OrderSend(Symbol(), OP_BUYSTOP, LotSizeSHORT, Ask+ecartSHORT*3*pips, 0, 0, 0,0); int ticket22= OrderSend(Symbol(), OP_BUYSTOP, LotSizeSHORT, Ask+ecartSHORT*1*pips, 0, 0, 0,0); int ticket23= OrderSend(Symbol(), OP_BUYSTOP, LotSizeSHORT, Ask+ecartSHORT*2*pips, 0, 0, 0,0); int ticket24= OrderSend(Symbol(), OP_BUYSTOP, LotSizeSHORT, Ask+ecartSHORT*3*pips, 0, 0, 0,0); if(ticket13<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket14<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket15<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } } } } if(ticket16<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket17<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket18<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } } } } if(ticket19<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket20<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket21<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } } } } if(ticket22<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket23<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket24<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } } } } //+------------------------------------------------------------------+ } if (Hour()>=hour && stopOK==0) { stopOK=1;sendOK=0; int u = OrdersTotal() - 1; while (u >= 0) { if(OrderSelect(u, SELECT_BY_POS)) if (type == OP_SELLSTOP || type == OP_BUYSTOP) { bool modif3= OrderDelete(OrderTicket()); } u -= 1; } } if (AccountEquity()>= AccountBalance()+ gainLONG) if (AccountEquity()>= AccountBalance()+ gainSHORT) { int w = OrdersTotal() - 1; while (w >= 0) { if(OrderSelect(w, SELECT_BY_POS)) { bool modif1= OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID),2); bool modif2= OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK),2); } w -= 1; } //MODIF*********** // if (!IsTradeContextBusy() && IsTradeAllowed()) int ticket25=OrderSend(Symbol(), OP_BUY, SizeLotLONG, Ask, 0, Ask - (stop * Point),0, "MODULOLG SH TP SL MULTIBUY MULTISELL"); int ticket26=OrderSend(Symbol(), OP_BUY, SizeLotSHORT, Ask, 0, Ask - (stop * Point),0, "MODULOLG SH TP SL MULTIBUY MULTISELL"); //--- place market order to buy 1 lot if(ticket25<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); if(ticket26<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); //MODIF*********** } return(0); } //+------------------------------------------------------------------+ //insuring its a new candle function //+------------------------------------------------------------------+ bool IsNewCandle() { static int BarsOnChart=0; if (Bars == BarsOnChart) return (false); BarsOnChart = Bars; return(true); } //+------------------------------------------------------------------+ //Calculates Lot Size based on balance and factor //+------------------------------------------------------------------+ double Lot_Volume() { LotSizeLONG=AccountBalance() * 0.01 /LotFactorLONG ; SizeLotLONG=LotSizeLONG*MultiplierLONG; return(LotSizeLONG); return(SizeLotLONG); LotSizeSHORT=AccountBalance() * 0.01 /LotFactorSHORT ; SizeLotSHORT=LotSizeSHORT*MultiplierSHORT; return(LotSizeSHORT); return(SizeLotSHORT); } //+------------------------------------------------------------------++
    lefeuvr3 a joint une image
    nouveau-bot-pour-feter-l-entree-en-2020-11908
  • lefeuvr3

    Si quelqu'un voulait le simplifier ou l'améliorer, cela serait sympa !
  • lefeuvr3

    Amélioration de la Lisibilité graphique

    Code
    //+------------------------------------------------------------------+ //| MODULOLG SH TP SL MULTIBUY MULTISELL .mq4 | //| Copyright 2020, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2020, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" //+------------------------------------------------------------------+ //| PARAMETRES EURUSD 1 MN | //+------------------------------------------------------------------+ int MagicNumber=01012020; //magic extern string Name_EA = "MODULOLG SH TP SL MULTIBUY MULTISELL"; extern double LotFactorLONG=300 ; // double LotFactorSHORT = 130; //lotsize factor extern double MultiplierLONG = 0; // double MultiplierSHORT = 0.7; //from 0.04...to 0.09 extern double multiplier1=10; extern double multiplier2=9; extern double multiplier3=3; extern double multiplier4=3; extern double multiplier5=6; extern double multiplier6=4; int long_courtLONG=1; // 0 = Long & 1 = Court int long_courtSHORT=1; // 0 = Long & 1 = Court extern int gainLONG=300; // no comment ;) extern int gainSHORT=300; // no comment ;) input int ecartLONG=82;// Ecart : 150, 1000, ou 1500 selon les paires.. int ecartSHORT=18;// Ecart : 150, 1000, ou 1500 selon les paires extern bool trail=true; extern double TrailingStop=48; double pips = 0.00001; //leave as default for 5 digit brokers int stopOK = 0; // ne pas modifier int sendOK = 0; // ne pas modifier int hour=23; int c=0; double LotSizeLONG; //lotsize double SizeLotLONG; double LotSizeSHORT; //lotsize double SizeLotSHORT; int stop =75; extern int Slippage =0; //---- double TP=0,SL=0,TR; //+------------------------------------------------------------------+ //| Hidden StopLoss Calculations | //+------------------------------------------------------------------+ void StopLoss() { double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; SL=stop*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,Red); if(OrderType()==OP_SELL) bool OrdClL=OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Blue); } } } } //+------------------------------------------------------------------+ //| Trailing Stoploss après Breakeven | //+------------------------------------------------------------------+ void trail() { for (int i = OrdersTotal()-1; i >= 0; i --) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) if(OrderSymbol()==Symbol()) { if(OrderType()==OP_BUY) { if(Bid - OrderOpenPrice() > TrailingStop *10* MarketInfo(OrderSymbol(),MODE_POINT)) { if(((OrderStopLoss() < Bid - TrailingStop *10* MarketInfo(OrderSymbol(), MODE_POINT))&& ((Bid-OrderOpenPrice())>(Point*TrailingStop)))|| (OrderStopLoss()==0)) { bool modify1=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*10*MarketInfo(OrderSymbol(),MODE_POINT),OrderTakeProfit(),Red); } } } else if(OrderType()==OP_SELL) { if(OrderOpenPrice()-Ask>TrailingStop*10*MarketInfo(OrderSymbol(),MODE_POINT)) { if(((OrderStopLoss()>Ask+TrailingStop*10*MarketInfo(OrderSymbol(),MODE_POINT))&& ((OrderOpenPrice()-Ask)>(Point*TrailingStop)))|| (OrderStopLoss()==0)) { bool modify2=OrderModify(OrderTicket(),OrderOpenPrice(), Ask+TrailingStop*10*MarketInfo(OrderSymbol(),MODE_POINT),OrderTakeProfit(),Blue); } } } } } } //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { if(trail) trail(); double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; if(IsNewCandle()) { Lot_Volume(); //calc lotsize return(0); } //MODIF*********** if(c==0){if(OrderSend(Symbol(), OP_BUY, SizeLotLONG, Ask, 0, Ask - (stop * Point),0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Red))c=1;} // if(c==0){if(OrderSend(Symbol(), OP_BUY, SizeLotSHORT, Ask, 0, Ask - (stop * Point),0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Red))c=1;} // //MODIF*********** Comment(AccountEquity() - AccountBalance()); int type = OrderType(); int type2 = OrderType(); if (Hour()==1 && Minute()==1 && Seconds()==1 && sendOK==0) { sendOK=1;stopOK=0; //+------------------------------------------------------------------+ if(long_courtLONG==1) { { { { { { { { { { { { int ticket1= OrderSend(Symbol(), OP_SELLSTOP, LotSizeLONG, Bid-ecartLONG*multiplier1*pips, 0,0,0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Blue); int ticket2= OrderSend(Symbol(), OP_SELLSTOP, LotSizeLONG, Bid-ecartLONG*multiplier2*pips, 0, 0, 0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Blue); int ticket3= OrderSend(Symbol(), OP_SELLSTOP, LotSizeLONG, Bid-ecartLONG*multiplier3*pips, 0, 0, 0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Blue); int ticket4= OrderSend(Symbol(), OP_SELLSTOP, LotSizeLONG, Bid-ecartLONG*multiplier4*pips, 0, 0, 0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Blue); int ticket5= OrderSend(Symbol(), OP_SELLSTOP, LotSizeLONG, Bid-ecartLONG*multiplier5*pips, 0, 0, 0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Blue); int ticket6= OrderSend(Symbol(), OP_SELLSTOP, LotSizeLONG, Bid-ecartLONG*multiplier6*pips, 0, 0, 0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Blue); if(long_courtSHORT==1) { { { { { { { { { { { { int ticket7= OrderSend(Symbol(), OP_SELLSTOP, LotSizeSHORT, Bid-ecartSHORT*multiplier1*pips, 0, 0, 0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Blue); int ticket8= OrderSend(Symbol(), OP_SELLSTOP, LotSizeSHORT, Bid-ecartSHORT*multiplier2*pips, 0, 0, 0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Blue); int ticket9= OrderSend(Symbol(), OP_SELLSTOP, LotSizeSHORT, Bid-ecartSHORT*multiplier3*pips, 0, 0, 0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Blue); int ticket10= OrderSend(Symbol(), OP_SELLSTOP, LotSizeSHORT, Bid-ecartSHORT*multiplier4*pips, 0, 0, 0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Blue); int ticket11= OrderSend(Symbol(), OP_SELLSTOP, LotSizeSHORT, Bid-ecartSHORT*multiplier5*pips, 0, 0, 0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Blue); int ticket12= OrderSend(Symbol(), OP_SELLSTOP, LotSizeSHORT, Bid-ecartSHORT*multiplier6*pips, 0, 0, 0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Blue); if(ticket1<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket2<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket3<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket4<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket5<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket6<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket7<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket8<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket9<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket10<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket11<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket12<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } } } } } } } } } } } } } //+------------------------------------------------------------------+ if(long_courtLONG==0) { { { { { { { { { { { { int ticket13= OrderSend(Symbol(), OP_BUYSTOP, LotSizeLONG, Ask+ecartLONG*multiplier1*pips ,0, 0, 0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Red); int ticket14= OrderSend(Symbol(), OP_BUYSTOP, LotSizeLONG, Ask+ecartLONG*multiplier2*pips, 0, 0, 0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Red); int ticket15= OrderSend(Symbol(), OP_BUYSTOP, LotSizeLONG, Ask+ecartLONG*multiplier3*pips, 0, 0, 0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Red); int ticket16= OrderSend(Symbol(), OP_BUYSTOP, LotSizeLONG, Ask+ecartLONG*multiplier4*pips, 0, 0, 0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Red); int ticket17= OrderSend(Symbol(), OP_BUYSTOP, LotSizeLONG, Ask+ecartLONG*multiplier5*pips, 0, 0, 0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Red); int ticket18= OrderSend(Symbol(), OP_BUYSTOP, LotSizeLONG, Ask+ecartLONG*multiplier6*pips, 0, 0, 0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Red); if(long_courtSHORT==0) // if (!IsTradeContextBusy() && IsTradeAllowed()) { { { { { { { { { { { { int ticket19= OrderSend(Symbol(), OP_BUYSTOP, LotSizeSHORT, Ask+ecartSHORT*multiplier1*pips, 0, 0, 0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Red); int ticket20= OrderSend(Symbol(), OP_BUYSTOP, LotSizeSHORT, Ask+ecartSHORT*multiplier2*pips, 0, 0, 0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Red); int ticket21= OrderSend(Symbol(), OP_BUYSTOP, LotSizeSHORT, Ask+ecartSHORT*multiplier3*pips, 0, 0, 0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Red); int ticket22= OrderSend(Symbol(), OP_BUYSTOP, LotSizeSHORT, Ask+ecartSHORT*multiplier4*pips, 0, 0, 0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Red); int ticket23= OrderSend(Symbol(), OP_BUYSTOP, LotSizeSHORT, Ask+ecartSHORT*multiplier5*pips, 0, 0, 0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Red); int ticket24= OrderSend(Symbol(), OP_BUYSTOP, LotSizeSHORT, Ask+ecartSHORT*multiplier6*pips, 0, 0, 0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Red); if(ticket13<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket14<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket15<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket16<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket17<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket18<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket19<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket20<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket21<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket22<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket23<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket24<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } } } } } } } } } } } } } } //+------------------------------------------------------------------+ if (Hour()>=hour && stopOK==0) { stopOK=1;sendOK=0; int u = OrdersTotal() - 1; while (u >= 0) { if(OrderSelect(u, SELECT_BY_POS)) if (type == OP_SELLSTOP || type == OP_BUYSTOP) { bool modif3= OrderDelete(OrderTicket()); } u -= 1; } } if (AccountEquity()>= AccountBalance()+ gainLONG) if (AccountEquity()>= AccountBalance()+ gainSHORT) { int w = OrdersTotal() - 1; while (w >= 0) { if(OrderSelect(w, SELECT_BY_POS)) { bool modif1= OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID),2); bool modif2= OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK),2); } w -= 1; } //MODIF*********** // if (!IsTradeContextBusy() && IsTradeAllowed()) int ticket25=OrderSend(Symbol(), OP_BUY, SizeLotLONG, Ask, 0, Ask - (stop * Point),0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Red); int ticket26=OrderSend(Symbol(), OP_BUY, SizeLotSHORT, Ask, 0, Ask - (stop * Point),0, "MODULOLG SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Red); //--- place market order to buy 1 lot if(ticket25<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); if(ticket26<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); //MODIF*********** } return(0); } //+------------------------------------------------------------------+ //insuring its a new candle function //+------------------------------------------------------------------+ bool IsNewCandle() { static int BarsOnChart=0; if (Bars == BarsOnChart) return (false); BarsOnChart = Bars; return(true); } //+------------------------------------------------------------------+ //Calculates Lot Size based on balance and factor //+------------------------------------------------------------------+ double Lot_Volume() { LotSizeLONG=AccountEquity() * 0.01 /LotFactorLONG ; SizeLotLONG=LotSizeLONG*MultiplierLONG; return(LotSizeLONG); return(SizeLotLONG); LotSizeSHORT=AccountBalance() * 0.01 /LotFactorSHORT ; SizeLotSHORT=LotSizeSHORT*MultiplierSHORT; return(LotSizeSHORT); return(SizeLotSHORT); } //+------------------------------------------------------------------++
  • pravanavivids

    Bonjour
    En référence aux backtest
    Un backtest ne vous dit rien sur les performances futures c'est juste un rêve :)
    Mais mon point est qu'une bonne performance dans un backtest ne garantit pas que le système est également bon dans le trading en direct.
    Le trading est un jeu de probabilités, et la probabilité qu'une EA soit rentable, basée uniquement sur un bon backtest, est très, très très faible.
  • lefeuvr3 — en réponse à pravanavivids dans son message #117891

    Bonjour pravanavivids
    Je suis d'accord avec toi.
    Le backtest viendra simplement comme une aide, très, imparfaite, mais aide quant même en plus de la strategie mise en place.
    Rien ne vaut la mise à l’épreuve en trading direct réel.
    Amicalement
    Gérard
  • lefeuvr3

    Merci d'être intervenu ,car je me sens ,sur ce forum ,un peu solitaire.
    Je ne vois pas grand monde poster ou mettre des programmes de trading complet comme je le fais.
    En fait ,il y a peu d’échanges ,ici.
    Je me demande même,parfois , s'il y a des lecteurs !
    Bonne journée
    Gerard
  • pravanavivids

    Beaucoup de visiteurs qui viennent sur ce site. Mais je pense que la première page du site, beaucoup de gens ne voient pas qu'il y a un forum parce que la première page est surchargée avec trop d'informations..

    Et pour vous dire la vérité, je pense que ceux qui se joignent à ce forum ont tendance à être paresseux dans leur attitude et recherchent juste quelqu'un pour leur donner un système rentable.
    Modifié le 2020-01-09 13:04:14 par pravanavivids
  • pravanavivids

    Je suis sûr que la plupart ne savent même pas comment compiler votre code ;)
  • lefeuvr3

    Variante ...code repensé .
    Code
    //+------------------------------------------------------------------+ //| MODULOLG V1 SH TP SL MULTIBUY MULTISELL .mq4 | //| Copyright 2020, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2020, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" //+------------------------------------------------------------------+ //| PARAMETRES EURUSD 1 MN | //+------------------------------------------------------------------+ int MagicNumber=09012020; //magic extern string Name_EA = "MODULOLG V1 SH TP SL MULTIBUY MULTISELL"; extern double LotFactorLONG=300 ; // double LotFactorSHORT = 130; //lotsize factor extern double MultiplierLONG = 0; // double MultiplierSHORT = 0.7; //from 0.04...to 0.09 extern double multiplier1=10; extern double multiplier2=9; extern double multiplier3=3; extern double multiplier4=3; extern double multiplier5=6; extern double multiplier6=4; int long_courtLONG=1; // 0 = Long & 1 = Court int long_courtSHORT=1; // 0 = Long & 1 = Court extern double A=0; extern double B=0; extern int gainLONG=300; // no comment ;) extern int gainSHORT=300; // no comment ;) input int ecartLONG=82;// Ecart : 150, 1000, ou 1500 selon les paires.. int ecartSHORT=18;// Ecart : 150, 1000, ou 1500 selon les paires extern bool trail=true; extern double TrailingStop=48; double pips = 0.00001; //leave as default for 5 digit brokers int stopOK = 0; // ne pas modifier int sendOK = 0; // ne pas modifier int hour=23; int c=0; double LotSizeLONG; //lotsize double SizeLotLONG; double LotSizeSHORT; //lotsize double SizeLotSHORT; int stop =75; extern int Slippage =0; //---- double TP=0,SL=0,TR; //+------------------------------------------------------------------+ //| Hidden StopLoss Calculations | //+------------------------------------------------------------------+ void StopLoss() { double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; SL=stop*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,Red); if(OrderType()==OP_SELL) bool OrdClL=OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Blue); } } } } //+------------------------------------------------------------------+ //| Trailing Stoploss après Breakeven | //+------------------------------------------------------------------+ void trail() { for (int i = OrdersTotal()-1; i >= 0; i --) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) if(OrderSymbol()==Symbol()) { if(OrderType()==OP_BUY) { if(Bid - OrderOpenPrice() > TrailingStop *10* MarketInfo(OrderSymbol(),MODE_POINT)) { if(((OrderStopLoss() < Bid - TrailingStop *10* MarketInfo(OrderSymbol(), MODE_POINT))&& ((Bid-OrderOpenPrice())>(Point*TrailingStop)))|| (OrderStopLoss()==0)) { bool modify1=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*10*MarketInfo(OrderSymbol(),MODE_POINT),OrderTakeProfit(),Red); } } } else if(OrderType()==OP_SELL) { if(OrderOpenPrice()-Ask>TrailingStop*10*MarketInfo(OrderSymbol(),MODE_POINT)) { if(((OrderStopLoss()>Ask+TrailingStop*10*MarketInfo(OrderSymbol(),MODE_POINT))&& ((OrderOpenPrice()-Ask)>(Point*TrailingStop)))|| (OrderStopLoss()==0)) { bool modify2=OrderModify(OrderTicket(),OrderOpenPrice(), Ask+TrailingStop*10*MarketInfo(OrderSymbol(),MODE_POINT),OrderTakeProfit(),Blue); } } } } } } //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { if(trail) trail(); double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; if(IsNewCandle()) { Lot_Volume(); //calc lotsize return(0); } Comment(AccountEquity() - AccountBalance()); int type = OrderType(); int type2 = OrderType(); if (Hour()==1 && Minute()==1 && Seconds()==1 && sendOK==0) { sendOK=1;stopOK=0; //+------------------------------------------------------------------+ if(long_courtLONG==1) { // if (!IsTradeContextBusy() && IsTradeAllowed()) int ticket1= OrderSend(Symbol(), OP_SELLSTOP, LotSizeLONG, Bid-ecartLONG*multiplier1*pips, 0,0,0, "MODULOLG V1 SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Blue); int ticket2= OrderSend(Symbol(), OP_SELLSTOP, LotSizeLONG, Bid-ecartLONG*multiplier2*pips, 0, 0, 0, "MODULOLG V1 SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Blue); int ticket3= OrderSend(Symbol(), OP_SELLSTOP, LotSizeLONG, Bid-ecartLONG*multiplier3*pips, 0, 0, 0, "MODULOLG V1 SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Blue); int ticket4= OrderSend(Symbol(), OP_SELLSTOP, LotSizeLONG, Bid-ecartLONG*multiplier4*pips, 0, 0, 0, "MODULOLG V1 SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Blue); int ticket5= OrderSend(Symbol(), OP_SELLSTOP, LotSizeLONG, Bid-ecartLONG*multiplier5*pips, 0, 0, 0, "MODULOLG V1 SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Blue); int ticket6= OrderSend(Symbol(), OP_SELLSTOP, LotSizeLONG, Bid-ecartLONG*multiplier6*pips, 0, 0, 0, "MODULOLG V1 SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Blue); if(long_courtSHORT==1) // if (!IsTradeContextBusy() && IsTradeAllowed()) int ticket7= OrderSend(Symbol(), OP_SELLSTOP, LotSizeSHORT, Bid-ecartSHORT*multiplier1*pips, 0, 0, 0, "MODULOLG V1 SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Blue); int ticket8= OrderSend(Symbol(), OP_SELLSTOP, LotSizeSHORT, Bid-ecartSHORT*multiplier2*pips, 0, 0, 0, "MODULOLG V1 SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Blue); int ticket9= OrderSend(Symbol(), OP_SELLSTOP, LotSizeSHORT, Bid-ecartSHORT*multiplier3*pips, 0, 0, 0, "MODULOLG V1 SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Blue); int ticket10= OrderSend(Symbol(), OP_SELLSTOP, LotSizeSHORT, Bid-ecartSHORT*multiplier4*pips, 0, 0, 0, "MODULOLG V1 SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Blue); int ticket11= OrderSend(Symbol(), OP_SELLSTOP, LotSizeSHORT, Bid-ecartSHORT*multiplier5*pips, 0, 0, 0, "MODULOLG V1 SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Blue); int ticket12= OrderSend(Symbol(), OP_SELLSTOP, LotSizeSHORT, Bid-ecartSHORT*multiplier6*pips, 0, 0, 0, "MODULOLG V1 SH TP SL MULTIBUY MULTISELL",MagicNumber,0 , Blue); } } //+------------------------------------------------------------------+ if (Hour()>=hour && stopOK==0) { stopOK=1;sendOK=0; int u = OrdersTotal() - 1; while (u >= 0) { if(OrderSelect(u, SELECT_BY_POS)) if (type == OP_SELLSTOP || type == OP_BUYSTOP) { bool modif3= OrderDelete(OrderTicket()); } u -= 1; } } if (AccountEquity()>= AccountBalance()+ gainLONG) if (AccountEquity()>= AccountBalance()+ gainSHORT) { int w = OrdersTotal() - 1; while (w >= 0) { if(OrderSelect(w, SELECT_BY_POS)) { bool modif1= OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID),2); bool modif2= OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK),2); } w -= 1; } } return(0); } //+------------------------------------------------------------------+ //insuring its a new candle function //+------------------------------------------------------------------+ bool IsNewCandle() { static int BarsOnChart=0; if (Bars == BarsOnChart) return (false); BarsOnChart = Bars; return(true); } //+------------------------------------------------------------------+ //Calculates Lot Size based on balance and factor //+------------------------------------------------------------------+ double Lot_Volume() { LotSizeLONG=AccountEquity() * 0.01 /LotFactorLONG ; SizeLotLONG=LotSizeLONG*MultiplierLONG; return(LotSizeLONG); return(SizeLotLONG); LotSizeSHORT=AccountBalance() * 0.01 /LotFactorSHORT ; SizeLotSHORT=LotSizeSHORT*MultiplierSHORT; return(LotSizeSHORT); return(SizeLotSHORT); } //+------------------------------------------------------------------++
    lefeuvr3 a joint une image
    nouveau-bot-pour-feter-l-entree-en-2020-11927
  • louisakyfran

    Salut à tous.
    Nouveau sur ce site afin de comprendre comment faire ou trouver une stratégie qui peut être rentable sur la durée.
    Je me rend compte qu'effectivement je ne sais pas compiler votre code. Lol
    Je pensai qu'il fallait juste copier coller dans meta editor et compiler mais apparemment non.

    Édit: en le téléchargent et double clic. C'est mieux. Mais du coup avec le tiens comment faire ?

    Bon en faite même en téléchargement ça fonctionne pas.
    Je compile mais il y a des messages de warning.
    Modifié le 2020-01-12 12:16:57 par louisakyfran
  • lefeuvr3

    louisakyfran
    Si tu veux on peut se donner un rendez vous pour voir cela ensemble via teamviewer
    Si cela t’intéresse tu peux me téléphoner au 06.13.44.80.10
    Amicalement
    Gerard Lefeuvre
  • kyfranlouisa — en réponse à lefeuvr3 dans son message #117976

    salut.
    merci pour votre réponse rapide.
    je ne veux pas trop vous deranger. ou vous faire perdre votre temps.
    il y a vraiment beaucoup de manipulation a faire ?
  • kyfranlouisa

    je n'arrive pas a éditer mon message du dessus.
    pour ete sur c'est bien sur mt5 ?
    et donc un copier coller ne suffit pas ?
  • lefeuvr3

    Le problème doit venir de là ...du fait que mon programme est du MT4 ( mq4) et non pas du MT5 !
  • kyfranlouisa — en réponse à lefeuvr3 dans son message #117976

    ok. j'installe mt4 pour commencer alors
    Modifié le 2020-01-13 17:53:48 par kyfranlouisa
  • lefeuvr3

  • kyfranlouisa — en réponse à lefeuvr3 dans son message #117989

    merci. ok mt4 installé. ton script est bien compilé.

    par contre on peut pas faire de backtest comme sur mt5 ?
  • lefeuvr3

    En allant dans affichage ...testeur de strategies...proprietes de l'expert...en cochant optimisation ...en mettant au niveau de modele "chaque tick" ....les dates et ecart actuel ....on a un assez bon backtest
    Si tu as un probleme ,je te rappelle mon telephone 06.13.44.80.10
    Bonne journée
    gerard
  • lefeuvr3

    Si je peux me permettre ,j'ai observe une différence au niveau des backtests
    A savoir une différence quand on est en compte démo ou quand on est en compte réel.
    Différence également si on fait un Backtest la nuit ou le week end .( du fait des variations de spread)
  • Kyfran

    Salut. C'est d'un compliqué pour se connecter à votre site. 3 navigateur différents. URL bloquer par tou.
    Pour info. C'est kygranlouisa.
    Merci pour ton aide du coup.
    Tu ne compile pas sur mt5 ?