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

Ordre de Sell / Buy par un EA MQL4 MT4 UT M30 / DAX30 CFD

  • billyTom

    Bonjour,

    sous MT4 MQL4 (UT M30 / DAX30 CFD) j’essai de voir comment faire un ordre d'achat/vente via les conditions ci-jointe.

    Si vous pouviez m'aiguiller par un bout de code...

    après pour la clôture je suis ouvert peut-être un TP +10pips ? là j’avoue ?!?
    déjà ouvrir l'ordre me pose problème alors le reste... :P

    Merci d'avance
    billyTom a joint une image
    ordre-de-sell-buy-par-un-ea-mql4-mt4-ut-m30-dax30-cfd-11977
  • billyTom

    les ptis pouces levés c'est cool et ça me montre que mon message est pas trop con lol
    Mais ça me dit pas comment faire ! :-D
    Modifié le 2020-01-26 18:04:36 par billyTom
  • billyTom

    Bon... c'est sans doute très moche mais je fais avec les moyens du bord hein !
    Oui c'est avec un builder... donc probablement très mal fait désolé... :(

    Code
    //+------------------------------------------------------------------+ // DO NOT DELETE THIS HEADER // DELETING THIS HEADER IS COPYRIGHT INFRIGMENT // // Copyright ©2011, ForexEAdvisor.com // ForexEAdvisor Strategy Builder version 0.2 // http://www.ForexEAdvisor.com // // THIS EA CODE HAS BEEN GENERATED USING FOREXEADVISOR STRATEGY BUILDER 0.2 // on: 1/26/2020 10:30:01 PM // Disclaimer: This EA is provided to you "AS-IS", and ForexEAdvisor disclaims any warranty // or liability obligations to you of any kind. // UNDER NO CIRCUMSTANCES WILL FOREXEADVISOR BE LIABLE TO YOU, OR ANY OTHER PERSON OR ENTITY, // FOR ANY LOSS OF USE, REVENUE OR PROFIT, LOST OR DAMAGED DATA, OR OTHER COMMERCIAL OR // ECONOMIC LOSS OR FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, STATUTORY, PUNITIVE, // EXEMPLARY OR CONSEQUENTIAL DAMAGES WHATSOEVER RELATED TO YOUR USE OF THIS EA OR // FOREXEADVISOR STRATEGY BUILDER // Because software is inherently complex and may not be completely free of errors, you are // advised to verify this EA. Before using this EA, please read the ForexEAdvisor Strategy Builder // license for a complete understanding of ForexEAdvisor' disclaimers. // USE THIS EA AT YOUR OWN RISK. // // Before adding this expert advisor to a chart, make sure there are NO // open positions. // DO NOT DELETE THIS HEADER // DELETING THIS HEADER IS COPYRIGHT INFRIGMENT //+------------------------------------------------------------------+ extern int MagicNumber=10001; extern double Lots =0.01; extern double StopLoss=5; extern double TakeProfit=10; extern int TrailingStop=50; extern int Slippage=3; //+------------------------------------------------------------------+ // expert start function //+------------------------------------------------------------------+ int start() { double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; double TheStopLoss=0; double TheTakeProfit=0; if( TotalOrdersCount()==0 ) { int result=0; if((iMA(NULL,PERIOD_M30,50,1,MODE_SMA,PRICE_CLOSE,1)>Open[1])&&(iMA(NULL,PERIOD_M30,50,1,MODE_SMA,PRICE_CLOSE,1)<Close[1])&&(Open[0]>=Close[1])&&(Low[0]<Close[1])) // Here is your open buy rule { result=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,"EA Generator www.ForexEAdvisor.com",MagicNumber,0,Blue); if(result>0) { TheStopLoss=0; TheTakeProfit=0; if(TakeProfit>0) TheTakeProfit=Ask+TakeProfit*MyPoint; if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint; OrderSelect(result,SELECT_BY_TICKET); OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } if((iMA(NULL,PERIOD_M30,50,1,MODE_SMA,PRICE_CLOSE,1)>Close[1])&&(iMA(NULL,PERIOD_M30,50,1,MODE_SMA,PRICE_CLOSE,1)<Open[1])&&(Open[0]<=Close[1])&&(High[0]<Open[1])) // Here is your open Sell rule { result=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,"EA Generator www.ForexEAdvisor.com",MagicNumber,0,Red); if(result>0) { TheStopLoss=0; TheTakeProfit=0; if(TakeProfit>0) TheTakeProfit=Bid-TakeProfit*MyPoint; if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint; OrderSelect(result,SELECT_BY_TICKET); OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } } for(int cnt=0;cnt<OrdersTotal();cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderType()<=OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber ) { if(OrderType()==OP_BUY) { if((Close[0]>5)) //here is your close buy rule { OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage,Red); } if(TrailingStop>0) { if(Bid-OrderOpenPrice()>MyPoint*TrailingStop) { if(OrderStopLoss()<Bid-MyPoint*TrailingStop) { OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green); return(0); } } } } else { if((Close[0]<5)) // here is your close sell rule { OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage,Red); } if(TrailingStop>0) { if((OrderOpenPrice()-Ask)>(MyPoint*TrailingStop)) { if((OrderStopLoss()>(Ask+MyPoint*TrailingStop)) || (OrderStopLoss()==0)) { 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++) { OrderSelect(i,SELECT_BY_POS ,MODE_TRADES); if (OrderMagicNumber()==MagicNumber) result++; } return (result); }
    Modifié le 2020-01-26 22:05:52 par billyTom
  • billyTom

    Bonjour,

    Personne pour me donner un bout de code "propre" ? que je l'analyse le décortique...etc....
    car le mien généré en automatique fonctionne pas vraiment :(
    puis rajouter une clôture du buy et du sell à +60points.

    Merci pour votre aide.
    Cordialement.
    billyTom a joint une image
    ordre-de-sell-buy-par-un-ea-mql4-mt4-ut-m30-dax30-cfd-11989
  • stani

    Salut
    Peux tu nous dire ce qui ne "fonctionne pas vraiment", là c'est un peu vague pour t'aider.
  • billyTom

    Salut,

    avant tout, merci de t’intéresser à mon problème :)
    premièrement le prog est fait par un moyen automatique donc forcement code sans doute pas propre... (j'essai d'apprendre...)
    mais il semble ouvrir des buy et des sell au bon moment ! (point positif)
    le souci c'est qu'il prend plusieurs positions (cf. l'image jointe";) et je souhaiterai les clôtures par exemple quand 50 ou 60points sont atteints mais...?!?

    Code
    //+------------------------------------------------------------------+ // DO NOT DELETE THIS HEADER // DELETING THIS HEADER IS COPYRIGHT INFRIGMENT // // Copyright ©2011, ForexEAdvisor.com // ForexEAdvisor Strategy Builder version 0.2 // http://www.ForexEAdvisor.com // // THIS EA CODE HAS BEEN GENERATED USING FOREXEADVISOR STRATEGY BUILDER 0.2 // on: 2/1/2020 5:56:16 PM // Disclaimer: This EA is provided to you "AS-IS", and ForexEAdvisor disclaims any warranty // or liability obligations to you of any kind. // UNDER NO CIRCUMSTANCES WILL FOREXEADVISOR BE LIABLE TO YOU, OR ANY OTHER PERSON OR ENTITY, // FOR ANY LOSS OF USE, REVENUE OR PROFIT, LOST OR DAMAGED DATA, OR OTHER COMMERCIAL OR // ECONOMIC LOSS OR FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, STATUTORY, PUNITIVE, // EXEMPLARY OR CONSEQUENTIAL DAMAGES WHATSOEVER RELATED TO YOUR USE OF THIS EA OR // FOREXEADVISOR STRATEGY BUILDER // Because software is inherently complex and may not be completely free of errors, you are // advised to verify this EA. Before using this EA, please read the ForexEAdvisor Strategy Builder // license for a complete understanding of ForexEAdvisor' disclaimers. // USE THIS EA AT YOUR OWN RISK. // // Before adding this expert advisor to a chart, make sure there are NO // open positions. // DO NOT DELETE THIS HEADER // DELETING THIS HEADER IS COPYRIGHT INFRIGMENT //+------------------------------------------------------------------+ extern int MagicNumber=10001; extern double Lots =0.01; extern double StopLoss=50; extern double TakeProfit=50; extern int TrailingStop=50; extern int Slippage=3; //+------------------------------------------------------------------+ // expert start function //+------------------------------------------------------------------+ int start() { double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; double TheStopLoss=0; double TheTakeProfit=0; if( TotalOrdersCount()==0 ) { int result=0; if((iMA(NULL,PERIOD_M30,50,2,MODE_SMA,PRICE_CLOSE,2)>Open[2])&&(iMA(NULL,PERIOD_M30,50,2,MODE_SMA,PRICE_CLOSE,2)<Close[2])&&(Open[1]>=Close[2])&&(Low[1]<Close[2])&&(Open[2]<Close[2])&&(Open[1]<Close[1])) // Here is your open buy rule { result=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,"EA Generator www.ForexEAdvisor.com",MagicNumber,0,Blue); if(result>0) { TheStopLoss=100; TheTakeProfit=40; if(TakeProfit>0) TheTakeProfit=Ask+TakeProfit*MyPoint; if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint; OrderSelect(result,SELECT_BY_TICKET); OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } if((iMA(NULL,PERIOD_M30,50,2,MODE_SMA,PRICE_CLOSE,2)<Open[2])&&(iMA(NULL,PERIOD_M30,50,2,MODE_SMA,PRICE_CLOSE,2)>Close[2])&&(Open[1]<=Close[2])&&(High[1]<Open[2])&&(Open[2]>Close[2])&&(Open[1]>Close[1])) // Here is your open Sell rule { result=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,"EA Generator www.ForexEAdvisor.com",MagicNumber,0,Red); if(result>0) { TheStopLoss=100; TheTakeProfit=40; if(TakeProfit>0) TheTakeProfit=Bid-TakeProfit*MyPoint; if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint; OrderSelect(result,SELECT_BY_TICKET); OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } } for(int cnt=0;cnt<OrdersTotal();cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderType()<=OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber ) { if(OrderType()==OP_BUY) { if((Close[0]>Open[0])) //here is your close buy rule { OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage,Red); } if(TrailingStop>0) { if(Bid-OrderOpenPrice()>MyPoint*TrailingStop) { if(OrderStopLoss()<Bid-MyPoint*TrailingStop) { OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green); return(0); } } } } else { if((Close[0]<Open[0])) // here is your close sell rule { OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage,Red); } if(TrailingStop>0) { if((OrderOpenPrice()-Ask)>(MyPoint*TrailingStop)) { if((OrderStopLoss()>(Ask+MyPoint*TrailingStop)) || (OrderStopLoss()==0)) { 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++) { OrderSelect(i,SELECT_BY_POS ,MODE_TRADES); if (OrderMagicNumber()==MagicNumber) result++; } return (result); }
    Modifié le 2020-02-02 10:34:37 par billyTom
    billyTom a joint une image
    ordre-de-sell-buy-par-un-ea-mql4-mt4-ut-m30-dax30-cfd-11990
  • stani

    Bien sur que le code est très imparfait, mais un EA aussi simple, je présume que c'est juste a titre expérimental, pour tester vite fait une idée. Donc cela peut suffire.
    Pour la sortie tu as un paramètre "StopLoss" qui a première vue devrait le faire, inutile d'aller bidouiller dans le code des valeurs qui sont de toutes façons recalculées a la ligne suivante, met juste les bonnes valeurs dans le paramètre. :)
    Modifié le 2020-02-02 12:38:42 par stani
  • billyTom

    Merci bien mais pour le moment ça n'est pas concluant !
  • stani

    Oui, mais c'est très figé comme stratégie, tu n'as pas beaucoup de leviers d'action !
    Une fois tes conditions définis, tu n'as plus que regarder... en priant !!! :)
    Bon courage
  • billyTom

    Stani, Alors là tu as tout à fais raison !
    pour le moment l’essai de comprendre et apprendre le langage.
    d’où mes recherches d'exemples bien fait, simples et commentés un maximum pour avancer.
    je ne me lancerai pas à coller un EA comme ça en réel.
    j'envisage dans un premier temps plus de faire un indicateur qui me donnera des points d'entrées et je ferai office d'EA ;)
    cela reste néanmoins pour moi encore de l'apprentissage...
  • lefeuvr3

    Mon cher Billy Tom
    Je me suis permis d'apporter quelques modifications à ton programme pour corriger les warnings et petits problèmes
    J'ai utiliser la periode Minute pour avoir plus d’occurrences.
    Je te le mets ici
    Si tu voulais ,par hasard ,utiliser ce programme il faudrait augmenter le LotFactor pour diminuer le risque DrawDown....il est ici poussé à son maximun
    Passe une excellente journée
    Gerard

    Code
    //+------------------------------------------------------------------+ //| Billy Tom EA.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 A2=2; extern int B1 =1; extern int MagicNumber=10001; extern int LotFactor =50;....Leverage //Levier extern double StopLoss=0; extern double TakeProfit=50; extern int TrailingStop=0; extern int Slippage=3; //+------------------------------------------------------------------+ // expert start function //+------------------------------------------------------------------+ int start() { 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//Ici votre strategie d'achat if((iMA(NULL,PERIOD_M1,50,2,MODE_SMA,PRICE_CLOSE,2)>Open[A2])&&(iMA(NULL,PERIOD_M1,50,2,MODE_SMA,PRICE_CLOSE,A2)<Close[A2])&&(Open[B1]>=Close[A2])&&(Low[B1]<Close[A2])&&(Open[A2]<Close[A2])&&(Open[B1]<Close[B1])) // Here is your open buy rule //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ { 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((iMA(NULL,PERIOD_M1,50,2,MODE_SMA,PRICE_CLOSE,2)<Open[A2])&&(iMA(NULL,PERIOD_M1,50,2,MODE_SMA,PRICE_CLOSE,2)>Close[A2])&&(Open[B1]<=Close[A2])&&(High[B1]<Open[A2])&&(Open[A2]>Close[A2])&&(Open[B1]>Close[B1])) // Here is your open Sell rule //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ { 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-06 12:18:18 par lefeuvr3
    lefeuvr3 a joint une image
    ordre-de-sell-buy-par-un-ea-mql4-mt4-ut-m30-dax30-cfd-11995
  • lefeuvr3

    Je vais voir ce que cela donne en reel avec un levier de LotFactor à 120 dans un premier temps
  • lefeuvr3

    Ps...oups !
    Je viens de realiser qu'il y a une petite boulette a corriger....il faut remplacer

    Code
    extern int LotFactor =50;....Leverage //Levier par extern int LotFactor =50;//....Leverage //Levier

    En effet il manque deux barres après le point-virgule pour qu'il puisse fonctionner.
    Modifié le 2020-02-06 12:35:25 par lefeuvr3 : erreur sur balise
  • billyTom

    Bonjour lefeuvr3,

    Merci de t’intéresser à mon EA.
    Je pense qu'il y a moyen d'en faire quelque chose mon seul point bloquant est la méconnaissance du langage MQL4 ;)
    Ce qui est quand même un sérieux handicape !
    néanmoins en backtest c'est plutôt prometteur.
    Modifié le 2020-02-06 15:14:29 par billyTom
  • lefeuvr3

    retour sur infos live
    trois positions prises par l'EA ...trois trades gagnants...23.15...2.38...4.93 entre hier et aujourd'hui avec capital de 2000 €
  • lefeuvr3

    Billy Tom ea M15 Eurusd...(unite de temps 15 minutes )
    En fonction des différentes unités de temps utilisées ,il faut faire varier les paramétres (Tp-Ts ...période de la moyenne mobile...etc)
    Il est bien plus facile de réaliser un EA pour chaque unité de temps (1 minutes ...15 mn...1 Heures ...4 Heures...) que d'essayer de toutes les mettre sur le même sur un seul EA.

    Code
    //+------------------------------------------------------------------+ //| Billy Tom M15 EA.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 A2=2; extern int B1 =1; extern int MagicNumber=10001; extern int LotFactor =50; extern double StopLoss=0; extern double TakeProfit=40; extern int TrailingStop=45; extern int Slippage=3; extern int period=50; //+------------------------------------------------------------------+ // expert start function //+------------------------------------------------------------------+ int start() { 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//Ici votre strategie d'achat if((iMA(NULL,PERIOD_M15,period,2,MODE_SMA,PRICE_CLOSE,2)>Open[A2])&&(iMA(NULL,PERIOD_M15,period,2,MODE_SMA,PRICE_CLOSE,A2)<Close[A2])&&(Open[B1]>=Close[A2])&&(Low[B1]<Close[A2])&&(Open[A2]<Close[A2])&&(Open[B1]<Close[B1])) // Here is your open buy rule //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ { 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((iMA(NULL,PERIOD_M15,period,2,MODE_SMA,PRICE_CLOSE,2)<Open[A2])&&(iMA(NULL,PERIOD_M15,period,2,MODE_SMA,PRICE_CLOSE,2)>Close[A2])&&(Open[B1]<=Close[A2])&&(High[B1]<Open[A2])&&(Open[A2]>Close[A2])&&(Open[B1]>Close[B1])) // Here is your open Sell rule //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ { 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-11 14:03:35 par lefeuvr3 : faute de frappe
    lefeuvr3 a joint une image
    ordre-de-sell-buy-par-un-ea-mql4-mt4-ut-m30-dax30-cfd-12002
  • billyTom

    lefeuvr3 il semble avoir de bon résultat reste à voir sur le plus ou moins long terme en réel...
  • lefeuvr3

    Pour le moment en réel ,il a un très bon comportement en UT 1 minute
    Avec un capital de 2000 € cela donne 11 trades gagnants pour un gain de 121.77 €uros du 06.02.2020 au 11.02.2020
  • billyTom

    c'est plutôt pas mal en effet :)
  • billyTom

    Bonjour lefeuvr3,

    Toujours en test avec cet EA ?