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

    J'ai repris ce matin le MODULO cf https://miniurl.be/r-1p1s
    Bien que je ne comprenne absolument rien à sa strategie ,j'ai essayé d'apporter quelques modifications interressantes.
    Merci d'apporter a votre tour votre pierre pour bonifier cet EA originalement bizarre :)

    Le Trailing stop ne sert a rien ….je l'ai retiré

    Code
    //+------------------------------------------------------------------+ //| MODULO LOTS AUTOAJUSTES TP ST | | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| PARTAMETRES EURUSD 1 MN | | //+------------------------------------------------------------------+ extern int MagicNumber=20180810; //magic double LotSize; //lotsize extern double LotFactor = 9.5; //lotsize factor extern int StopLoss=5475; //stop loss extern int TakeProfit=570; //take profit double pips = 0.00001; //leave as default for 5 digit brokers int stopOK = 0; // ne pas modifier int sendOK = 0; // ne pas modifier int long_court=1; // 0 = Long & 1 = Court int gain=1; // no comment ;) int c=0; //+------------------------------------------------------------------+ //| 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(c==0){bool modify1=OrderSend(Symbol(),OP_BUY,LotSize,Ask,3,Ask-(StopLoss*pips),Ask+(TakeProfit*pips),NULL,MagicNumber,0,Green);;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_court==1) { bool modify2=OrderSend(Symbol(),OP_SELL,LotSize,Bid,3,Bid+(StopLoss*pips),Bid-(TakeProfit*pips),NULL,MagicNumber,0,Red); } if(long_court==0) { bool modify3=OrderSend(Symbol(),OP_BUY,LotSize,Ask,3,Ask-(StopLoss*pips),Ask+(TakeProfit*pips),NULL,MagicNumber,0,Green); } } 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 modify7= OrderDelete(OrderTicket()); } u -= 1; } } if (AccountEquity()>= AccountBalance()+ gain) { int w = OrdersTotal() - 1; while (w >= 0) { if(OrderSelect(w, SELECT_BY_POS)) { bool modify4=OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 2); bool modify5=OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 2); } w -= 1; } //MODIF*********** bool modify6=OrderSend(Symbol(),OP_BUY,LotSize,Ask,3,Ask-(StopLoss*pips),Ask+(TakeProfit*pips),NULL,MagicNumber,0,Green); //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() { double lot; 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()>=550) lot=0.24; if (AccountBalance()>=600) lot=0.26; if (AccountBalance()>=650) lot=0.28; if (AccountBalance()>=700) lot=0.3; if (AccountBalance()>=750) lot=0.32; if (AccountBalance()>=800) lot=0.34; if (AccountBalance()>=850) lot=0.36; if (AccountBalance()>=900) lot=0.38; if (AccountBalance()>=1000) lot=0.4; if (AccountBalance()>=1500) lot=0.6; if (AccountBalance()>=2000) lot=0.8; if (AccountBalance()>=2500) lot=1.0; if (AccountBalance()>=3000) lot=1.2; 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()>=7000) lot=2.8; if (AccountBalance()>=8000) lot=3.2; if (AccountBalance()>=9000) lot=3.6; if (AccountBalance()>=10000) lot=4.0; 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
    modulo-lots-autoajustes-tp-st-10930
  • lefeuvr3

    Modulo ...revu corrige optimisé !
    lefeuvr3 a joint une image
    modulo-lots-autoajustes-tp-st-10935
  • Lebenet

    Bonjour,

    Quelles corrections as-tu apportées ?
  • lefeuvr3

    Désolé mais comme j'ai fait plusieurs autres EA ces derniers temps,je ne sais plus :)
    D'ailleurs ,je l'ai encore modifie pour que le Broker ne puisse pas voir TP ...SL...etc
    J'ai essayé en vain de trouver une formule pour ne pas avoir a mettre les montants "Account" pour calculer automatiquement la taille des lots….du coup tout est a faire à la main a raison de 0.2 lots pour 500€ sur le compte.
    Si quelqu'un a la formule avec Math ( https://docs.mql4.com/math )...cela pourrait être interressant !
    Bonne soirée
    Gerard
    cf nouveau programme amelioré

    Code
    //+------------------------------------------------------------------+ //| MODULO LOTS AUTOAJUSTES TP ST | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| PARAMETRES EURUSD 1 MN | //+------------------------------------------------------------------+ int MagicNumber=20180810; //magic double LotSize; //lotsize extern string mm="Maximum Drawdown "; extern double LotFactor = 3.1; //lotsize factor double pips = 0.00001; //leave as default for 5 digit brokers int stopOK = 0; // ne pas modifier int sendOK = 0; // ne pas modifier int long_court=1; // 0 = Long & 1 = Court extern int gain=25; // no comment ;) int hour=23; input int ecart=13;// Ecart : 150, 1000, ou 1500 selon les paires int c=0; //+------------------------------------------------------------------+ //| 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(c==0){if(OrderSend(Symbol(), OP_BUY, 0.01, 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_court==1) { int ticket= OrderSend(Symbol(), OP_SELLSTOP, LotSize, Bid-ecart*pips, 0, 0, 0, "Ordre 2 !"); // if(ticket<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(long_court==0) { int ticket1= OrderSend(Symbol(), OP_BUYSTOP, LotSize, Ask+ecart*pips, 0, 0, 0, "Ordre 2 !"); if(ticket1<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()+ gain) { 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*********** int ticket2=OrderSend(Symbol(), OP_BUY, 0.01, Ask, 0, 0, 0, "Ordre 2 !"); // //--- place market order to buy 1 lot if(ticket<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() { double lot; 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()>=550) lot=0.24; if (AccountBalance()>=600) lot=0.26; if (AccountBalance()>=650) lot=0.28; if (AccountBalance()>=700) lot=0.3; if (AccountBalance()>=750) lot=0.32; if (AccountBalance()>=800) lot=0.34; if (AccountBalance()>=850) lot=0.36; if (AccountBalance()>=900) lot=0.38; if (AccountBalance()>=1000) lot=0.4; if (AccountBalance()>=1500) lot=0.6; if (AccountBalance()>=2000) lot=0.8; // if (AccountBalance()>=2250) lot=0.9; if (AccountBalance()>=2500) lot=1.0; if (AccountBalance()>=2750) lot=1.1; // if (AccountBalance()>=3000) lot=1.2; 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()>=7000) lot=2.8; if (AccountBalance()>=8000) lot=3.2; if (AccountBalance()>=9000) lot=3.6; 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

    oups ! :)
    Je viens de voir que ce n'est pas sur ce programme que j'ai ajouté les dissimulations pour le broker ….il faut que je le rajoute ….que je le compile que je le teste et je le mettrais ici en ligne , pour le partage avec ceux que cela interresse !
  • lefeuvr3

    re oups!
    pas de trailing stop ou autre ….on n' a rien a cacher en fait au broker
    Par contre au backtest qui on trouve dans le journal "OrderClose error138" et " "OrderClose error 4108"....ce qui n'empêche pas le Modulo" de fonctionner très bien !
    Mais ,il est sur que si quelqu'un pouvait corriger cela ...l'esthétique du programme en serait améliorée !...:)
  • lefeuvr3

    Simplification de Modulo sur le calcul de la taille optimisée des lots….merci de vos contributions pour l'ameliorer

    Code
    //+------------------------------------------------------------------+ //| MODULO LOTS AUTOAJUSTES TP ST | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| PARAMETRES EURUSD 1 MN | //+------------------------------------------------------------------+ int MagicNumber=20180810; //magic double LotSize; //lotsize extern string mm="Maximum Drawdown "; extern double LotFactor = 43; //lotsize factor double pips = 0.00001; //leave as default for 5 digit brokers int stopOK = 0; // ne pas modifier int sendOK = 0; // ne pas modifier int long_court=1; // 0 = Long & 1 = Court extern int gain=25; // no comment ;) int hour=23; input int ecart=13;// Ecart : 150, 1000, ou 1500 selon les paires int c=0; //+------------------------------------------------------------------+ //| 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(c==0){if(OrderSend(Symbol(), OP_BUY, 0.01, 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_court==1) { int ticket= OrderSend(Symbol(), OP_SELLSTOP, LotSize, Bid-ecart*pips, 0, 0, 0, "Ordre 2 !"); // if(ticket<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(long_court==0) { int ticket1= OrderSend(Symbol(), OP_BUYSTOP, LotSize, Ask+ecart*pips, 0, 0, 0, "Ordre 2 !"); if(ticket1<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()+ gain) { 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*********** int ticket2=OrderSend(Symbol(), OP_BUY, 0.01, Ask, 0, 0, 0, "Ordre 2 !"); // //--- place market order to buy 1 lot if(ticket<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() { LotSize=AccountBalance() * 0.01 /LotFactor ; return(LotSize); } //+------------------------------------------------------------------+
    Modifié le 2018-09-06 09:06:34 par lefeuvr3
  • lefeuvr3

    voici le dernier backtest avec le dernier programme de modulo
    lefeuvr3 a joint une image
    modulo-lots-autoajustes-tp-st-10960