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

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

    Version 2
    Version Short avec amelioration de la performance….merci de votre participation pour l'améliorer encore !

    Code
    //+------------------------------------------------------------------+ //| MODULO LOTS AUTOAJUSTES | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| SHORT //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| PARAMETRES EURUSD 1 MN | //+------------------------------------------------------------------+ int MagicNumber=20180810; //magic double LotSize; //lotsize double SizeLot; extern string mm="Maximum Drawdown "; extern double LotFactor = 43; //lotsize factor extern double Multiplier = 0.09; //from 0.04...to 0.09 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, SizeLot, 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, SizeLot, 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 ; SizeLot=LotSize*Multiplier; return(LotSize); } //+------------------------------------------------------------------+
    Modifié le 2018-10-04 14:53:33 par lefeuvr3
    lefeuvr3 a joint une image
    modulo-lots-autoajustes-tp-st-11021
  • Lebenet

    Salut.
    Je suis en train de coder les différentes versions (cela prend un peu de temps) en LUA afin de valider les algos que tu proposes.
    Je me posais une question : Joues-tu en réel certains des algos ?
    Modifié le 2018-10-05 08:43:07 par Lebenet
  • lefeuvr3

    Je jouerai en reel au mois de décembre une fois mes meilleurs algos finalisés….modulo sera dans le lot….il tourne en live sur la plateforme d'un ami.
    Legere amelioration des volumes dans cette version 3 qui privilégie la hausse
    Code
    //+------------------------------------------------------------------+ //| MODULO VERSION 3 LONG.mq4 | //| QPG | //| https://www.mql5.com | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| MODULO LOTS AUTOAJUSTES | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| LONG //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| PARAMETRES EURUSD 1 MN | //+------------------------------------------------------------------+ int MagicNumber=20180810; //magic double LotSize; //lotsize double SizeLot; extern string mm="Maximum Drawdown "; extern double LotFactor=85 ; //lotsize factor 2000 USD=45->90 50000 USD=210->410 extern double Multiplier = 0.02; //from 0.04...to 0.09 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=0; // 0 = Long & 1 = Court extern int gain=30; // no comment ;) int hour=23; input int ecart=120;// Ecart : 150, 1000, ou 1500 selon les paires...don't touch 110 --> 170 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, SizeLot, 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, SizeLot, 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 ; SizeLot=LotSize*Multiplier; return(LotSize); return(SizeLot); } //+------------------------------------------------------------------+
    lefeuvr3 a joint une image
    modulo-lots-autoajustes-tp-st-11023
  • lefeuvr3

    Il ressort de toutes ces versions que c'est la versiion 2 la meilleur pour le moment ….merci de l'améliorer
  • AliX — en réponse à lefeuvr3 dans son message #112251

    Coucou, je ne sais pas si c'est très approprié mais on ne sait jamais si personne ne peut t'apporter d'aide je te mets quand même le lien d'un sujet qui m'a interpellé et qui pourra peut-être t'aider ^^

    https://www.forexagone.com/forum/expert-advisors-robots/propose-aide-pour-developper-un-ea-en-mql5-sous-conditions-20715#112241
  • lefeuvr3

    Merci beaucoup Alix pour ton intervention mais pour le moment je reste en mql4....je verrai peut être plus tard pour le mql5
    Merci encore et bonne soirée
    Gerard
  • lefeuvr3

    J'ai observe que les paramètres variaient en fonction du montant sur le compte ….je vais essaye de mettre en place une formule mathématique exponentielle pour faire un auto ajustement
  • lefeuvr3

    Voici donc la version 5 avec auto ajustement des paramètres en fonction du montant sur le compte.( variations exponentielles allant crescendo ou decrescendo)
    Le back test doit être refait car celui ci a été un peu rapidement réalisé.
    Merci de corriger les erreurs ,si vous en voyez, car je ne suis ni mathématicien ,ni programmeur….juste un débutant .

    Code
    //+------------------------------------------------------------------+ //| MODULO version.5 //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| VARIATION OF PARAMETERS IN RELATION TO ACCOUNT //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| PARAMETERS EURUSD 1 MN | //+------------------------------------------------------------------+ int MagicNumber=20180810; //magic extern string ls="Lot Size "; double LotSize; //lotsize double SizeLot; double LotFactor;//=43; //lotsize factor extern double a=0.6; extern double b=1.9; extern string mm="Multiplier "; double Multiplier; //= 0.09; //from 0.04...to 0.09 extern double f=1.6; extern double g=0.4; double pips = 0.00001; //leave as default for 5 digit brokers int stopOK = 0; // Not modified int sendOK = 0; // Not modified int long_court=1; // 0 = Long & 1 = Short extern string ga="Gain "; int gain;//=25;// no comment ;) extern double d=0.2; extern double e=1.9; extern string ti="Time "; int hour=23; extern string ec="Ecart "; input int ecart=120;// 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, SizeLot, 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; } } gain=(AccountBalance())/((AccountBalance())*(0.01*(MathPow(d,e)))); 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, SizeLot, 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() { LotFactor=(AccountBalance())/((AccountBalance())*(0.01*(MathPow(a,b)))); LotSize=AccountBalance() * 0.01 /LotFactor ; Multiplier=(AccountBalance())/((AccountBalance())*(1*(MathPow(f,g)))); SizeLot=LotSize*Multiplier; return(LotSize); return(SizeLot); } //+------------------------------------------------------------------+
    Modifié le 2018-10-08 16:01:58 par lefeuvr3
    lefeuvr3 a joint une image
    modulo-lots-autoajustes-tp-st-11025
  • alain33

    Bonjour, je viens de juste de voir votre préparation pour modulo lots autoajustes tp st....
    Je n'ai n'y connais rien en programmation, alors comment pourrais-je me rendre utile, test sur petit compte réel par exemple enfin dit-moi
    Super votre boulot et je vous souhaite une belle réalisation pour la suite

    Bonne journée
  • lefeuvr3

    Bonjour Alain
    Merci pour ton post sympa.
    Un test sur un petit compte en réel pourrait être intéressant .
    Il faudrait que tu me dises quel montant tu serais prêt a risqué afin que je te propose la version la plus adaptée a ce montant .
    Des que le compte aura doublé ,il faudra retirer les gains pour continuer…...pour limiter les risques .
  • lefeuvr3

    Il apparait que MODULO présente de temps en temps des périodes de surchauffe ….je vais tenté de reduire ces périodes en proposant une petite modification du programme
  • lefeuvr3

    MODULO V2 BOOSTER avec ADX+RSI+VOLUMES
    Code
    //+------------------------------------------------------------------+ //| MODULO V2 BOOSTER.mq4 | //| QPG | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "QPG" #property link "https://www.mql5.com" #property version "1.00" //+------------------------------------------------------------------+ extern int adxperiod= 16; extern int adxthreshold=24; extern int rsiperiod=14; extern int rsilower =34; extern int rsiupper =74; int MagicNumber=20181121; //magic double LotSize; //lotsize double SizeLot; extern string mm="Maximum Drawdown "; extern double LotFactor = 90; //lotsize factor extern double Multiplier = 0.7; //from 0.06...to 0.31 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=130; // no comment ;) int hour=23; input int ecart=14;// Ecart : 150, 1000, ou 1500 selon les paires /* A controler LotFactor lotsize factor 2000 USD=43 50000 USD=210->410 */ int c=0; //+------------------------------------------------------------------+ //| 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 ; 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, SizeLot, 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 && booster ) if (!IsTradeContextBusy() && IsTradeAllowed()) { 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 && booster ) if (!IsTradeContextBusy() && IsTradeAllowed()) { 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*********** if (!IsTradeContextBusy() && IsTradeAllowed()) int ticket2=OrderSend(Symbol(), OP_BUY, SizeLot, 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 ; SizeLot=LotSize*Multiplier; return(LotSize); } //+------------------------------------------------------------------+
    lefeuvr3 a joint une image
    modulo-lots-autoajustes-tp-st-11057