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

STEGOSAURUS

  • lefeuvr3

    EURUSD 4 HEURES

    Code
    //+------------------------------------------------------------------+ //| STEGOSAURUS.mq4 | //| EURUSD 4 HEURES QPG | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "QPG" #property link "https://www.mql5.com" #property version "1.00" //#property strict //+------------------------------------------------------------------+ extern string Name_EA = "STEGOSAURUS"; extern bool Trade_buy = true; extern bool Trade_sell = true; extern int Start_Hour = 1; extern int End_Hour = 23; extern bool Tp_in_Money = true; extern double TP_in_money = 3; extern int TP = 20; extern int SL = 110; extern int Max_order = 10; //extern double Lots = 0.12; extern string mm="MONEY MANAGEMENT"; extern bool TrailingStop_ = true; extern int TrailingStop = 20; extern int Magic = 76; extern int Period_1 = 2; extern int Period_2 = 44; double LotSize; //lotsize extern double LotFactor = 50; //lotsize factor extern int StopLoss=5000; //stop loss extern int TakeProfit=70; //take profit extern int MagicNumber=201808009; //magic double pips = 0.00001; //leave as default for 5 digit brokers extern int adxthreshold = 27; //adx threshold - must be greater than this to trade extern int adxperiod = 14; //adx period extern int rsiperiod = 14; //rsi period extern int rsiupper = 65; //rsi upper bound, wont buy above this value extern int rsilower = 35; //rsi lower bound, wont sell below this value //---- extern int a=1; extern int b=0; extern int c=2; extern int d=4; extern int e=2; extern int f=3; double lot; double slb,tpb,sls,tps,pt; int ras,wt,wk,ticketb,tickets; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- if(Digits==3 || Digits==5) pt=10*Point; else pt=Point; //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { if(TrailingStop_)dtrailing(); if(Tp_in_Money && TP_in_money<=money()) closeall(); //---- int signal; // if (High[a]>High[b]&&High[b]>High[e]&&High[c]>High[f]&&Open[a]>Open[b]&&Open[b]>Open[c]&&Open[c]>Open[d]) signal=1;// open buy if( High[a]<High[b]&&High[b]<High[e]&&High[c]<High[f]&&Open[a]<Open[b]&&Open[b]<Open[c]&&Open[c]<Open[d]) signal=2;// open sell if(Hour_trade()==1) { if(SL==0)slb=0;else slb=Ask-SL*pt; if(SL==0)sls=0;else sls=Bid+SL*pt; if(TP==0)tpb=0;else tpb=Ask+TP*pt; if(TP==0)tps=0;else tps=Bid-TP*pt; if(totalorder(0)<Max_order && CheckMoneyForTrade(Symbol(), NR(Lot_Volume()), OP_BUY)==True && Trade_buy && signal==1 && wt!=Time[0]) { ticketb=OrderSend(Symbol(),OP_BUY,NR(Lot_Volume()),Ask,3,slb,tpb,Name_EA,Magic,0,Blue); if(ticketb>0) wt=Time[0]; } if(totalorder(1)<Max_order && CheckMoneyForTrade(Symbol(), NR(Lot_Volume()), OP_SELL)==True && Trade_sell && signal==2 && wk!=Time[0]) { tickets=OrderSend(Symbol(),OP_SELL,NR(Lot_Volume()),Bid,3,sls,tps,Name_EA,Magic,0,Red); if(tickets>0) wk=Time[0]; } } //---- return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int Hour_trade() { bool trade=false; if(Start_Hour>End_Hour) { if(Hour()>=Start_Hour || Hour()<End_Hour) trade=true; } else if(Hour()>=Start_Hour && Hour()<End_Hour) trade=true; return (trade); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int totalorder(int tipe) { int total=0; for(int i=0; i<OrdersTotal(); i++) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic || OrderType()!=tipe) continue; total++; } return(total); } //+------------------------------------------------------------------+ //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); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void dtrailing() { int i,r;double tpn; for(i=0; i<OrdersTotal(); i++) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue; tpn=OrderTakeProfit(); if(OrderType()==OP_BUY) { if(Bid-OrderOpenPrice()>pt*TrailingStop) { if((OrderStopLoss()<Bid-pt*TrailingStop) || (OrderStopLoss()==0)) { if(tpn) r=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-pt*TrailingStop,OrderTakeProfit(),0,Green); } } } if(OrderType()==OP_SELL) { if((OrderOpenPrice()-Ask)>(pt*TrailingStop)) { if(OrderStopLoss()>(Ask+pt*TrailingStop) || (OrderStopLoss()==0)) { if(tpn) r=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+pt*TrailingStop,OrderTakeProfit(),0,Red); } } } } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void closeall() { for(int i=OrdersTotal()-1; i>=0; i--) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue; if(OrderType()>1) ras=OrderDelete(OrderTicket()); else { if(OrderType()==0) ras=OrderClose(OrderTicket(),OrderLots(),Bid,3,CLR_NONE); else ras=OrderClose(OrderTicket(),OrderLots(),Ask,3,CLR_NONE); } } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double money() { double dp=0; int i; for(i=0; i<OrdersTotal(); i++) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue; dp+=OrderProfit(); } return(dp); } //+------------------------------------------------------------------+ bool CheckMoneyForTrade(string symb,double lots,int type) { double free_margin=AccountFreeMarginCheck(symb,type, lots); //-- if there is not enough money if(free_margin<0) { string oper=(type==OP_BUY)? "Buy":"Sell"; //fPrint("Not enough money for ", oper," ",lots, " ", symb, " Error code=",GetLastError()); return(false); } //--- checking successful return(true); }
    Modifié le 2018-09-24 18:03:42 par lefeuvr3
    lefeuvr3 a joint une image
    stegosaurus-11015
  • lefeuvr3

    Modifications de l'EA pour le rendre plus performant avec moins de trades….merci de l'améliorer !
    Code
    //+------------------------------------------------------------------+ //| STEGOSAURUS.mq4 | //| EURUSD 4 HEURES QPG | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "QPG" #property link "https://www.mql5.com" #property version "1.00" //#property strict //+------------------------------------------------------------------+ extern string Name_EA = "STEGOSAURUS"; extern bool Trade_buy = true; extern bool Trade_sell = true; extern int Start_Hour = 1; extern int End_Hour = 23; extern bool Tp_in_Money = true; extern double TP_in_money = 18; extern int TP = 20; extern int SL = 90; extern int Max_order = 3; extern bool TrailingStop_ = true; extern int TrailingStop = 20; int Magic = 76; double LotSize; extern double LotFactor = 90; //lotsize factor extern int MagicNumber=201808009; //magic double pips = 0.00001; //leave as default for 5 digit brokers extern int adxperiod= 7; extern int adxthreshold=24; extern int rsiperiod=18; extern int rsilower =30; extern int rsiupper =70; extern int volume1=1; extern int volume0=0; extern string bu = "BUY"; extern int aB=2; extern int bB=1; extern int cB=5; extern int dB=0; extern int eB=0; extern int fB=4; extern string se = "SELL"; extern int aS=1; extern int bS=0; extern int cS=2; extern int dS=4; extern int eS=2; extern int fS=3; double lot; double slb,tpb,sls,tps,pt; int ras,wt,wk,ticketb,tickets; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- if(Digits==3 || Digits==5) pt=10*Point; else pt=Point; //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { if(TrailingStop_)dtrailing(); if(Tp_in_Money && TP_in_money<=money()) closeall(); //---- int signal; double booster = Volume[volume1]> Volume[volume0] &&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 ; // if ((High[aB]>High[bB]&&High[bB]>High[eB]&&High[cB]>High[fB]&&Open[aB]>Open[bB]&&Open[bB]>Open[cB]&&Open[cB]>Open[dB])&&(booster)) signal=1;// open buy if(( Low[aS]<Low[bS]&&Low[bS]<Low[eS]&&Low[cS]<Low[fS]&&Close[aS]<Close[bS]&&Close[bS]<Close[cS]&&Close[cS]<Close[dS])&& (booster)) signal=2;// open sell if(Hour_trade()==1) { if(SL==0)slb=0;else slb=Ask-SL*pt; if(SL==0)sls=0;else sls=Bid+SL*pt; if(TP==0)tpb=0;else tpb=Ask+TP*pt; if(TP==0)tps=0;else tps=Bid-TP*pt; if(totalorder(0)<Max_order && CheckMoneyForTrade(Symbol(), NR(Lot_Volume()), OP_BUY)==True && Trade_buy && signal==1 && wt!=Time[0]) { ticketb=OrderSend(Symbol(),OP_BUY,NR(Lot_Volume()),Ask,3,slb,tpb,Name_EA,Magic,0,Blue); if(ticketb>0) wt=Time[0]; } if(totalorder(1)<Max_order && CheckMoneyForTrade(Symbol(), NR(Lot_Volume()), OP_SELL)==True && Trade_sell && signal==2 && wk!=Time[0]) { tickets=OrderSend(Symbol(),OP_SELL,NR(Lot_Volume()),Bid,3,sls,tps,Name_EA,Magic,0,Red); if(tickets>0) wk=Time[0]; } } //---- return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int Hour_trade() { bool trade=false; if(Start_Hour>End_Hour) { if(Hour()>=Start_Hour || Hour()<End_Hour) trade=true; } else if(Hour()>=Start_Hour && Hour()<End_Hour) trade=true; return (trade); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int totalorder(int tipe) { int total=0; for(int i=0; i<OrdersTotal(); i++) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic || OrderType()!=tipe) continue; total++; } return(total); } //+------------------------------------------------------------------+ //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); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void dtrailing() { int i,r;double tpn; for(i=0; i<OrdersTotal(); i++) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue; tpn=OrderTakeProfit(); if(OrderType()==OP_BUY) { if(Bid-OrderOpenPrice()>pt*TrailingStop) { if((OrderStopLoss()<Bid-pt*TrailingStop) || (OrderStopLoss()==0)) { if(tpn) r=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-pt*TrailingStop,OrderTakeProfit(),0,Green); } } } if(OrderType()==OP_SELL) { if((OrderOpenPrice()-Ask)>(pt*TrailingStop)) { if(OrderStopLoss()>(Ask+pt*TrailingStop) || (OrderStopLoss()==0)) { if(tpn) r=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+pt*TrailingStop,OrderTakeProfit(),0,Red); } } } } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void closeall() { for(int i=OrdersTotal()-1; i>=0; i--) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue; if(OrderType()>1) ras=OrderDelete(OrderTicket()); else { if(OrderType()==0) ras=OrderClose(OrderTicket(),OrderLots(),Bid,3,CLR_NONE); else ras=OrderClose(OrderTicket(),OrderLots(),Ask,3,CLR_NONE); } } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double money() { double dp=0; int i; for(i=0; i<OrdersTotal(); i++) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue; dp+=OrderProfit(); } return(dp); } //+------------------------------------------------------------------+ bool CheckMoneyForTrade(string symb,double lots,int type) { double free_margin=AccountFreeMarginCheck(symb,type, lots); //-- if there is not enough money if(free_margin<0) { string oper=(type==OP_BUY)? "Buy":"Sell"; //fPrint("Not enough money for ", oper," ",lots, " ", symb, " Error code=",GetLastError()); return(false); } //--- checking successful return(true); }
    lefeuvr3 a joint une image
    stegosaurus-11045
  • lefeuvr3

    Je viens de reperer une petite erreur
    Le dernier programme posté n'est pas en 4 heures mais en Daily
    Modifié le 2018-11-03 08:14:53 par lefeuvr3
  • lefeuvr3

    Voici le nouveau backtest en UT 4 HEURES
    lefeuvr3 a joint une image
    stegosaurus-11048
  • vivilamalice — en réponse à lefeuvr3 dans son message #112411

    Bonjour!
    Pourquoi la qualité du modelage est sur n/a est pas à 90.00%? Data's mal remontées?
    Sinon les stats sont bonnes. Mais il ne peut rien contre mon armée divine!!!! Lol
  • lefeuvr3

    Je ne sais que te dire
    C'est sur que ton Armée Divine est impressionnante ….il va falloir voir comment elle se comporte avec le temps et si elle tient la distance sans modification de parametres.
    Voici mes dernières stats concernant mes EA
    Code
    EXPERTS CLASSEMENT EURUSD SUR UNE PERIODE DE 6 MOIS...Les meilleurs sur 96 robots elaborés Robot… mise … gain...drawdown .. .nombre de trades MARCHENT BIEN 1. GAP 15MN…. 1000368/10.4%/23trades 2. GAP 1H…. 1000245/10.6%/15trades 3. GAP 30MN…. 1000306/10.5%/18trades 4. GAP 4H…. 1000155/10.6%/8trades 5. GAP 5MN ….1000405/10.1%/25trades 6. GAPOUNET 1 MN ….1000624/9.91%/79trades 7. MODULO 1 MN version 1…2_3….Plonge en dessous de 750 USD de capital….1000856/42%/68trades 8. MODULO 1 MN version 2….10001250/59%/58trades 9. MODULO 1 MN version 4…..1000983/36.76%/31trades 10. PIEDS SUR TERRE TETE DANS LES ETOILES VERSION 2 DAILY…1000473/15.33%/92trades. 11. QPG GAP 1MN…. 1 MN …..1000 345/6.23%/75trades 12. EA HEDGE AVERAGE EA DAILY… VERSION 2 sans AMM ..1000151/4.30%/68 trades 13. LEFEUVRE CUSTOMIZED …..GAPS MTF 1 MN …..1000530/10.68%/114trades 14. MTF RSI SAR 1MN …1000468/27.53%/23 trades TRES bon outil Bonne matrice…le nombre de trades augmente ainsi que le gain avec la hauteur du capital de depart…optimal a partir de 2000 SOUS SURVEILLANCE 15. QPG LOTSCALP.MQ4 V3 EURUSD 1 H…..10002007/10.86%/49trades.. 16. QPG MM CLOSE OPEN MTF ADX RSI.ex4 version 2 avec AMM…1MN…..1000 1099/13.22%/168trades 17. STEGOSAURUS DAILY…..1000 348/4%/19 trades 18. STREGOSAURUS 4 H…..1000 348/4%/19 trades

    Je suis actuellement dans la phase où je dois m'assurer que mes robots mis a plusieurs sur la plateforme ne tradent pas en même temps pour ne pas être en flux tendu.
    Passe un très bon week end