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_KELTNER_ENVELOPES_BANDS_DIV_RSI_ATR_MARTINGALE

  • lefeuvr3

    Tout idée d'amelioration de cet EA serait constructive et bien venue
    Code
    //+------------------------------------------------------------------+ //| BOLLINGER_KELTNER_ENVELOPES_BANDS_DIV_RSI_ATR_MARTINGALE.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 //+------------------------------------------------------------------+ //...EURUSD ...1MN //+------------------------------------------------------------------+ extern string Expert_Advisor= "BOLLINGER_KELTNER_ENVELOPES_BANDS_DIV_RSI_ATR_MARTINGALE.mq4"; extern int MagicNumber=01022021; extern string Lotsize_Factor = "Lotsize Factor"; extern double LotFactor =90; //Lotsize Factor extern string Martingale_Power = "Martingale Power"; extern double MartingalePower=4.5;//Martingale Power extern string Dynamic_Parameters = "Dynamic Parameters"; extern int atrMultipleSL=70;//Stop Loss extern int atrMultipleTP=6;//Take Profit extern int atrMultipleTS=41;//Trailing Stop extern int PeriodATR=1; extern int ShiftATR=0; extern string slippage= "Slippage"; extern int Slippage=3; extern string RSI_Levels = "RSI levels"; extern double Lowlevel=30;//RSI Level low extern double Highlevel=54;//Rsi Level High extern string Indicator_Period= "Indicator period"; extern int Indicatorperiod=10;//Period Indicators extern string Bollinger_Bands= "Bollinger Bands"; extern int BBDeviation=2;//Bollinger Bands Deviation extern string Keltner_Bands= "Keltner Bands"; extern double atrmultiplier=2; extern string Envelopes= "Envelopes"; extern double EnvelopesDeviation = 0.04; // Deviation for the iEnvelopes indicator extern string Candles_Retrace= "Candles retrace"; extern int CandlesToRetrace=9; //Num.Of Candles For Divergence double lot; double MarginFree; // Free margin in percentage extern string Min_MarginLevel= " MinMarginLevel"; extern double MinMarginLevel = 100; // Lowest allowed Margin level for new positions to be opened. int last_bar = 0; double last_profit, last_lot; int last_tip; double ema0,atr0,imalow0,imahigh0,imadiff0,ema1,atr1,imalow1,imahigh1,imadiff1; extern string Volumes = "Volumes"; extern int volume1=1; extern int volume0=0; extern int adxperiod= 50; extern int adxthreshold=10; //+------------------------------------------------------------------+ // expert start function //+------------------------------------------------------------------+ int start() { //+------------------------------------------------------------------+ // Martingale (double Martingale) //+------------------------------------------------------------------+ double Lot = (AccountEquity() * 0.01 /LotFactor); if( OrdersTotal() == 0 && OrdersHistoryTotal() == 0) Lot = (AccountEquity() * 0.01 /LotFactor); else if( OrdersTotal() == 0&& OrdersHistoryTotal() > 0 ) last_history_profit(); if( last_profit < 0 ) Lot = MartingalePower*last_lot; if( last_profit > 0 ) Lot = (AccountEquity() * 0.01 /LotFactor); //+------------------------------------------------------------------+ double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; double TheStopLoss=0; double TheTakeProfit=0; //+------------------------------------------------------------------+ // Dynamic parameters //+------------------------------------------------------------------+ double atr = iATR(NULL, 0, PeriodATR, ShiftATR); double StopLoss = (atr * atrMultipleSL / Point);//Stoploss double TakeProfit =(atr * atrMultipleTP / Point);//TakeProfit double TrailingStop=(atr * atrMultipleTS / Point);//TrailingStop //+------------------------------------------------------------------+ //Calculate and check spread //+------------------------------------------------------------------+ double MaxSpreadInPoints = 30; double Spread = Ask - Bid; if(Spread>MaxSpreadInPoints*Point) return(false); //+------------------------------------------------------------------+ //MinMarginLevel //+------------------------------------------------------------------+ 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 ) { //+------------------------------------------------------------------+ //keltner Bands //+------------------------------------------------------------------+ ema0 = iMA(NULL, 0, Indicatorperiod, 0, MODE_EMA, PRICE_CLOSE, 0); atr0 = iATR(NULL, 0, Indicatorperiod, 0); imalow0 = ema0-(atr0*atrmultiplier); imahigh0 = ema0+(atr0*atrmultiplier); imadiff0 = imahigh0 - imalow0;//iMA ema1 = iMA(NULL, 0,Indicatorperiod, 0, MODE_EMA, PRICE_CLOSE, 1); atr1 = iATR(NULL, 0,Indicatorperiod, 1); imalow1 = ema1-(atr1*atrmultiplier); imahigh1 = ema1+(atr1*atrmultiplier); imadiff1 = imahigh1 - imalow1;//iMA int result=0; //+------------------------------------------------------------------+ // Here is your open buy rule //+------------------------------------------------------------------+ //Divergence RSI if( RSI()==1) //Keltner Bands if((iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,1)<imalow1)&&(iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,0)>imalow0)) //Volumes (Volumes +ADX) if((Volume[volume1]> Volume[volume0]) &&(iADX(Symbol(),0,adxperiod,PRICE_CLOSE,MODE_MAIN,0)> adxthreshold) ) //Bollinger Bands 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 //Envelopes Bands if((iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,1)< iEnvelopes ( Symbol(), PERIOD_M1, Indicatorperiod, MODE_LWMA, 0, PRICE_OPEN, EnvelopesDeviation, MODE_LOWER, 1 )) &&(iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,0)> iEnvelopes ( Symbol(), PERIOD_M1, Indicatorperiod, MODE_LWMA, 0, PRICE_OPEN, EnvelopesDeviation, MODE_LOWER, 0 ))) // Here is your open buy rule //RSI Levels if((iRSI(NULL,0,Indicatorperiod,PRICE_CLOSE,1)<Lowlevel)&&(iRSI(NULL,0,Indicatorperiod,PRICE_CLOSE,0)>Lowlevel)) if (!IsTradeContextBusy() && IsTradeAllowed()) { result=OrderSend(Symbol(),OP_BUY,Lot,Ask,Slippage,0,0,"BOLLINGER_BANDS_RSI_EA_V2",MagicNumber,0,Blue); 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 modif1=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } //+------------------------------------------------------------------+ // Here is your open Sell rule //+------------------------------------------------------------------+ //Divergences RSI if( RSI()==2)//divergence RSI //Keltner bands if((iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,1)>imahigh1)&&(iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,0)<imahigh0)) //Volume (Volumes + ADX) if((Volume[volume1]> Volume[volume0]) &&(iADX(Symbol(),0,adxperiod,PRICE_CLOSE,MODE_MAIN,0)> adxthreshold) ) //Bollinger Bands 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 //Enveloppes bandes if((iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,1)>iEnvelopes ( Symbol(), PERIOD_M1, Indicatorperiod, MODE_LWMA, 0, PRICE_OPEN, EnvelopesDeviation, MODE_UPPER,1)) &&(iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,0)<iEnvelopes ( Symbol(), PERIOD_M1, Indicatorperiod, MODE_LWMA, 0, PRICE_OPEN, EnvelopesDeviation, MODE_UPPER, 0))) // Here is your open Sell rule //Rsi Level if((iRSI(NULL,0,Indicatorperiod,PRICE_CLOSE,1)>Highlevel)&&(iRSI(NULL,0,Indicatorperiod,PRICE_CLOSE,0)<Highlevel)) if (!IsTradeContextBusy() && IsTradeAllowed()) { result=OrderSend(Symbol(),OP_SELL,Lot,Bid,Slippage,0,0,"BOLLINGER_BANDS_RSI_EA_V2",MagicNumber,0,Red); 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 modif2= OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } } //+------------------------------------------------------------------+ //| Trailing Stop //+------------------------------------------------------------------+ 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); } //+------------------------------------------------------------------+ //| Divergences RSI //+------------------------------------------------------------------+ int RSI() { for(int i=CandlesToRetrace; i>=0; i--) { if(((iRSI(Symbol(),0,Indicatorperiod,PRICE_HIGH,1)<iRSI(Symbol(),0,Indicatorperiod,PRICE_HIGH,i))&& (High[1]>High[i])) ||((iRSI(Symbol(),0,Indicatorperiod,PRICE_HIGH,1)>iRSI(Symbol(),0,Indicatorperiod,PRICE_HIGH,i))&& (High[1]<High[i]))) { return(1); Comment("The trend is up"); } else if(((iRSI(Symbol(),0,Indicatorperiod,PRICE_LOW,1)>iRSI(Symbol(),0,Indicatorperiod,PRICE_TYPICAL,i))&& (Low[1]<Low[i])) ||((iRSI(Symbol(),0,Indicatorperiod,PRICE_LOW,1)<iRSI(Symbol(),0,Indicatorperiod,PRICE_LOW,i))&& (Low[1]>Low[i]))) { return(2); Comment("The trend is down"); } } return(0); } //+------------------------------------------------------------------+ // Martingale //+------------------------------------------------------------------+ double last_history_profit() { double cpte_profit = 0; //int Magik_No = -1; if( OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY) ) { if( OrderMagicNumber() == MagicNumber ) { last_profit = OrderProfit(); last_lot = OrderLots(); last_tip = OrderType(); } } return(0); } //============================================================================
    Modifié le 2021-02-01 14:40:43 par lefeuvr3 : erreur balise
    lefeuvr3 a joint une image
    bollingerkeltnerenvelopesbandsdivrsiatrmartingale-12648
  • stevenfoarbs

    Bonjour,

    Tout d'abord félicitations, je suis impressionné par la quantité de robots que vous écrivez !!
    Celui-ci semble donner de bons résultats également sur la paire gbp/usd. J'ai néanmoins quelques fois des erreurs générés dans le journal qui indiquent "OrderModify error1" mais celui d'après passe. Est-ce aussi quelque chose que vous avez ?

    J'ai une autre question sur tous les robots que vous créez : est-ce que vous en utilisez certains en réel ? Peu -t-on vraiment espérer le même résultat qu'en démo ? (j'utilise aussi tickstory...)

    J'ai essayé de mon côté de développer un robot pour reproduire la méthode PXTR enseignée par Dimitri mais je n'obtiens pas encore de résultat assez correct...il faut que je continue d'y travailler.

    Merci encore ;)
  • lefeuvr3

    Bonjour
    Je mets le programme corrigé pour supprimer "OrderModify error1"....merci de me dire si cela a tout corrigé.
    J'utilise un compte Kamikaze en réel pour uniquement tester mes programmes...
    Je passe donc d'un robot a un autre sur ce compte....mais si je devais faire tourner un robot,de manière régulière, ,je pense que le programme "BOLLINGER_KELTNER_ENVELOPES_BANDS_DIV_RSI_ATR_MARTINGALE.mq4"; serait dans mes favoris....tout comme le SRIF-GG-3 [ https://www.forexagone.com/forum/expert-advisors-robots/srif-gg-3-24795#120686 ]
    Merci pour ton retour qui m' a été bien utile
    Gerard

    Code
    //+------------------------------------------------------------------+ //| BOLLINGER_KELTNER_ENVELOPES_BANDS_DIV_RSI_ATR_MARTINGALE.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 //+------------------------------------------------------------------+ //...EURUSD ...1MN //+------------------------------------------------------------------+ extern string Expert_Advisor= "BOLLINGER_KELTNER_ENVELOPES_BANDS_DIV_RSI_ATR_MARTINGALE.mq4"; extern int MagicNumber=01022021; extern string Lotsize_Factor = "Lotsize Factor"; extern double LotFactor =90; //Lotsize Factor extern string Martingale_Power = "Martingale Power"; extern double MartingalePower=4.5;//Martingale Power extern string Dynamic_Parameters = "Dynamic Parameters"; extern int atrMultipleSL=70;//Stop Loss extern int atrMultipleTP=6;//Take Profit extern int atrMultipleTS=41;//Trailing Stop extern int PeriodATR=1; extern int ShiftATR=0; extern string slippage= "Slippage"; extern int Slippage=3; extern string RSI_Levels = "RSI levels"; extern double Lowlevel=30;//RSI Level low extern double Highlevel=54;//Rsi Level High extern string Indicator_Period= "Indicator period"; extern int Indicatorperiod=10;//Period Indicators extern string Bollinger_Bands= "Bollinger Bands"; extern int BBDeviation=2;//Bollinger Bands Deviation extern string Keltner_Bands= "Keltner Bands"; extern double atrmultiplier=2; extern string Envelopes= "Envelopes"; extern double EnvelopesDeviation = 0.04; // Deviation for the iEnvelopes indicator extern string Candles_Retrace= "Candles retrace"; extern int CandlesToRetrace=9; //Num.Of Candles For Divergence extern double correctmodify=0.5; double lot; double MarginFree; // Free margin in percentage extern string Min_MarginLevel= " MinMarginLevel"; extern double MinMarginLevel = 100; // Lowest allowed Margin level for new positions to be opened. int last_bar = 0; double last_profit, last_lot; int last_tip; double ema0,atr0,imalow0,imahigh0,imadiff0,ema1,atr1,imalow1,imahigh1,imadiff1; extern string Volumes = "Volumes"; extern int volume1=1; extern int volume0=0; extern int adxperiod= 50; extern int adxthreshold=10; //+------------------------------------------------------------------+ // expert start function //+------------------------------------------------------------------+ int start() { //+------------------------------------------------------------------+ // Martingale (double Martingale) //+------------------------------------------------------------------+ double Lot = (AccountEquity() * 0.01 /LotFactor); if( OrdersTotal() == 0 && OrdersHistoryTotal() == 0) Lot = (AccountEquity() * 0.01 /LotFactor); else if( OrdersTotal() == 0&& OrdersHistoryTotal() > 0 ) last_history_profit(); if( last_profit < 0 ) Lot = MartingalePower*last_lot; if( last_profit > 0 ) Lot = (AccountEquity() * 0.01 /LotFactor); //+------------------------------------------------------------------+ double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; double TheStopLoss=0; double TheTakeProfit=0; //+------------------------------------------------------------------+ // Dynamic parameters //+------------------------------------------------------------------+ double atr = iATR(NULL, 0, PeriodATR, ShiftATR); double StopLoss = (atr * atrMultipleSL / Point);//Stoploss double TakeProfit =(atr * atrMultipleTP / Point);//TakeProfit double TrailingStop=(atr * atrMultipleTS / Point);//TrailingStop //+------------------------------------------------------------------+ //Calculate and check spread //+------------------------------------------------------------------+ double MaxSpreadInPoints = 30; double Spread = Ask - Bid; if(Spread>MaxSpreadInPoints*Point) return(false); //+------------------------------------------------------------------+ //MinMarginLevel //+------------------------------------------------------------------+ 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 ) { //+------------------------------------------------------------------+ //keltner Bands //+------------------------------------------------------------------+ ema0 = iMA(NULL, 0, Indicatorperiod, 0, MODE_EMA, PRICE_CLOSE, 0); atr0 = iATR(NULL, 0, Indicatorperiod, 0); imalow0 = ema0-(atr0*atrmultiplier); imahigh0 = ema0+(atr0*atrmultiplier); imadiff0 = imahigh0 - imalow0;//iMA ema1 = iMA(NULL, 0,Indicatorperiod, 0, MODE_EMA, PRICE_CLOSE, 1); atr1 = iATR(NULL, 0,Indicatorperiod, 1); imalow1 = ema1-(atr1*atrmultiplier); imahigh1 = ema1+(atr1*atrmultiplier); imadiff1 = imahigh1 - imalow1;//iMA int result=0; //+------------------------------------------------------------------+ // Here is your open buy rule //+------------------------------------------------------------------+ //Divergence RSI if( RSI()==1) //Keltner Bands if((iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,1)<imalow1)&&(iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,0)>imalow0)) //Volumes (Volumes +ADX) if((Volume[volume1]> Volume[volume0]) &&(iADX(Symbol(),0,adxperiod,PRICE_CLOSE,MODE_MAIN,0)> adxthreshold) ) //Bollinger Bands 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 //Envelopes Bands if((iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,1)< iEnvelopes ( Symbol(), PERIOD_M1, Indicatorperiod, MODE_LWMA, 0, PRICE_OPEN, EnvelopesDeviation, MODE_LOWER, 1 )) &&(iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,0)> iEnvelopes ( Symbol(), PERIOD_M1, Indicatorperiod, MODE_LWMA, 0, PRICE_OPEN, EnvelopesDeviation, MODE_LOWER, 0 ))) // Here is your open buy rule //RSI Levels if((iRSI(NULL,0,Indicatorperiod,PRICE_CLOSE,1)<Lowlevel)&&(iRSI(NULL,0,Indicatorperiod,PRICE_CLOSE,0)>Lowlevel)) if (!IsTradeContextBusy() && IsTradeAllowed()) { result=OrderSend(Symbol(),OP_BUY,Lot,Ask,Slippage,0,0,"BOLLINGER_BANDS_RSI_EA_V2",MagicNumber,0,Blue); 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 modif1=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } //+------------------------------------------------------------------+ // Here is your open Sell rule //+------------------------------------------------------------------+ //Divergences RSI if( RSI()==2)//divergence RSI //Keltner bands if((iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,1)>imahigh1)&&(iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,0)<imahigh0)) //Volume (Volumes + ADX) if((Volume[volume1]> Volume[volume0]) &&(iADX(Symbol(),0,adxperiod,PRICE_CLOSE,MODE_MAIN,0)> adxthreshold) ) //Bollinger Bands 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 //Enveloppes bandes if((iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,1)>iEnvelopes ( Symbol(), PERIOD_M1, Indicatorperiod, MODE_LWMA, 0, PRICE_OPEN, EnvelopesDeviation, MODE_UPPER,1)) &&(iMA(NULL,PERIOD_M1,1,0,MODE_EMA,PRICE_CLOSE,0)<iEnvelopes ( Symbol(), PERIOD_M1, Indicatorperiod, MODE_LWMA, 0, PRICE_OPEN, EnvelopesDeviation, MODE_UPPER, 0))) // Here is your open Sell rule //Rsi Level if((iRSI(NULL,0,Indicatorperiod,PRICE_CLOSE,1)>Highlevel)&&(iRSI(NULL,0,Indicatorperiod,PRICE_CLOSE,0)<Highlevel)) if (!IsTradeContextBusy() && IsTradeAllowed()) { result=OrderSend(Symbol(),OP_SELL,Lot,Bid,Slippage,0,0,"BOLLINGER_BANDS_RSI_EA_V2",MagicNumber,0,Red); 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 modif2= OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } } //+------------------------------------------------------------------+ //| Trailing Stop //+------------------------------------------------------------------+ 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()+ correctmodify * Point<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()-correctmodify*Point>(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); } //+------------------------------------------------------------------+ //| Divergences RSI //+------------------------------------------------------------------+ int RSI() { for(int i=CandlesToRetrace; i>=0; i--) { if(((iRSI(Symbol(),0,Indicatorperiod,PRICE_HIGH,1)<iRSI(Symbol(),0,Indicatorperiod,PRICE_HIGH,i))&& (High[1]>High[i])) ||((iRSI(Symbol(),0,Indicatorperiod,PRICE_HIGH,1)>iRSI(Symbol(),0,Indicatorperiod,PRICE_HIGH,i))&& (High[1]<High[i]))) { return(1); Comment("The trend is up"); } else if(((iRSI(Symbol(),0,Indicatorperiod,PRICE_LOW,1)>iRSI(Symbol(),0,Indicatorperiod,PRICE_TYPICAL,i))&& (Low[1]<Low[i])) ||((iRSI(Symbol(),0,Indicatorperiod,PRICE_LOW,1)<iRSI(Symbol(),0,Indicatorperiod,PRICE_LOW,i))&& (Low[1]>Low[i]))) { return(2); Comment("The trend is down"); } } return(0); } //+------------------------------------------------------------------+ // Martingale //+------------------------------------------------------------------+ double last_history_profit() { double cpte_profit = 0; //int Magik_No = -1; if( OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY) ) { if( OrderMagicNumber() == MagicNumber ) { last_profit = OrderProfit(); last_lot = OrderLots(); last_tip = OrderType(); } } return(0); } //============================================================================
  • lefeuvr3

    La correction au fait est dans le Trailing Stop...[ correctmodify * Point ] qui est ajouté ou soustrait
  • stevenfoarbs

    Merci pour le retour rapide ! en effet la modification corrige le problème d'order modify.
    En ce qui concerne le robot SRIF-GG-3, je l'ai testé aussi sur ces 6 derniers mois en eur/usd mais il semble donner des résultats moins constants que celui-ci.
    Je me demandais si le nombre assez important d'order modify pouvait poser un problème au niveau du broker ?
  • lefeuvr3

    Pour le moment ,je n'ai jamais eu de problème avec mon Broker Activtrades, concernant les order modify.
    Bonne soirée
    Gerard
  • stevenfoarbs

    Bonsoir Gérard,
    Je viens de le retester sur une durée plus longue (les 12 derniers mois) sur du GBP/USD : bizarrement au mois de mars ça ne se passe pas bien et dans le journal, plusieurs alertes s'affichent indiquant que le Free Margin en question est plus bas que le MinMarginLevel... Cela fini ainsi par un capital à 0. Si je commence l'analyse après mars jusqu'à aujourd'hui tout se passe bien. Une idée du problème ?
    Voici plus de détails si vous souhaitez reproduire le problème à la même date (en mars)
    stevenfoarbs a joint une image
    bollingerkeltnerenvelopesbandsdivrsiatrmartingale-12691
  • lefeuvr3

    Bonjour Steven
    En fait ,les paramètres mis en place, sont évalués pour EURUSD 1 mn.
    Pour GBPUSD ,il faudrait ,par un backtest, les réévalués ,après avoir diminué la taille des lots en mettant extern double LotFactor =300; //Lotsize Factor
    Modifié le 2021-02-11 08:01:15 par lefeuvr3 : faute de frappe
  • stevenfoarbs

    J'obtiens le même résultat en mettant 300.J'ai essayé d'autres valeurs mais ça ne semble pas avoir d'influences...
  • lefeuvr3

    J'ai fait une rapide evaluation avec GBPUSD.1 Mn.....j' ai change quelques parametres comme suit
    lefeuvr3 a joint une image
    bollingerkeltnerenvelopesbandsdivrsiatrmartingale-12699
  • stevenfoarbs

    Je confirme ça fonctionne beaucoup mieux, merci Gérard !