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

MODULO LOTS AUTOAJUSTES TP ST

  • lefeuvr3

    MODULOSTOP_2_2_RSI..VOL..ADX.mq4 ….
    merci de l'améliorer

    Code
    //+------------------------------------------------------------------+ //| MODULOSTOP_2_2_RSI..VOL..ADX.mq4 | //| QPG | EURUSD 1 MN //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "QPG" #property link "https://www.mql5.com" #property version "1.00" //+------------------------------------------------------------------+ //| ModuloStop_2_2.mq4 | //+------------------------------------------------------------------+ int stopOK = 0; // ne pas modifier int sendOK = 0; // ne pas modifier extern double Lots=0.23; // à modifier selon vos moyens extern int long_court=1; // 0 = Long & 1 = Court extern int ecart=100; // diminuer l'écart = + de gain, mais exige un capital plus important extern int gain=26; // no comment ;) extern int adxperiod= 17; extern int adxthreshold=24; extern int rsiperiod=14; extern int rsilower =30; extern int rsiupper =70; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { // double valeur1 = iAO(Symbol(),0,0); // Connecter à l'indicateur technique >> modif de ModuloStop_2_1********* double booster = Volume[1]> Volume[0] &&iADX(Symbol(),0,adxperiod,PRICE_CLOSE,MODE_MAIN,0)> adxthreshold &&iRSI(Symbol(),0,rsiperiod,PRICE_CLOSE,0)>rsilower && iRSI(Symbol(),0,rsiperiod,PRICE_CLOSE,0)<rsiupper ; Comment(AccountEquity() - AccountBalance()); int type = OrderType(); int type2 = OrderType(); if (Hour()==1 && Minute()==1 && Seconds()==1 && sendOK==0) { sendOK=1;stopOK=0; if(long_court==1 && booster ) //modif de ModuloStop_2_1******************************************************** { OrderSend(Symbol(), OP_SELLSTOP, Lots, Bid-ecart*Point, 0, 0, 0, "Ordre 2 !"); } if(long_court==0 && booster )//modif de ModuloStop_2_1******************************************************** { OrderSend(Symbol(), OP_BUYSTOP, Lots, Ask+ecart*Point, 0, 0, 0, "Ordre 2 !"); } } if (Hour()>=23 && stopOK==0) { stopOK=1;sendOK=0; int u = OrdersTotal() - 1; while (u >= 0) { OrderSelect(u, SELECT_BY_POS); if (type == OP_SELLSTOP || type == OP_BUYSTOP) { OrderDelete(OrderTicket()); } u -= 1; } } if (AccountEquity()>= AccountBalance()+ gain) { int w = OrdersTotal() - 1; while (w >= 0) { OrderSelect(w, SELECT_BY_POS); { OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 2); OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 2); } w -= 1; } } return(0); }
    lefeuvr3 a joint une image
    modulo-lots-autoajustes-tp-st-11060
  • lefeuvr3

    version ameliorée …..merci d'apporter votre pierre à son élaboration
    La taille des lots s'adapte automatiquement au capital
    Code
    //+------------------------------------------------------------------+ //| MODULOSTOP_2_2RSI.VOL.ADX.AUTOAJUSTABLE.mq4 | //| QPG | //| https://www.mql5.com | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| EURUSD 1 MN //+------------------------------------------------------------------+ #property copyright "QPG" #property link "https://www.mql5.com" #property version "1.00" int stopOK = 0; // ne pas modifier int sendOK = 0; // ne pas modifier //extern double Lots=0.23; // à modifier selon vos moyens extern int long_court=1; // 0 = Long & 1 = Court extern double LotFactor = 40; //lotsize factor extern int ecart=100; // diminuer l'écart = + de gain, mais exige un capital plus important extern int gain=26; // no comment ;) double lot ; extern int adxperiod= 17; extern int adxthreshold=24; extern int rsiperiod=14; extern int rsilower =30; extern int rsiupper =70; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { // double valeur1 = iAO(Symbol(),0,0); // Connecter à l'indicateur technique >> modif de ModuloStop_2_1********* double booster = Volume[1]> Volume[0] &&iADX(Symbol(),0,adxperiod,PRICE_CLOSE,MODE_MAIN,0)> adxthreshold &&iRSI(Symbol(),0,rsiperiod,PRICE_CLOSE,0)>rsilower && iRSI(Symbol(),0,rsiperiod,PRICE_CLOSE,0)<rsiupper ; Comment(AccountEquity() - AccountBalance()); int type = OrderType(); int type2 = OrderType(); if (Hour()==1 && Minute()==1 && Seconds()==1 && sendOK==0) { sendOK=1;stopOK=0; if(long_court==1 && booster ) //modif de ModuloStop_2_1******************************************************** { bool modif1= OrderSend(Symbol(), OP_SELLSTOP, NR(Lot_Volume()), Bid-ecart*Point, 0, 0, 0, "Ordre 2 !"); } if(long_court==0 && booster )//modif de ModuloStop_2_1******************************************************** { bool modif2= OrderSend(Symbol(), OP_BUYSTOP,NR(Lot_Volume()), Ask+ecart*Point, 0, 0, 0, "Ordre 2 !"); } } if (Hour()>=23 && 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()+ gain) { int w = OrdersTotal() - 1; while (w >= 0) { if(OrderSelect(w, SELECT_BY_POS)) { bool modif4= OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 2); bool modif5= OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 2); } w -= 1; } } 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() { lot=AccountBalance() * 0.01 /LotFactor ; return(lot); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+
    Modifié le 2018-11-27 07:29:21 par lefeuvr3
    lefeuvr3 a joint une image
    modulo-lots-autoajustes-tp-st-11061
  • Tirbo

    Bonjour Lefeuvr3,

    Ne serait ce pas une stratégie SELL order breakout range + 5pips?
    En revanche je n'ai que des SELL... Sur EUR USD 1M
  • lefeuvr3

    On peut mettre sell ou buy au choix

    Je joins un programme avec en même temps sell et buy

    Code
    //+------------------------------------------------------------------+ //| MODULO VERSION 4 LONG SHORT.mq4.mq4 | //| QPG | //| https://www.mql5.com | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| PARAMETRES EURUSD 1 MN | //+------------------------------------------------------------------+ int MagicNumber=20181005; //magic extern string lo="lotsize factor 2000 USD=45->90.... 50000 USD=210->410"; extern double LotFactorLONG=40 ; // extern double LotFactorSHORT = 110; //lotsize factor extern string fr="from 0.04...to 0.09 "; extern double MultiplierLONG = 0.1; // extern double MultiplierSHORT = 0.8; //from 0.04...to 0.09 extern string ls="0 = Long & 1 = Short "; extern int long_courtLONG=1; // 0 = Long & 1 = Court extern int long_courtSHORT=0; // 0 = Long & 1 = Court extern string ga="gain "; extern int gainLONG=180; // no comment ;) extern int gainSHORT=20; // no comment ;) extern string ec=" Ecart : 150, 1000, ou 1500 selon les paires...don't touch 110 --> 170 "; input int ecartLONG=80;// Ecart : 150, 1000, ou 1500 selon les paires...don't touch 110 --> 170 input int ecartSHORT=50;// Ecart : 150, 1000, ou 1500 selon les paires 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; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; if(IsNewCandle()) { Lot_Volume(); //calc lotsize return(0); } //MODIF*********** if (!IsTradeContextBusy() && IsTradeAllowed()) if(c==0){if(OrderSend(Symbol(), OP_BUY, SizeLotLONG, Ask, 0, 0, 0, "Ordre 2 !"))c=1;} if(c==0){if(OrderSend(Symbol(), OP_BUY, SizeLotSHORT, Ask, 0, 0, 0, "Ordre 2 !"))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) if (!IsTradeContextBusy() && IsTradeAllowed()) { int ticket5= OrderSend(Symbol(), OP_SELLSTOP, LotSizeLONG, Bid-ecartLONG*pips, 0, 0, 0, "Ordre 2 !"); if (!IsTradeContextBusy() && IsTradeAllowed()) if(long_courtSHORT==1) { int ticket6= OrderSend(Symbol(), OP_SELLSTOP, LotSizeSHORT, Bid-ecartSHORT*pips, 0, 0, 0, "Ordre 2 !"); 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(long_courtLONG==0) if (!IsTradeContextBusy() && IsTradeAllowed()) { int ticket1= OrderSend(Symbol(), OP_BUYSTOP, LotSizeLONG, Ask+ecartLONG*pips, 0, 0, 0, "Ordre 2 !"); if(long_courtSHORT==0) if (!IsTradeContextBusy() && IsTradeAllowed()) { int ticket2= OrderSend(Symbol(), OP_BUYSTOP, LotSizeSHORT, Ask+ecartSHORT*pips, 0, 0, 0, "Ordre 2 !"); 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 (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 ticket3=OrderSend(Symbol(), OP_BUY, SizeLotLONG, Ask, 0, 0, 0, "Ordre 2 !"); int ticket4=OrderSend(Symbol(), OP_BUY, SizeLotSHORT, Ask, 0, 0, 0, "Ordre 2 !"); // //--- place market order to buy 1 lot 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"); //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); } //+------------------------------------------------------------------+ //
Page 2