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

RENGOU LOT SCALP V2

  • lefeuvr3

    nouvelle version du Rengou

    Code
    //+------------------------------------------------------------------+ //| RENGOU LOTSCALP V2.mq4 | //| Copyright 2019, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2019, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" //#property strict //+------------------------------------------------------------------+ extern int MagicNumber=25102019; double lot; extern double StopLoss=120; double TakeProfit=20; int TrailingStop=20; extern int Slippage=3; double point = MarketInfo(Symbol(), MODE_POINT); int spread = MarketInfo(Symbol(), MODE_SPREAD); extern int size = 0; extern double LotFactor =40; //lotsize factor extern double LotFactor2 =40; //lotsize factor extern int ecartask=14; extern int ecartbid=2; int Amount = 250; int LockDown = 310; int Start_Hour = 0; int End_Hour = 0; extern string Name_EA = " RENGOU-LOTSCALP V2"; bool TrailingStop_ = true; string tp="TP IN MONEY"; bool Tp_in_Money = true; extern double TP_in_money = 1;//agir sur ce levier extern int volume1=1; extern int volume0=0; extern int adxperiod= 17; extern int adxthreshold=24; extern int rsiperiod=14; extern int rsilower =30; extern int rsiupper =70; double pt; int ras; double TP=0,SL=0,TR; //+------------------------------------------------------------------+ //| Hidden StopLoss Calculations | //+------------------------------------------------------------------+ void StpLoss() { double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; TP=TakeProfit*MyPoint; SL=StopLoss*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 Stop | //+------------------------------------------------------------------+ void trail() { for(int i=0; i<OrdersTotal(); i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) if(OrderSymbol()==Symbol()) { if(OrderType()==OP_BUY) { if(Bid - OrderOpenPrice() > TrailingStop * MarketInfo(OrderSymbol(),MODE_POINT)) { if(OrderStopLoss() < Bid - TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT)) { bool modify1=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MarketInfo(OrderSymbol(),MODE_POINT),OrderTakeProfit(),Red); } } } else if(OrderType()==OP_SELL) { if(OrderOpenPrice()-Ask>TrailingStop*MarketInfo(OrderSymbol(),MODE_POINT)) { if((OrderStopLoss()>Ask+TrailingStop*MarketInfo(OrderSymbol(),MODE_POINT)) || (OrderStopLoss()==0)) { bool modify2=OrderModify(OrderTicket(),OrderOpenPrice(), Ask+TrailingStop*MarketInfo(OrderSymbol(),MODE_POINT),OrderTakeProfit(),Red); } } } } } } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ // expert start function //+------------------------------------------------------------------+ int start() { 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(TrailingStop_)dtrailing(); if(Tp_in_Money && TP_in_money<=money()) closeall(); double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; double TheStopLoss=0; double TheTakeProfit=0; if( TotalOrdersCount()==0 ) { int result=0; //+------------------------------------------------------------------+ // Here is your open buy rule //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ // Here is the beginning of your open buy rule strategy //+------------------------------------------------------------------+ if((Bid>iOpen(Symbol(),0,0))) //+------------------------------------------------------------------+ // Here is the end of your buy rule strategy //+------------------------------------------------------------------+ { result= OrderSend(Symbol(),OP_BUYSTOP, (AccountEquity() * 0.01 /LotFactor2),Ask+ecartask*Point,5,(Ask+ecartask*Point)-StopLoss*Point,(Ask+ecartask*Point)+TakeProfit*Point,"RENGOU-LOTSCALP V2",MagicNumber,0,clrBlue); if(result>0) { TheStopLoss=0; TheTakeProfit=0; if(TakeProfit>0) TheTakeProfit=Ask+TakeProfit*MyPoint; if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint; if(OrderSelect(result,SELECT_BY_TICKET)) bool modif1=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } //+------------------------------------------------------------------+ // Here is your open sell rule //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ // Here is the beginning of your open sell rule strategy //+------------------------------------------------------------------+ if((Bid<iOpen(Symbol(),0,0))) //+------------------------------------------------------------------+ // Here is the end of your sell rule strategy //+------------------------------------------------------------------+ //&&(!IsTradeContextBusy() && IsTradeAllowed()) { result= OrderSend(Symbol(),OP_SELLSTOP, (AccountEquity() * 0.01 /LotFactor2),Bid-ecartbid*Point,5,(Bid-ecartbid*Point)+StopLoss*Point,(Bid-ecartbid*Point)-TakeProfit*Point,"RENGOU-LOTSCALP V2",MagicNumber,0,clrBlue); if(result>0) { TheStopLoss=0; TheTakeProfit=0; if(TakeProfit>0) TheTakeProfit=Bid-TakeProfit*MyPoint; if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint; if(OrderSelect(result,SELECT_BY_TICKET)) bool modif2=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } } for(int cnt=0;cnt<OrdersTotal();cnt++) { if(OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) if(OrderType()<=OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber ) { if(OrderType()==OP_BUY) { if(TrailingStop>0) { if(Bid-OrderOpenPrice()>MyPoint*TrailingStop) { if(OrderStopLoss()<Bid-MyPoint*TrailingStop) { if(OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green)) return(0); } } } } else { if(TrailingStop>0) { if((OrderOpenPrice()-Ask)>(MyPoint*TrailingStop)) { if((OrderStopLoss()>(Ask+MyPoint*TrailingStop)) || (OrderStopLoss()==0)) { if(OrderModify(OrderTicket(),OrderOpenPrice(),Ask+MyPoint*TrailingStop,OrderTakeProfit(),0,Red)) return(0); } } } } } } return(0); } int TotalOrdersCount() { int result=0; for(int i=0;i<OrdersTotal();i++) { if (OrderSelect(i,SELECT_BY_POS ,MODE_TRADES)) if (OrderMagicNumber()==MagicNumber) result++; } return (result); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ 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()!=MagicNumber || 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()!=MagicNumber) 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()!=MagicNumber) 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()!=MagicNumber) 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); } //--------------------------------------------------------------------------- int CheckForClose() { if(getProfit()>=Amount)//{CloseAll();} if(LockDown>0) { for(int TradeNumber = OrdersTotal(); TradeNumber >= 0; TradeNumber--) { if (OrderSelect(TradeNumber, SELECT_BY_POS, MODE_TRADES)&&(LockDown>0)) { int Pos=OrderType(); if((Pos==OP_BUY)&&(Bid-OrderOpenPrice()>Point*LockDown)&&(OrderStopLoss() == 0)) {bool modif1=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+Point,OrderTakeProfit(),0,CLR_NONE);} if((Pos==OP_SELL)&&(OrderOpenPrice()-Ask>Point*LockDown)&&(OrderStopLoss() == 0)) {bool modif2=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-Point,OrderTakeProfit(),0,CLR_NONE);} } } } return(0); } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- double getProfit() { double Profit = 0; for (int TradeNumber = OrdersTotal(); TradeNumber >= 0; TradeNumber--) { if (OrderSelect(TradeNumber, SELECT_BY_POS, MODE_TRADES)) Profit = Profit + OrderProfit() + OrderSwap(); } return (Profit); } //+------------------------------------------------------------------+ //insuring its a new candle function //+------------------------------------------------------------------+ bool IsNewCandle() { static int BarsOnChart=0; if (Bars == BarsOnChart) return (false); BarsOnChart = Bars; return(true); }
    lefeuvr3 a joint une image
    rengou-lot-scalp-v2-11992
  • lefeuvr3

    Amélioration des performances....nouvelle version ,simplifiée et donc plus courte

    Code
    //+------------------------------------------------------------------+ //| RENGOU LOTSCALP VERSION 3.mq4 | //| Copyright 2019, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2019, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict //+------------------------------------------------------------------+ extern int MagicNumber=20001; extern int LotFactor =50; extern double StopLoss=0; extern double TakeProfit=45; extern int TrailingStop=8; extern int Slippage=3; double lot; double point = MarketInfo(Symbol(), MODE_POINT); int spread =(int)MarketInfo(Symbol(), MODE_SPREAD); int size = 0; int shiftOpenBuy =0; int shiftCloseBuy =1; int shiftOpenSell =0; int shiftCloseSell =1; int Start_Hour = 0; int End_Hour = 0; extern string Name_EA = " RENGOU-LOTSCALP VERSION 3"; extern int t1buy=16; extern int t2buy=12; extern int t1sell=3; extern int t2sell=0; extern int delta_L=2; extern int delta_S=7; extern int volume1=1; extern int volume0=0; extern int adxperiod= 23; extern int adxthreshold=14; extern int rsiperiod=14; extern int rsilower =30; extern int rsiupper =70; //+------------------------------------------------------------------+ // expert start function //+------------------------------------------------------------------+ int start() { double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; 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 ; double TheStopLoss=0; double TheTakeProfit=0; if( TotalOrdersCount()==0 ) { int result=0; //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ // Here is your open buy rule//Ici votre strategie d'achat if ((iOpen(Symbol(),0, shiftOpenBuy)> iClose(Symbol(),0, shiftCloseBuy)+ (size + spread)*point) &&((((Open[t2buy]-Open[t1buy])>delta_L*Point) &&(booster))) //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ ) { result=OrderSend(Symbol(),OP_BUY, (AccountEquity() * 0.01 /LotFactor),Ask,Slippage,0,0,"Billy Tom EA",MagicNumber,0,Blue); if(result>0) { TheStopLoss=0; TheTakeProfit=0; if(TakeProfit>0) TheTakeProfit=Ask+TakeProfit*MyPoint; if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint; if( OrderSelect(result,SELECT_BY_TICKET)) bool modif1= OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ // Here is your open Sell rule//Ici votre strategie de vente if( ( iOpen(Symbol(),0, shiftOpenSell)< iClose(Symbol(),0, shiftCloseSell)- (size + spread)*point) &&((((Open[t1sell]-Open[t2sell])>delta_S*Point) &&(booster))) //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ ) { result=OrderSend(Symbol(),OP_SELL, (AccountEquity() * 0.01 /LotFactor),Bid,Slippage,0,0,"Billy Tom EA",MagicNumber,0,Red); if(result>0) { TheStopLoss=0; TheTakeProfit=0; if(TakeProfit>0) TheTakeProfit=Bid-TakeProfit*MyPoint; if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint; if( OrderSelect(result,SELECT_BY_TICKET)) bool modif2= OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } } for(int cnt=0;cnt<OrdersTotal();cnt++) { if( OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) if(OrderType()<=OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber ) { if(OrderType()==OP_BUY) { if(TrailingStop>0) { if(Bid-OrderOpenPrice()>MyPoint*TrailingStop) { if(OrderStopLoss()<Bid-MyPoint*TrailingStop) { bool modif3= OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green); return(0); } } } } else { if(TrailingStop>0) { if((OrderOpenPrice()-Ask)>(MyPoint*TrailingStop)) { if((OrderStopLoss()>(Ask+MyPoint*TrailingStop)) || (OrderStopLoss()==0)) { bool modif4= OrderModify(OrderTicket(),OrderOpenPrice(),Ask+MyPoint*TrailingStop,OrderTakeProfit(),0,Red); return(0); } } } } } } return(0); } int TotalOrdersCount() { int result=0; for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS ,MODE_TRADES)) if (OrderMagicNumber()==MagicNumber) result++; } return (result); }
    Modifié le 2020-02-14 17:46:44 par lefeuvr3 : rajout dans le post
    lefeuvr3 a joint une image
    rengou-lot-scalp-v2-12005
  • Fred6336

    Comment avez-vous appris le codage ?
    Je cherche à créer un Robot MT5 mais je dois être trop exigeant haha
  • lefeuvr3

    Cela fait longtemps maintenant mais je crois avoir commencer avec un "Builder" pour MT4 [https://www.forexeadvisor.com/]
    .
    .
    Je pense que sur le net on doit trouver des builder pour MT5 [https://www.google.com/search?q=expert+advisor+builder+mt5&rlz=1C1PRFI_enFR833FR833&oq=builder+mt5&aqs=chrome.1.69i57j0l5j69i60l2.11124j0j4&sourceid=chrome&ie=UTF-8]