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

MODULOSTOP VERSION .4....

  • lefeuvr3

    Avec le MODULOSTOP VERSION 3 [ https://www.forexagone.com/forum/expert-advisors-robots/modulostop-version-3-23168#116596 ] les gains étaient réalises sur les shorts....
    Avec le MODULOSTOP VERSION 4 ? au contraire ,les gains sont réalisés sur les longs...

    Code
    //+------------------------------------------------------------------+ //| MODULOSTOP V4 SLTS TP.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 //+------------------------------------------------------------------+ //| EURUSD 1 MN //+------------------------------------------------------------------+ #property copyright "QPG" #property link "https://www.mql5.com" #property version "1.00" extern string Name_EA = "MODULOSTOP-GG-V4"; int MagicNumber=24102019; //magic int stopOK = 0; // ne pas modifier int sendOK = 0; // ne pas modifier extern int long_court=1; // 0 = Long & 1 = Court extern double LotFactor = 50; //lotsize factor extern int ecart=50; // diminuer l'écart = + de gain, mais exige un capital plus important extern int Slippage =0; extern double gain=6; // no comment ;) double lot ; extern int stop =30; extern int adxperiod= 16; extern int adxthreshold=24; extern int rsiperiod=14; extern int rsilower =30; extern int rsiupper =70; extern int Takeprofit=45; extern int Stoploss=30; extern bool trail=true; extern double TrailingStop=30; double TP=0,SL=0,TR; //+------------------------------------------------------------------+ //| Hidden StopLoss Calculations | //+------------------------------------------------------------------+ void StopLoss() { double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; // TP=profit*MyPoint; SL=stop*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,clrGreenYellow); if(OrderType()==OP_SELL) bool OrdClL=OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,clrGreenYellow); } } } } //+------------------------------------------------------------------+ //| Trailing Stoploss après Breakeven | //+------------------------------------------------------------------+ void trail() { for (int i = OrdersTotal()-1; i >= 0; i --) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) if(OrderSymbol()==Symbol()) { if(OrderType()==OP_BUY) { if(Bid - OrderOpenPrice() > TrailingStop *10* MarketInfo(OrderSymbol(),MODE_POINT)) { if(((OrderStopLoss() < Bid - TrailingStop *10* MarketInfo(OrderSymbol(), MODE_POINT))&& ((Bid-OrderOpenPrice())>(Point*TrailingStop)))|| (OrderStopLoss()==0)) { bool modify1=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*10*MarketInfo(OrderSymbol(),MODE_POINT),OrderTakeProfit(),clrGreenYellow); } } } else if(OrderType()==OP_SELL) { if(OrderOpenPrice()-Ask>TrailingStop*10*MarketInfo(OrderSymbol(),MODE_POINT)) { if(((OrderStopLoss()>Ask+TrailingStop*10*MarketInfo(OrderSymbol(),MODE_POINT))&& ((OrderOpenPrice()-Ask)>(Point*TrailingStop)))|| (OrderStopLoss()==0)) { bool modify2=OrderModify(OrderTicket(),OrderOpenPrice(), Ask+TrailingStop*10*MarketInfo(OrderSymbol(),MODE_POINT),OrderTakeProfit(),clrGreenYellow); } } } } } } //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { if(trail) trail(); double booster = Volume[1]> Volume[0] &&iADX(Symbol(),0,adxperiod,PRICE_CLOSE,MODE_MAIN,0)> adxthreshold &&iRSI(Symbol(),0,rsiperiod,PRICE_CLOSE,0)>rsilower && iRSI(Symbol(),0,rsiperiod,PRICE_CLOSE,0)<rsiupper ; Comment(AccountEquity() - AccountBalance()); int type = OrderType(); int type2 = OrderType(); if (Hour()==1 && Minute()==1 && Seconds()==1 && sendOK==0) { sendOK=1;stopOK=0; if(long_court==1 && booster ) // if (!IsTradeContextBusy() && IsTradeAllowed()) { //bool modif1= OrderSend(Symbol(), OP_SELLSTOP, NR(Lot_Volume()), Bid-ecart*Point, Slippage, /*Bid- ecart*Point+Stoploss*Point*/0,Bid-ecart*Point-Takeprofit*Point*10, "MODULOSTOP-GG-V4", MagicNumber, 0, clrGreenYellow); bool modif2= OrderSend(Symbol(), OP_BUYSTOP, NR(Lot_Volume()), Ask+ ecart*Point, Slippage,/* Ask+ ecart*Point-Stoploss*Point*/0,Ask+ecart*Point+Takeprofit*Point*10, "MODULOSTOP-GG-V4", MagicNumber, 0, clrGreenYellow); //OrderSend(Symbol(), OP_SELLSTOP, NR(Lot_Volume()), Bid-ecart*Point, Slippage, Bid- ecart*Point+Stoploss*Point,Bid-ecart*Point-Takeprofit*Point, "", MagicNumber, 0, Red); } if(long_court==0 && booster ) // if (!IsTradeContextBusy() && IsTradeAllowed()) { // bool modif2= OrderSend(Symbol(), OP_BUYSTOP, NR(Lot_Volume()), Ask+ ecart*Point, Slippage,/* Ask+ ecart*Point-Stoploss*Point*/0,Ask+ecart*Point+Takeprofit*Point*10, "MODULOSTOP-GG-V4", MagicNumber, 0, clrGreenYellow); bool modif1= OrderSend(Symbol(), OP_SELLSTOP, NR(Lot_Volume()), Bid-ecart*Point, Slippage, /*Bid- ecart*Point+Stoploss*Point*/0,Bid-ecart*Point-Takeprofit*Point*10, "MODULOSTOP-GG-V4", MagicNumber, 0, clrGreenYellow); //OrderSend(Symbol(), OP_BUYSTOP, NR(Lot_Volume()), Ask+ ecart*Point, Slippage, Ask+ ecart*Point-Stoploss*Point,Ask+ecart*Point+Takeprofit*Point, "", MagicNumber, 0, Blue); } } if (Hour()>=23 && stopOK==0) { stopOK=1;sendOK=0; int u = OrdersTotal() - 1; while (u >= 0) { if(OrderSelect(u, SELECT_BY_POS)) if (type == OP_SELLSTOP || type == OP_BUYSTOP) { bool modif3=OrderDelete(OrderTicket()); } u -= 1; } } if (AccountEquity()>= AccountBalance()+ gain) { int w = OrdersTotal() - 1; while (w >= 0) { if(OrderSelect(w, SELECT_BY_POS)) { bool modif4= OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 2); bool modif5= OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 2); } w -= 1; } } return(0); } //+------------------------------------------------------------------+ //Calculates Lot Size based on balance and factor //+------------------------------------------------------------------+ double NR(double thelot) { double maxlots=MarketInfo(Symbol(),MODE_MAXLOT), minilot=MarketInfo(Symbol(),MODE_MINLOT), lstep=MarketInfo(Symbol(),MODE_LOTSTEP); double lots=lstep*NormalizeDouble(thelot/lstep,0); lots=MathMax(MathMin(maxlots,lots),minilot); return (lots); } //+------------------------------------------------------------------+ double Lot_Volume() { lot=AccountBalance() * 0.01 /LotFactor ; return(lot); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+
    lefeuvr3 a joint une image
    modulostop-version-4-11844