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

SVE RSI I FISH SYMPHO_v4

  • lefeuvr3

    Code
    //+------------------------------------------------------------------+ //| SVE RSI I FISH SYMPHO_v4.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=20190815; double lot; extern double LotFactor =50; //lotsize factor extern double StopLoss=0; extern double TakeProfit=10; extern int TrailingStop=10; extern int Slippage=3; extern int RsiPeriod=72; extern int EmaPeriod=144; extern int LevelUp=60; extern int LevelDown=20; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- return(0); } //+------------------------------------------------------------------+ // expert start function //+------------------------------------------------------------------+ int start() { int MyPoint=1; if(Digits==3 || Digits==5) MyPoint=10; double SVE_T1 = iCustom(NULL,0,"SVE_RSI_I-Fish",RsiPeriod,EmaPeriod,0,1); double SVE_T2 = iCustom(NULL,0,"SVE_RSI_I-Fish",RsiPeriod,EmaPeriod,0,2); double TheStopLoss=0; double TheTakeProfit=0; if( TotalOrdersCount()==0 ) { int result=0; if((SVE_T2<LevelDown)&&(SVE_T1>LevelDown)&&(SVE_T1<LevelUp)) // Here is your open buy rule { if(CheckMoneyForTrade(NULL,NR(Lot_Volume()),OP_BUY)) result=OrderSend(Symbol(),OP_BUY, NR(Lot_Volume()),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*_Point; if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint*_Point; if(OrderSelect(result, SELECT_BY_TICKET)) bool modif1= OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } if((SVE_T2>LevelUp)&&(SVE_T1<LevelUp)&&(SVE_T1>LevelDown)) // Here is your open Sell rule { if(CheckMoneyForTrade(NULL,NR(Lot_Volume()),OP_SELL)) result=OrderSend(Symbol(),OP_SELL, NR(Lot_Volume()),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*_Point; if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint*_Point; 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(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) { if(OrderType()==OP_BUY) { if((SVE_T2<LevelUp)&&(SVE_T1>LevelUp)) //here is your close buy rule { bool modif3= OrderClose(OrderTicket(),OrderLots(),MarketInfo(_Symbol,MODE_BID),Slippage,Red); } if(TrailingStop>0) { TrailingAlls(TrailingStop, MyPoint); } } else if(OrderType()==OP_SELL) { if((SVE_T2>LevelDown)&&(SVE_T1<LevelDown)) // here is your close sell rule { bool modif5= OrderClose(OrderTicket(),OrderLots(),MarketInfo(_Symbol,MODE_ASK),Slippage,Red); } if(TrailingStop>0) { TrailingAlls(TrailingStop, MyPoint); } } } } return(0); } int TotalOrdersCount() { int result=0; for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS ,MODE_TRADES) == True) if(OrderMagicNumber()==MagicNumber) result++; } return (result); } void TrailingAlls(double trail, int t) { if(trail==0) return; //---- double stopcal=0; int trade=0; int trades=OrdersTotal(); double profitcalc=0; bool Order_Modif=False; for(trade=0;trade<trades;trade++) { if(OrderSelect(trade,SELECT_BY_POS,MODE_TRADES)==False) { Print("Select Failed"); continue; } if(OrderSelect(trade,SELECT_BY_POS,MODE_TRADES)==True) { if(OrderSymbol()==Symbol()) { //continue; //LONG if(OrderType()==OP_BUY && (OrderMagicNumber()==MagicNumber))// && OrderStopLoss()>=OrderOpenPrice()) { //Print("Number = " + trade); if(OrderStopLoss()<OrderOpenPrice() && Bid>OrderOpenPrice()+(trail*t*_Point) && CheckStopLoss_Takeprofit(OP_BUY,OrderOpenPrice(),OrderTakeProfit())) { Order_Modif=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Blue); if(Order_Modif==True) Print("BE BUY"); continue; } stopcal=NormalizeDouble((OrderStopLoss()+(trail*t*_Point)), _Digits); profitcalc=OrderTakeProfit(); if(OrderStopLoss()>=OrderOpenPrice() && stopcal<Bid && CheckStopLoss_Takeprofit(OP_BUY,NormalizeDouble(OrderStopLoss()+(trail/2*t*Point), _Digits),profitcalc)) { Order_Modif=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(OrderStopLoss()+(trail/2*t*Point), _Digits),profitcalc,0,Blue); if(Order_Modif==False) Print("Modif failed"); //continue; } }//LONG //Shrt if(OrderType()==OP_SELL && (OrderMagicNumber()==MagicNumber))// && OrderStopLoss()<=OrderOpenPrice()) { //Print("Number = " + trade); if(OrderStopLoss()>OrderOpenPrice() && Ask<OrderOpenPrice()-(trail*t*_Point) && CheckStopLoss_Takeprofit(OP_SELL,OrderOpenPrice(),OrderTakeProfit())) { Order_Modif=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Blue); if(Order_Modif==True) Print("BE SELL"); continue; } stopcal=NormalizeDouble((OrderStopLoss()-(trail*t*_Point)), _Digits); profitcalc=OrderTakeProfit(); if(OrderStopLoss()<=OrderOpenPrice() && stopcal>Ask && CheckStopLoss_Takeprofit(OP_SELL,NormalizeDouble(OrderStopLoss()-(trail/2*t*Point), _Digits),profitcalc)) { Order_Modif=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(OrderStopLoss()-(trail/2*t*Point), _Digits),profitcalc,0,Red); if(Order_Modif==False) Print("Modif failed"); //continue; } } } } }//Shrt } bool CheckStopLoss_Takeprofit(ENUM_ORDER_TYPE type, double SL, double TP) { //--- get the SYMBOL_TRADE_STOPS_LEVEL level int stops_level=(int)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_STOPS_LEVEL); //--- bool SL_check=false,TP_check=false; //--- check only two order types switch(type) { //--- Buy operation case ORDER_TYPE_BUY: { //--- check the StopLoss SL_check=(Bid-SL>stops_level*10*_Point); if(SL==0) SL_check=True; //--- check the TakeProfit TP_check=(TP-Bid>stops_level*10*_Point); if(TP==0) TP_check=True; //--- return the result of checking return(SL_check&&TP_check); } //--- Sell operation case ORDER_TYPE_SELL: { //--- check the StopLoss SL_check=(SL-Ask>stops_level*10*_Point); if(SL==0) SL_check=True; //--- check the TakeProfit TP_check=(Ask-TP>stops_level*10*_Point); if(TP==0) TP_check=True; //--- return the result of checking return(TP_check&&SL_check); } break; } //--- a slightly different function is required for pending orders return false; } bool CheckMoneyForTrade(string symb,double lots,int type) { double free_margin=AccountFreeMarginCheck(symb,type, lots); //-- if there is not enough money if(free_margin<0) { string oper=(type==OP_BUY)? "Buy":"Sell"; //fPrint("Not enough money for ", oper," ",lots, " ", symb, " Error code=",GetLastError()); return(false); } //--- checking successful return(true); } // //+------------------------------------------------------------------+ //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
    sve-rsi-i-fish-symphov4-11584
  • lefeuvr3

    Je pense que le programme peut être amélioré et simplifié

    Les backtests sont longs car le programme utilise un " i custom " qui consomme beaucoup de ressource
  • lefeuvr3

    Modification des parametres
    lefeuvr3 a joint une image
    sve-rsi-i-fish-symphov4-11614
  • lefeuvr3

    Utilisation d'une nouvelle maquette....il ne s'agit que d'une variante que j'ai essaye pour faire des backtests plus rapides...malheureusement les backtest prennent autant de temps que la version précédente.

    L’idéal serait d’intégrer l'indicateur dans le programme pour éviter d'utiliser... 'iCustom"........ si quelqu'un sait le faire ,je suis preneur ....moi après plusieurs tentatives ,je n'y suis pas arrivé !

    Code
    //+------------------------------------------------------------------+ //| SVE RSI I FISH SYMPHO PARAMETRES.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 string Name_EA ="SVE RSI I FISH SYMPHO PARAMETRES"; extern int MagicNumber=05112019; extern double StopLoss=30; extern double TakeProfit=00; extern int TrailingStop=20; extern int Slippage=3; extern int RsiPeriod=72; extern int EmaPeriod=144; extern int LevelUp=60; extern int LevelDown=20; double lot; extern double LotFactor =100; //lotsize factor double TP=0,SL=0,TR; extern int size = 0; int shiftOpenBuy =0; int shiftCloseBuy =1; int shiftOpenSell =0; int shiftCloseSell =1; double point = MarketInfo(Symbol(), MODE_POINT); int spread = MarketInfo(Symbol(), MODE_SPREAD); //+------------------------------------------------------------------+ //| Hidden StopLoss Calculations | //+------------------------------------------------------------------+ void StpLoss() { double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; TP=TakeProfit*MyPoint; SL=StopLoss*MyPoint; double OrdP=0,OrdTP=0,OrdSL=0; for(int i=0; i<OrdersTotal(); i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) if(OrderMagicNumber()==MagicNumber && Symbol()==OrderSymbol()) { OrdP=OrderProfit()-MathAbs(OrderSwap())-MathAbs(OrderCommission()); OrdSL=(-1)*SL*OrderLots()*MarketInfo(OrderSymbol(),MODE_TICKVALUE)/Point; OrdTP=TP*OrderLots()*MarketInfo(OrderSymbol(),MODE_TICKVALUE)/Point; if(OrdP>OrdTP || OrdP<OrdSL) { if(OrderType()==OP_BUY) bool OrdClP=OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,clrGreen); if(OrderType()==OP_SELL) bool OrdClL=OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,clrYellow); } } } } //+------------------------------------------------------------------+ // expert start function //+------------------------------------------------------------------+ int start() { double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; double SVE_T1 = iCustom(NULL,0,"SVE_RSI_I-Fish",RsiPeriod,EmaPeriod,0,1); double SVE_T2 = iCustom(NULL,0,"SVE_RSI_I-Fish",RsiPeriod,EmaPeriod,0,2); double TheStopLoss=0; double TheTakeProfit=0; if( TotalOrdersCount()==0 ) { int result=0; //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ // Here is your open buy rule//Ici votre strategie d'achat if((SVE_T2<LevelDown)&&(SVE_T1>LevelDown)&&(SVE_T1<LevelUp)) //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ { if (!IsTradeContextBusy() && IsTradeAllowed()) result=OrderSend(Symbol(),OP_BUY, NR(Lot_Volume()),Ask,Slippage,0,0,"SVE RSI I FISH SYMPHO PARAMETRES",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((SVE_T2>LevelUp)&&(SVE_T1<LevelUp)&&(SVE_T1>LevelDown)) //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ { if (!IsTradeContextBusy() && IsTradeAllowed()) result=OrderSend(Symbol(),OP_SELL, NR(Lot_Volume()),Bid,Slippage,0,0,"SVE RSI I FISH SYMPHO PARAMETRES",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((SVE_T2>LevelUp)&&(SVE_T1<LevelUp)&&(SVE_T1>LevelDown)) //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ { 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((SVE_T2<LevelDown)&&(SVE_T1>LevelDown)&&(SVE_T1<LevelUp)) //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ { 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); } //+------------------------------------------------------------------+ //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); } //+------------------------------------------------------------------+
    Modifié le 2019-11-05 08:38:35 par lefeuvr3 : probleme de balises
    lefeuvr3 a joint une image
    sve-rsi-i-fish-symphov4-11828
  • lefeuvr3

    A paramètres équivalents, la nouvelle maquette est bien plus performante en terme de résultats... 42 €uros contre 28 €uros