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

Base avec Advanced Money Management

  • lefeuvr3

    Il suffit d’insérer votre statégie à la place de... if((Bid>iOpen(Symbol(),0,0))) et de if((Bid<iOpen(Symbol(),0,0))) dans le programme qui suit :
    Ici le cours actuel [ Bid ] est supérieur au cours d'ouverture pour l'achat de la bougie en cours pour l'achat et le contraire pour la vente.

    PROGRAMME sans sortie par une strategie mais à l'aide de take profit ou stop
    Code
    //+------------------------------------------------------------------+ //| ADVANCED MONEY MANAGEMENT SANS SORTIES.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=10001; extern double Lots =0.1; 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; //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ // Here is your open buy rule//Ici votre strategie d'achat if((Bid>iOpen(Symbol(),0,0))) //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ { result=OrderSend(Symbol(),OP_BUY,AdvancedMM(),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; 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((Bid<iOpen(Symbol(),0,0))) //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ { result=OrderSend(Symbol(),OP_SELL,AdvancedMM(),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; 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); } double AdvancedMM() { int i; double AdvancedMMLots = 0; bool profit1=false; int SystemHistoryOrders=0; for( i=0;i<OrdersHistoryTotal();i++) { if(OrderSelect(i,SELECT_BY_POS ,MODE_HISTORY)) if (OrderMagicNumber()==MagicNumber) SystemHistoryOrders++; } bool profit2=false; int LO=0; if(SystemHistoryOrders<2) return(Lots); for( i=OrdersHistoryTotal()-1;i>=0;i--) { if(OrderSelect(i,SELECT_BY_POS ,MODE_HISTORY)) if (OrderMagicNumber()==MagicNumber) { if(OrderProfit()>=0 && profit1) return(Lots); if( LO==0) { if(OrderProfit()>=0) profit1=true; if(OrderProfit()<0) return(OrderLots()); LO=1; } if(OrderProfit()>=0 && profit2) return(AdvancedMMLots); if(OrderProfit()>=0) profit2=true; if(OrderProfit()<0 ) { profit1=false; profit2=false; AdvancedMMLots+=OrderLots(); } } } return(AdvancedMMLots); }
  • lefeuvr3

    Il suffit d’insérer votre statégie à la place de... if((Bid>iOpen(Symbol(),0,0))) et de if((Bid<iOpen(Symbol(),0,0))) dans le programme qui suit :
    Ici le cours actuel [ Bid ] est supérieur au cours d'ouverture pour l'achat de la bougie en cours pour l'achat et le contraire pour la vente.

    PROGRAMME avec sortie par une strategie sans à l'aide de take profit
    Code
    //+------------------------------------------------------------------+ //| ADVANCED MONEY MANAGEMENT.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=02112019; extern double Lots =0.1; 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; //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ // Here is your open buy rule//Ici votre strategie d'achat if((Bid>iOpen(Symbol(),0,0))) //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ { result=OrderSend(Symbol(),OP_BUY,AdvancedMM(),Ask,Slippage,0,0," ADVANCED MONEY MANAGEMENT",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((Bid<iOpen(Symbol(),0,0))) //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ { result=OrderSend(Symbol(),OP_SELL,AdvancedMM(),Bid,Slippage,0,0,"ADVANCED MONEY MANAGEMENT",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) { //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //here is your close buy rule//Ici strategie de fin d'achat if((Bid<iOpen(Symbol(),0,0))) //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ { bool modif3= OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage,Red); } if(TrailingStop>0) { if(Bid-OrderOpenPrice()>MyPoint*TrailingStop) { if(OrderStopLoss()<Bid-MyPoint*TrailingStop) { bool modif4=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green); return(0); } } } } else { //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ // here is your close sell rule/Ici strategie de fin de vente if((Bid>iOpen(Symbol(),0,0))) //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ { bool modif5=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage,Red); } if(TrailingStop>0) { if((OrderOpenPrice()-Ask)>(MyPoint*TrailingStop)) { if((OrderStopLoss()>(Ask+MyPoint*TrailingStop)) || (OrderStopLoss()==0)) { bool modif6= 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); } double AdvancedMM() { int i; double AdvancedMMLots = 0; bool profit1=false; int SystemHistoryOrders=0; for( i=0;i<OrdersHistoryTotal();i++) { if(OrderSelect(i,SELECT_BY_POS ,MODE_HISTORY)) if (OrderMagicNumber()==MagicNumber) SystemHistoryOrders++; } bool profit2=false; int LO=0; if(SystemHistoryOrders<2) return(Lots); for( i=OrdersHistoryTotal()-1;i>=0;i--) { if(OrderSelect(i,SELECT_BY_POS ,MODE_HISTORY)) if (OrderMagicNumber()==MagicNumber) { if(OrderProfit()>=0 && profit1) return(Lots); if( LO==0) { if(OrderProfit()>=0) profit1=true; if(OrderProfit()<0) return(OrderLots()); LO=1; } if(OrderProfit()>=0 && profit2) return(AdvancedMMLots); if(OrderProfit()>=0) profit2=true; if(OrderProfit()<0 ) { profit1=false; profit2=false; AdvancedMMLots+=OrderLots(); } } } return(AdvancedMMLots); }