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 GG SELL V2.mq4 |

  • lefeuvr3

    Spread de 20 pour mettre le robot en condition difficile
    Capital de départ 1500 $...en dessous de ce montant ,on observe une baisse de la courbe en final de backtest.
    Je suis désolé pour la qualité du modelage mais ma plateforme ne me permet pas de faire mieux

    Code
    //+------------------------------------------------------------------+ //| MODULOSTOP GG SELL V2.mq4 | //| Copyright 2019, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| MODULO LG SH TP SL BREAKEVEN.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" int MagicNumber=13102019; //magic extern string Name_EA = "MODULOSTOP GG SELL V2"; double point = MarketInfo(Symbol(), MODE_POINT); int spread = MarketInfo(Symbol(), MODE_SPREAD); extern int size = 0; int shiftOpenBuy =0; int shiftCloseBuy =1; int shiftOpenSell =0; int shiftCloseSell =1; double LotFactorLONG=54 ; // extern double LotFactorSHORT = 130; //lotsize factor double MultiplierLONG = 0.1; // extern double MultiplierSHORT = 0.7; //from 0.04...to 0.09 extern int long_courtLONG=1; // 0 = Long & 1 = Court extern int long_courtSHORT=1; // 0 = Long & 1 = Court int gainLONG=32; // no comment ;) extern int gainSHORT=0; // no comment ;) int ecartLONG=0;// Ecart : 150, 1000, ou 1500 selon les paires.. extern int ecartSHORT=18;// Ecart : 150, 1000, ou 1500 selon les paires extern bool trail=false; extern double TrailingStop=13; double pips = 0.00001; //leave as default for 5 digit brokers int stopOK = 0; // ne pas modifier int sendOK = 0; // ne pas modifier extern int hour=23; extern int c=0; double LotSizeLONG; //lotsize double SizeLotLONG; double LotSizeSHORT; //lotsize double SizeLotSHORT; extern int profit=20; extern int stop =32; extern int Slippage =0; //---- 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,clrGold); if(OrderType()==OP_SELL) bool OrdClL=OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,clrGold); } } } } //+------------------------------------------------------------------+ //| 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(),clrGold); } } } 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(),clrGold); } } } } } } //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { if(trail) trail(); 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(PERIOD_M5==true) if(PERIOD_H1==true) if (((iOpen(Symbol(),0, shiftOpenBuy)> iClose(Symbol(),0, shiftCloseBuy)+ (size + spread)*point)) &&(Bid >iOpen(NULL,PERIOD_M5,0) &&(Bid >iOpen(NULL,PERIOD_H1,0)))) if(OrderSend(Symbol(), OP_BUY, SizeLotLONG, Ask, 0, Ask - (stop * Point), Ask + (profit * Point), "MODULOSTOP GG SELL V2",MagicNumber,0,clrGold))c=1;} //+------------------------------------------------------------------+ // Here is your open buy rule //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ // Here is the beginning of your open buy rule strategy //+------------------------------------------------------------------+ // double Price=(Ask+Bid)/2; if(PERIOD_M5==true) if(PERIOD_H1==true) if (((iOpen(Symbol(),0, shiftOpenBuy)> iClose(Symbol(),0, shiftCloseBuy)+ (size + spread)*point)) &&(Bid >iOpen(NULL,PERIOD_M5,0) &&(Bid >iOpen(NULL,PERIOD_H1,0)))) //+------------------------------------------------------------------+ // Here is the end of your buy rule strategy //+------------------------------------------------------------------+ if (!IsTradeContextBusy() && IsTradeAllowed()) if(c==0){if(OrderSend(Symbol(), OP_BUY, SizeLotSHORT, Ask, 0, Ask - (stop * Point), Ask + (profit * Point), "MODULOSTOP GG SELL V2",MagicNumber,0,clrGold))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_courtLONG==1) if (!IsTradeContextBusy() && IsTradeAllowed()) { int ticket5= OrderSend(Symbol(), OP_SELLSTOP, LotSizeLONG, Bid-ecartLONG*pips, 0, 0, 0, "MODULOSTOP GG SELL V2",MagicNumber,0,clrGold); if (!IsTradeContextBusy() && IsTradeAllowed()) if(long_courtSHORT==1) { int ticket6= OrderSend(Symbol(), OP_SELLSTOP, LotSizeSHORT, Bid-ecartSHORT*pips, 0, 0, 0, "MODULOSTOP GG SELL V2",MagicNumber,0,clrGold); if(ticket5<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket6<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } //+------------------------------------------------------------------+ if(long_courtLONG==0) if (!IsTradeContextBusy() && IsTradeAllowed()) { int ticket1= OrderSend(Symbol(), OP_BUYSTOP, LotSizeLONG, Ask+ecartLONG*pips, 0, 0, 0, "MODULO LONG SHORT TP SL TS",MagicNumber,0,clrGold); if(long_courtSHORT==0) if (!IsTradeContextBusy() && IsTradeAllowed()) { int ticket2= OrderSend(Symbol(), OP_BUYSTOP, LotSizeSHORT, Ask+ecartSHORT*pips, 0, 0, 0, "MODULO LONG SHORT TP SL TS",MagicNumber,0,clrGold); if(ticket1<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); } if(ticket2<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()+ gainLONG) if (AccountEquity()>= AccountBalance()+ gainSHORT) { 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 ticket3=OrderSend(Symbol(), OP_BUY, SizeLotLONG, Ask, 0, Ask - (stop * Point), Ask + (profit * Point), "MODULO LONG SHORT TP SL TS",MagicNumber,0,clrGold); //(OrderSend(Symbol(), OP_BUY, SizeLotLONG, Ask, 0, Ask - (stop1 * Point), Ask + (profit1 * Point), 0, "MODULO VERSION 4 LONG SHORT") int ticket4=OrderSend(Symbol(), OP_BUY, SizeLotSHORT, Ask, 0, Ask - (stop * Point), Ask + (profit * Point), "MODULO LONG SHORT TP SL TS",MagicNumber,0,clrGold); //--- place market order to buy 1 lot if(ticket3<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); if(ticket4<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() { LotSizeLONG=AccountBalance() * 0.01 /LotFactorLONG ; SizeLotLONG=LotSizeLONG*MultiplierLONG; return(LotSizeLONG); return(SizeLotLONG); LotSizeSHORT=AccountBalance() * 0.01 /LotFactorSHORT ; SizeLotSHORT=LotSizeSHORT*MultiplierSHORT; return(LotSizeSHORT); return(SizeLotSHORT); } //+------------------------------------------------------------------+
    lefeuvr3 a joint une image
    modulostop-gg-sell-v2-mq4-11878
  • jk666

    Bonjour Lefeuvr3,
    Merci beaucoup pour ce partage et pour la qualité de ce travail! Je l'ai pas mal testé aujourd'hui sur MT4. Vraiment très intéressant!!
    L'utilisez vous aujourd'hui en live ou toujours en backtest?
    Bien à vous
  • lefeuvr3

    Bonjour jk666

    Ce programme ne fonctionne pas en live en ce moment ,car je viens juste de le finaliser.
    Par contre d'autres tournent sur ma plateforme:

    RENGOU MTF ORDRES STOP
    MODULOSTOP V3 TS TP
    ETOILE SOIR MATIN GG
    QPG RANGE MTF
    MODULOSTOP V4 TS TP
    MODULOSTOP GG ...BUY
    Gap 30 Minutes
    RENGOU LOT SCALP
    Gap 1 heure
    Gap 4 Heures

    Il va falloir que j'augmente le capital a 2000 € pour faire tourner d'autre expert advisors

    MODULOSTOP GG ...SELL
    MODULO LONG SHORT TP SL TS BREAKEVEN
    MODULOSTOP GG SELL V2

    Il va sans dire que j'engage ,en live,un montant que je suis prêt a voir disparaître purement et simplement....la finalité étant plus de m'amuser avec mes robots,que de gagner de l'argent .

    Ps ..tout ce petit monde est réglé pour qu'un seul travaille à la fois quand la plateforme n'est pas occupée par un trade en cours....d'autre part ,je les mets au repos la nuit car je trouve que les spreads appliqués par le brooker sont trop conséquents

    Amicalement

    Gerard
  • jk666

    A la vue des noms des programmes plusieurs stratégies ont été pensées, c'est vraiment très intéressant tout ça.

    Je trade moi aussi, mais depuis quelques temps j'ai arrêté car les marchés sont anxiogènes et difficiles à appréhender. Le twett trading ce n'est pas mon truc :), je reprendrais après la prochaine euphorie des marchés qui devraient s'entamer et un changement de présidence aux US...

    Je m'intéresse de plus en plus au algo de trading, car 90% des trades (il me semble) sont faits aujourd'hui par des algo.

    Pour vos différents programmes, il est possible d'en faire fonctionner 2 ou 3 en même temps, mais reste à avoir les ressources serveurs en face. J'ai lu des programmeurs en faire tourner plusieurs 10ène en même temps. Mais tout dépendra, il me semble, de la puissance informatique du serveur sur lequelle ils seront hébergés.

    Pour les spreads je suis entièrement d'accord de ne pas faire tourner les programmes sur marché forex la nuit (arrêt vers 22 ou 23h). Et pour la somme placée, n'investir que la somme que l'on est prêt à perdre, je vous rejoins totalement sur cet autre point.

    Quel broker utilisez vous pour vos programmes MT4 ? Vous avez un VPS ou bien est-ce sur votre pc?

    Et encore une fois merci pour ce partage, c'est très enrichissant!!

    Bien à vous
  • lefeuvr3

    Mes programmes tournent pour le moment sur mon PC.....
    Je suis depuis des années chez Activtrades MT 4 avec beaucoup de satisfactions....spread raisonnable ,sachant que je ne trade que EURUSD et Broker très accessible à la moindre demande.
    En tradant de manière personnelle ,je sais que je ne ferai jamais aussi bien qu'un de mes programmes qui a ete au mieux optimisé.
    Ma règle d'or est de les laisser travailler même si la tentation est grande d'intervenir pendant leurs trades,en coupant des positions ou en prenant prématurément des bénéfices.
    Mais programmes sont assez courts pour ne pas prendre de ressource et permettre a plusieurs d'être places sur la plateforme ( par exemple je n'utilise pas de programmes avec iCustom car ils sont trop gourmands en ressource)
    Avec [ if (!IsTradeContextBusy() && IsTradeAllowed()) ]....un seul EA est en position a chaque fois ,sans interferer avec un autre.
    Amicalement
  • lefeuvr3

    Sur mes programmes ,la taille des lots est automatiquement calculée en fonction du capital du moment ....de ce fait le money managment est optimal .
    Je cache egalement mes anticipations stop loss au broker qui n'a pas a tout savoir .
  • jk666

    Bonjour à vous,

    Merci beaucoup pour toutes ces précisions!! C'est vraiment super de votre part. Je continue de tester vos programmes avec les données réelles aujourd'hui.

    J'ai remarqué, si cela peut vous aider, qu'en lançant le programme MODULO LONG SHORT TP SL TS BREAKEVEN, il prend direct une position. Je ne sais pas si je me trompe, mais il semble prendre une position sans avoir analyser et optimiser la position de départ du trade.

    Est-ce normal?

    Bien à vous
  • lefeuvr3

    Oui ce programme est impatient tel un pure sang arabe !