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

RSI a modifier

  • massine

    Bonjour tout le monde,

    J'utilise une stratégie a base du RSI qui m'alerte aux niveaux 20 & 80.
    Je voudrai filtrer ces alertes en ne recevant que les alertes en fonctions de la moyenne mobile EMA 50.
    1) activer les alertes seulement quand RSI supérieur 80 et prix inferieur a EMA 50
    2) activer les alertes seulement quand RSI inferieur 20 et prix supérieur a EMA 50

    Merci d'avance pour votre aide
  • lefeuvr3

    En utilisant un Builder ,cela peut être réalisé en moins d'une heure

    https://www.forexeadvisor.com/expert_generator.aspx
  • lefeuvr3

    Petit programme utilisant la strategie sur GBPUSD 1 minute apres backtest pour ajuster les parametres
    Code
    //+------------------------------------------------------------------+ //| RSI_EMA_EA_MASSINE | //| GBPUSD 1 MN //| 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 //+------------------------------------------------------------------+ //----------------------- Include files ------------------------------------------------------------ #include <stdlib.mqh> // "stdlib.mqh" or "<sdlib.mqh> #include <stderror.mqh> // "stderror.mqh" or <stderror.mqh> //+------------------------------------------------------------------+ extern int MagicNumber=10001; extern double Lots =0.01; extern double StopLoss=190; extern double TakeProfit=130; extern int TrailingStop=30; extern int Slippage=3; extern int LotFactor=260; extern int PeriodEMA=45; extern int PeriodRSI=10; extern int LowLevel=20; extern int HighLevel=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; if((iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,1)<HighLevel)&&(iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,0)>HighLevel)&&(iMA(NULL,0,PeriodEMA,1,MODE_EMA,PRICE_CLOSE,1)>Close[1])&&(iMA(NULL,0,PeriodEMA,0,MODE_EMA,PRICE_CLOSE,0)<Close[0])) // Here is your open buy rule { result=OrderSend(Symbol(),OP_BUY,(AccountBalance() * 0.01 /LotFactor),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 modif4= OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } if((iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,1)>LowLevel)&&(iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,0)<LowLevel)&&(iMA(NULL,0,PeriodEMA,1,MODE_EMA,PRICE_CLOSE,1)>Close[1])&&(iMA(NULL,0,PeriodEMA,0,MODE_EMA,PRICE_CLOSE,0)>Close[0])) // Here is your open Sell rule { result=OrderSend(Symbol(),OP_SELL,(AccountBalance() * 0.01 /LotFactor),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 modif3=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 modif2= 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 modif1= 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); }
    lefeuvr3 a joint une image
    rsi-a-modifier-13723
  • lefeuvr3

    Petite modification dans le programme pour avoir soit une alerte soit une prise de position de trading automatique quand les conditions sont réunies

    Code
    //+------------------------------------------------------------------+ //| RSI_EMA_EA_MASSINE | //| GBPUSD 1 MN //| 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 //+------------------------------------------------------------------+ //----------------------- Include files ------------------------------------------------------------ #include <stdlib.mqh> // "stdlib.mqh" or "<sdlib.mqh> #include <stderror.mqh> // "stderror.mqh" or <stderror.mqh> //+------------------------------------------------------------------+ extern int MagicNumber=10001; extern double Lots =0.01; extern double StopLoss=190; extern double TakeProfit=130; extern int TrailingStop=30; extern int Slippage=3; extern int LotFactor=260; extern int PeriodEMA=45; extern int PeriodRSI=10; extern int LowLevel=20; extern int HighLevel=50; extern bool ShowAlerts =false; //Hide or show labels //+------------------------------------------------------------------+ // expert start function //+------------------------------------------------------------------+ int start() { double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; //Alert("OrderSend"); double TheStopLoss=0; double TheTakeProfit=0; if( TotalOrdersCount()==0 ) { int result=0; if((iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,1)<HighLevel)&&(iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,0)>HighLevel)&&(iMA(NULL,0,PeriodEMA,1,MODE_EMA,PRICE_CLOSE,1)>Close[1])&&(iMA(NULL,0,PeriodEMA,0,MODE_EMA,PRICE_CLOSE,0)<Close[0])) // Here is your open buy rule { if( ShowAlerts == true ) Alert("hello BUY from my EA!"); else result=OrderSend(Symbol(),OP_BUY,(AccountBalance() * 0.01 /LotFactor),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 modif4= OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } if((iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,1)>LowLevel)&&(iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,0)<LowLevel)&&(iMA(NULL,0,PeriodEMA,1,MODE_EMA,PRICE_CLOSE,1)>Close[1])&&(iMA(NULL,0,PeriodEMA,0,MODE_EMA,PRICE_CLOSE,0)>Close[0])) // Here is your open Sell rule { if( ShowAlerts == true ) Alert("hello SELL from my EA!"); else result=OrderSend(Symbol(),OP_SELL,(AccountBalance() * 0.01 /LotFactor),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 modif3=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 modif2= 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 modif1= 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); }
  • lefeuvr3

    Nouvelle version où les positions sont clôturées à l'inversion des indicateurs
    Code
    //+------------------------------------------------------------------+ //| RSI_EMA_RSI_MASSINE_CLOSE_BUY_SELL.mq4 | //| GBPUSD 1 MN //| 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 //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //----------------------- Include files ------------------------------------------------------------ #include <stdlib.mqh> // "stdlib.mqh" or "<sdlib.mqh> #include <stderror.mqh> // "stderror.mqh" or <stderror.mqh> //+------------------------------------------------------------------+ extern int MagicNumber=10001; //extern double Lots =0.01; extern double StopLoss=200; extern double TakeProfit=130; extern int TrailingStop=30; extern int Slippage=3; extern int LotFactor=200; extern int PeriodEMA=30; extern int PeriodRSI=35; extern int LowLevel=50; extern int HighLevel=50; extern bool ShowAlerts =false; //Hide or show labels //+------------------------------------------------------------------+ // 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((iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,1)<HighLevel)&&(iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,0)>HighLevel)&&(iMA(NULL,0,PeriodEMA,1,MODE_EMA,PRICE_CLOSE,1)>Close[1])&&(iMA(NULL,0,PeriodEMA,0,MODE_EMA,PRICE_CLOSE,0)<Close[0])) // Here is your open buy rule { if( ShowAlerts == true ) Alert("hello BUY from my EA!"); else result=OrderSend(Symbol(),OP_BUY,(AccountBalance() * 0.01 /LotFactor),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 modif4= OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } if((iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,1)>LowLevel)&&(iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,0)<LowLevel)&&(iMA(NULL,0,PeriodEMA,1,MODE_EMA,PRICE_CLOSE,1)>Close[1])&&(iMA(NULL,0,PeriodEMA,0,MODE_EMA,PRICE_CLOSE,0)>Close[0])) // Here is your open Sell rule { if( ShowAlerts == true ) Alert("hello SELL from my EA!"); else result=OrderSend(Symbol(),OP_SELL,(AccountBalance() * 0.01 /LotFactor),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 modif3=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((iRSI(NULL,0,14,PRICE_CLOSE,1)>20)&&(iRSI(NULL,0,14,PRICE_CLOSE,0)<20)&&(iMA(NULL,0,14,1,MODE_EMA,PRICE_CLOSE,1)<Close[1])&&(iMA(NULL,0,14,0,MODE_EMA,PRICE_CLOSE,0)>Close[0])) //here is your close buy rule { bool modif6= OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage,Red); } if(TrailingStop>0) { if(Bid-OrderOpenPrice()>MyPoint*TrailingStop) { if(OrderStopLoss()<Bid-MyPoint*TrailingStop) { bool modif2= OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green); return(0); } } } } else { if((iRSI(NULL,0,14,PRICE_CLOSE,1)<80)&&(iRSI(NULL,0,14,PRICE_CLOSE,0)>80)&&(iMA(NULL,0,14,1,MODE_EMA,PRICE_CLOSE,1)>Close[1])&&(iMA(NULL,0,14,1,MODE_EMA,PRICE_CLOSE,0)<Close[0])) // here is your close sell rule { bool modif5= OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage,Red); } if(TrailingStop>0) { if((OrderOpenPrice()-Ask)>(MyPoint*TrailingStop)) { if((OrderStopLoss()>(Ask+MyPoint*TrailingStop)) || (OrderStopLoss()==0)) { bool modif1= 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 2021-10-24 18:06:34 par lefeuvr3 : REDONDANCE
  • lefeuvr3

    resultat backtest
    lefeuvr3 a joint une image
    rsi-a-modifier-13724