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

BOLLINGER_BANDS_RSI_V4_EA ...EURUSD ...1MN

  • lefeuvr3

    Version a plusieurs étages
    Code
    //+------------------------------------------------------------------+ //| BOLLINGER_BANDS_RSI_EA_V4.mq4 | //| Copyright 2020, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2020, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict //+------------------------------------------------------------------+ //BOLLINGER_BANDS_EA ...EURUSD ...1MN //+------------------------------------------------------------------+ extern int MagicNumber=04122020; extern int barnumberA =5; extern int shifthighA=15; extern int shiftlowA=0; extern int barnumberB =5; extern int shifthighB=19; extern int shiftlowB=0; extern double StopLossA=68; extern double TakeProfitA=79; extern double StopLossB=46; extern double TakeProfitB=40; extern int TrailingStop=36; extern int Slippage=3; extern int IndicatorperiodA=23; extern int IndicatorperiodB=33; extern int BBDeviation=2; extern double LotFactor =195; //lotsize factor double lot; double MarginFree;// Free margin in percentage extern double MinMarginLevel = 100; // Lowest allowed Margin level for new positions to be opened. extern double LowlevelA=24; extern double HighlevelA=48; extern int PeriodeA=5; extern int shiftA=17; extern double LowlevelB=34; extern double HighlevelB=30; extern int PeriodeB=5; extern int shiftB=14; //+------------------------------------------------------------------+ // expert start function //+------------------------------------------------------------------+ int start() { double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; double TheStopLoss=0; double TheTakeProfit=0; //Calculate and check spread double MaxSpreadInPoints = 30; double Spread = Ask - Bid; if(Spread>MaxSpreadInPoints*Point) return(false); //+------------------------------------------------------------------+ double am = 0.000000001; // Set variable to a very small number double marginlevel; // Get the Free Margin MarginFree = AccountFreeMargin(); // Calculate Margin level if ( AccountMargin() != 0 ) am = AccountMargin(); marginlevel = AccountEquity() / am * 100; // Free Margin is less than the value of MinMarginLevel, so no trading is allowed if ( marginlevel < MinMarginLevel ) { Comment ( "Warning! Free Margin " + DoubleToStr ( marginlevel, 2 ) + " is lower than MinMarginLevel!" ); Alert ( "Warning! Free Margin " + DoubleToStr ( marginlevel, 2 ) + " is lower than MinMarginLevel!" ); return(0); } //+------------------------------------------------------------------+ if( TotalOrdersCount()==0 ) { int result=0; //A if((iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,1)<iBands(NULL,PERIOD_M1,IndicatorperiodA,BBDeviation,0,PRICE_OPEN,MODE_LOWER,1)) &&(iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,0)>iBands(NULL,PERIOD_M1,IndicatorperiodA,BBDeviation,0,PRICE_OPEN,MODE_LOWER,0))) // Here is your open buy rule if((iRSI(NULL,0,PeriodeA,PRICE_CLOSE,1)<LowlevelA)&&(iRSI(NULL,0,PeriodeA,PRICE_CLOSE,0)>LowlevelA)) if ((iLow ( Symbol (), PERIOD_M1 , iLowest ( Symbol (), PERIOD_M1 , MODE_LOW, barnumberA , shiftlowA )))<(iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,0))) { if (!IsTradeContextBusy() && IsTradeAllowed()) result=OrderSend(Symbol(),OP_BUY,NR(Lot_Volume()),Ask,Slippage,0,0,"BOLLINGER_BANDS_RSI_EA_V4",MagicNumber,0,Blue); if(result>0) { TheStopLoss=0; TheTakeProfit=0; if(TakeProfitA>0) TheTakeProfit=Ask+TakeProfitA*MyPoint; if(StopLossA>0) TheStopLoss=Ask-StopLossA*MyPoint; if(OrderSelect(result,SELECT_BY_TICKET)) bool modif1=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } //B if((iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,1)>iBands(NULL,PERIOD_M1,IndicatorperiodB,BBDeviation,0,PRICE_OPEN,MODE_UPPER,1)) &&(iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,0)<iBands(NULL,PERIOD_M1,IndicatorperiodB,BBDeviation,0,PRICE_OPEN,MODE_UPPER,0))) // Here is your open Sell rule if((iRSI(NULL,0,PeriodeB,PRICE_CLOSE,1)>HighlevelB)&&(iRSI(NULL,0,PeriodeB,PRICE_CLOSE,0)<HighlevelB)) if((iHigh ( Symbol (), PERIOD_M1 , iHighest ( Symbol (), PERIOD_M1 , MODE_HIGH, barnumberB , shifthighB )))>(iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,0))) { if (!IsTradeContextBusy() && IsTradeAllowed()) result=OrderSend(Symbol(),OP_BUY,NR(Lot_Volume()),Ask,Slippage,0,0,"BOLLINGER_BANDS_RSI_EA_V4",MagicNumber,0,Blue); if(result>0) { TheStopLoss=0; TheTakeProfit=0; if(TakeProfitB>0) TheTakeProfit=Ask+TakeProfitB*MyPoint; if(StopLossB>0) TheStopLoss=Ask-StopLossB*MyPoint; if(OrderSelect(result,SELECT_BY_TICKET)) bool modif1=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } // A if((iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,1)>iBands(NULL,PERIOD_M1,IndicatorperiodA,BBDeviation,0,PRICE_OPEN,MODE_UPPER,1)) &&(iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,0)<iBands(NULL,PERIOD_M1,IndicatorperiodA,BBDeviation,0,PRICE_OPEN,MODE_UPPER,0))) // Here is your open Sell rule if((iRSI(NULL,0,PeriodeA,PRICE_CLOSE,1)>HighlevelA)&&(iRSI(NULL,0,PeriodeA,PRICE_CLOSE,0)<HighlevelA)) if((iHigh ( Symbol (), PERIOD_M1 , iHighest ( Symbol (), PERIOD_M1 , MODE_HIGH, barnumberA , shifthighA )))>(iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,0))) { if (!IsTradeContextBusy() && IsTradeAllowed()) result=OrderSend(Symbol(),OP_SELL,NR(Lot_Volume()),Bid,Slippage,0,0,"BOLLINGER_BANDS_RSI_EA_V4",MagicNumber,0,Red); if(result>0) { TheStopLoss=0; TheTakeProfit=0; if(TakeProfitA>0) TheTakeProfit=Bid-TakeProfitA*MyPoint; if(StopLossA>0) TheStopLoss=Bid+StopLossA*MyPoint; if(OrderSelect(result,SELECT_BY_TICKET)) bool modif2= OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } //B if((iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,1)<iBands(NULL,PERIOD_M1,IndicatorperiodB,BBDeviation,0,PRICE_OPEN,MODE_LOWER,1)) &&(iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,0)>iBands(NULL,PERIOD_M1,IndicatorperiodB,BBDeviation,0,PRICE_OPEN,MODE_LOWER,0))) // Here is your open buy rule if((iRSI(NULL,0,PeriodeB,PRICE_CLOSE,1)<LowlevelB)&&(iRSI(NULL,0,PeriodeB,PRICE_CLOSE,0)>LowlevelB)) if ((iLow ( Symbol (), PERIOD_M1 , iLowest ( Symbol (), PERIOD_M1 , MODE_LOW, barnumberB , shiftlowB )))<(iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,0))) { if (!IsTradeContextBusy() && IsTradeAllowed()) result=OrderSend(Symbol(),OP_SELL,NR(Lot_Volume()),Bid,Slippage,0,0,"BOLLINGER_BANDS_RSI_EA_V4",MagicNumber,0,Red); if(result>0) { TheStopLoss=0; TheTakeProfit=0; if(TakeProfitB>0) TheTakeProfit=Bid-TakeProfitB*MyPoint; if(StopLossB>0) TheStopLoss=Bid+StopLossB*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); } //+------------------------------------------------------------------+ //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
    bollingerbandsrsiv4ea-eurusd-1mn-12505
  • lefeuvr3

    nouvelle version avec simplification des parametres mais avec un resultat moindre
    Code
    //+------------------------------------------------------------------+ //| BOLLINGER_BANDS_RSI_V5.mq4 | //| Copyright 2020, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| BOLLINGER_BANDS_RSI_EA_V4.mq4 | //| Copyright 2020, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2020, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict //+------------------------------------------------------------------+ //BOLLINGER_BANDS_EA ...EURUSD ...1MN //+------------------------------------------------------------------+ extern int MagicNumber=04122020; extern int barnumber =5; extern int shifthigh=11; extern int shiftlow=14; extern double StopLoss=71; extern double TakeProfit=38; extern int TrailingStop=35; extern int Slippage=3; extern int Indicatorperiod=22; extern int BBDeviation=2; extern double LotFactor =195; //lotsize factor double lot; double MarginFree;// Free margin in percentage extern double MinMarginLevel = 100; // Lowest allowed Margin level for new positions to be opened. extern double Lowlevel=50; extern double Highlevel=50; extern int Periode=10; extern int shift=15; //+------------------------------------------------------------------+ // expert start function //+------------------------------------------------------------------+ int start() { double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; double TheStopLoss=0; double TheTakeProfit=0; //Calculate and check spread double MaxSpreadInPoints = 30; double Spread = Ask - Bid; if(Spread>MaxSpreadInPoints*Point) return(false); //+------------------------------------------------------------------+ double am = 0.000000001; // Set variable to a very small number double marginlevel; // Get the Free Margin MarginFree = AccountFreeMargin(); // Calculate Margin level if ( AccountMargin() != 0 ) am = AccountMargin(); marginlevel = AccountEquity() / am * 100; // Free Margin is less than the value of MinMarginLevel, so no trading is allowed if ( marginlevel < MinMarginLevel ) { Comment ( "Warning! Free Margin " + DoubleToStr ( marginlevel, 2 ) + " is lower than MinMarginLevel!" ); Alert ( "Warning! Free Margin " + DoubleToStr ( marginlevel, 2 ) + " is lower than MinMarginLevel!" ); return(0); } //+------------------------------------------------------------------+ if( TotalOrdersCount()==0 ) { int result=0; //A if((iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,1)<iBands(NULL,PERIOD_M1,Indicatorperiod,BBDeviation,0,PRICE_OPEN,MODE_LOWER,1)) &&(iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,0)>iBands(NULL,PERIOD_M1,Indicatorperiod,BBDeviation,0,PRICE_OPEN,MODE_LOWER,0))) // Here is your open buy rule if((iRSI(NULL,0,Periode,PRICE_CLOSE,1)<Lowlevel)&&(iRSI(NULL,0,Periode,PRICE_CLOSE,0)>Lowlevel)) if ((iLow ( Symbol (), PERIOD_M1 , iLowest ( Symbol (), PERIOD_M1 , MODE_LOW, barnumber , shiftlow )))<(iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,0))) { if (!IsTradeContextBusy() && IsTradeAllowed()) result=OrderSend(Symbol(),OP_BUY,NR(Lot_Volume()),Ask,Slippage,0,0,"BOLLINGER_BANDS_RSI_EA_V4",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); } //B if((iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,1)>iBands(NULL,PERIOD_M1,Indicatorperiod,BBDeviation,0,PRICE_OPEN,MODE_UPPER,1)) &&(iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,0)<iBands(NULL,PERIOD_M1,Indicatorperiod,BBDeviation,0,PRICE_OPEN,MODE_UPPER,0))) // Here is your open Sell rule if((iRSI(NULL,0,Periode,PRICE_CLOSE,1)>Highlevel)&&(iRSI(NULL,0,Periode,PRICE_CLOSE,0)<Highlevel)) if((iHigh ( Symbol (), PERIOD_M1 , iHighest ( Symbol (), PERIOD_M1 , MODE_HIGH, barnumber , shifthigh )))>(iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,0))) { if (!IsTradeContextBusy() && IsTradeAllowed()) result=OrderSend(Symbol(),OP_BUY,NR(Lot_Volume()),Ask,Slippage,0,0,"BOLLINGER_BANDS_RSI_EA_V4",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); } // A if((iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,1)>iBands(NULL,PERIOD_M1,Indicatorperiod,BBDeviation,0,PRICE_OPEN,MODE_UPPER,1)) &&(iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,0)<iBands(NULL,PERIOD_M1,Indicatorperiod,BBDeviation,0,PRICE_OPEN,MODE_UPPER,0))) // Here is your open Sell rule if((iRSI(NULL,0,Periode,PRICE_CLOSE,1)>Highlevel)&&(iRSI(NULL,0,Periode,PRICE_CLOSE,0)<Highlevel)) if((iHigh ( Symbol (), PERIOD_M1 , iHighest ( Symbol (), PERIOD_M1 , MODE_HIGH, barnumber , shifthigh )))>(iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,0))) { if (!IsTradeContextBusy() && IsTradeAllowed()) result=OrderSend(Symbol(),OP_SELL,NR(Lot_Volume()),Bid,Slippage,0,0,"BOLLINGER_BANDS_RSI_EA_V4",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); } //B if((iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,1)<iBands(NULL,PERIOD_M1,Indicatorperiod,BBDeviation,0,PRICE_OPEN,MODE_LOWER,1)) &&(iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,0)>iBands(NULL,PERIOD_M1,Indicatorperiod,BBDeviation,0,PRICE_OPEN,MODE_LOWER,0))) // Here is your open buy rule if((iRSI(NULL,0,Periode,PRICE_CLOSE,1)<Lowlevel)&&(iRSI(NULL,0,Periode,PRICE_CLOSE,0)>Lowlevel)) if ((iLow ( Symbol (), PERIOD_M1 , iLowest ( Symbol (), PERIOD_M1 , MODE_LOW, barnumber , shiftlow )))<(iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,0))) { if (!IsTradeContextBusy() && IsTradeAllowed()) result=OrderSend(Symbol(),OP_SELL,NR(Lot_Volume()),Bid,Slippage,0,0,"BOLLINGER_BANDS_RSI_EA_V4",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); } //+------------------------------------------------------------------+ //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
    bollingerbandsrsiv4ea-eurusd-1mn-12506
  • rudygg — en réponse à lefeuvr3 dans son message #120262

    Bonjour,
    je suis novice dans MT4 et je m'intéresse aux EA et au langage mql5. J'ai fait exactement le même test et je ne retrouve pas le même rapport. Est-il possible de m'indiquer si il y a une configuration spécifique ? Merci
    rudygg a joint une image
    bollingerbandsrsiv4ea-eurusd-1mn-12507
  • lefeuvr3

    Il s'agit de la plateforme MT4....Le mieux est d'utiliser Tickstory [ https://tickstory.com/download-tickstory/ ] pour avoir un historique de meilleur qualite ... sinon les parametres sont totalement differents
    Une qualite de modelage de 25 % n'est pas suffisante ....il faut se rapprocher le plus possible des 90 à 100%