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

SRIF-GG-3

  • lefeuvr3

    Toute amélioration serait bienvenue

    Code
    //+------------------------------------------------------------------+ //| SRIF-GG-3.mq4 | //| Copyright 2020, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //...EURUSD ...1MN //+------------------------------------------------------------------+ extern int MagicNumber=06112020; extern double StopLoss=80; extern double TakeProfit=0; extern int TrailingStop=40; extern int Slippage=3; extern double LotFactor =90; //lotsize int shift0=0; int shift1=1; int volume1=1; int volume0=0; extern int adxperiod= 52; extern int adxthreshold=23; extern int rsiperiodlow=2; extern int rsiperiodhigh=2; extern int rsiperiodclose=9; extern double multiplicateur=12; int timeframe = PERIOD_M1; double lot; double MarginFree; // Free margin in percentage extern double MinMarginLevel = 100; // Lowest allowed Margin level for new positions to be opened. double wma0L,wma1L,wma2L,wma3L,wma4L,wma5L,wma6L,wma7L,wma8L,wma9L; double wma0H,wma1H,wma2H,wma3H,wma4H,wma5H,wma6H,wma7H,wma8H,wma9H; double rainbow[],rsi[],srsi[],fish[]; double ema0[],ema1[]; double rainbowL,rainbowH,rainbowC; double rainbowC1; double wma0C ,wma1C,wma2C ,wma3C,wma4C ,wma5C ,wma6C ,wma7C ,wma8C ,wma9C; double wma0C1 ,wma1C1,wma2C1 ,wma3C1,wma4C1 ,wma5C1 ,wma6C1 ,wma7C1 ,wma8C1 ,wma9C1; double rsiL,rsiH; double srsiL,srsiH,srsiC; double rsiC1; double srsiC1; double fishC1; double fishL,fishH; double levelup; double leveldown; double fishC; double rsiCS,rsiCL,rsiLL,rsiHS,rsiHL,rsiLS; double rsiC; double imalow ; double imahigh ; double imadiff ; double isbidgreaterthanima ; //+------------------------------------------------------------------+ // 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; //+---------------------------------------- //+---------------------------------------- wma0C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,1); wma1C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,2); wma2C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,3); wma3C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,4); wma4C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,5); wma5C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,6); wma6C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,7); wma7C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,8); wma8C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,9); wma9C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,10); rainbowC1=(5*wma0C1+4*wma1C1+3*wma2C1+2*wma3C1+wma4C1+wma5C1+wma6C1+wma7C1+wma8C1+wma9C1)/20; rsiC1=multiplicateur*0.1 *((iRSI(Symbol(), timeframe,rsiperiodclose,PRICE_CLOSE,1))*rainbowC1)-50; srsiC1=rsiC1+rsiC1-rainbowC1; fishC1=(((MathExp(2*srsiC1)-1)/(MathExp(2*srsiC1)+1)+1)*50); //+------------------------------ //+------------------------------ imalow = ((MathExp(2*srsiC)-1)/(MathExp(2*srsiC)+1)+1)*50; imahigh = ((MathExp(2*srsiC)-1)/(MathExp(2*srsiC)+1)+1)*50; imalow = fishL; imahigh = fishH; imadiff = imahigh-imalow ; isbidgreaterthanima =(fishC >= imahigh + imadiff / 2.0) ; //+---------------------------------------- //+---------------------------------------- wma0C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,0); wma1C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,1); wma2C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,2); wma3C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,3); wma4C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,4); wma5C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,5); wma6C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,6); wma7C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,7); wma8C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,8); wma9C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,9); rainbowC=(5*wma0C+4*wma1C+3*wma2C+2*wma3C+wma4C+wma5C+wma6C+wma7C+wma8C+wma9C)/20; rsiC=multiplicateur*0.1 *((iRSI(Symbol(), timeframe,rsiperiodclose,PRICE_CLOSE,0))*rainbowC)-50; srsiC=rsiC+rsiC-rainbowC; fishC=(((MathExp(2*srsiC)-1)/(MathExp(2*srsiC)+1)+1)*50); //+------------------------------ //+------------------------------ imalow = ((MathExp(2*srsiC)-1)/(MathExp(2*srsiC)+1)+1)*50; imahigh = ((MathExp(2*srsiC)-1)/(MathExp(2*srsiC)+1)+1)*50; //+------------------------------ //+------------------------------ if(((fishC1 <20 )&& (fishC >20) &&(Volume[volume1]> Volume[volume0]) &&(iADX(Symbol(),0,adxperiod,PRICE_CLOSE,MODE_MAIN,0)> adxthreshold)) ) { if (!IsTradeContextBusy() && IsTradeAllowed()) result=OrderSend(Symbol(),OP_BUY,NR(Lot_Volume()),Ask,Slippage,0,0,"BOLLINGER_BANDS_EA",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); } if(((fishC1 > 80)&&(fishC<80) &&(Volume[volume1]> Volume[volume0]) &&(iADX(Symbol(),0,adxperiod,PRICE_CLOSE,MODE_MAIN,0)> adxthreshold) )) { if (!IsTradeContextBusy() && IsTradeAllowed()) result=OrderSend(Symbol(),OP_SELL,NR(Lot_Volume()),Bid,Slippage,0,0,"BOLLINGER_BANDS_EA",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
    srif-gg-3-12465
  • lefeuvr3

    RESULTATS APRES BACKTEST....NOUVEAUX PARAMETRES
    lefeuvr3 a joint une image
    srif-gg-3-12466
  • (invité) — en réponse à lefeuvr3 dans son message #120097

    Hello !
    Comment peut-on changer "level high" et "level low" ? Je ne vois ces réglages nul part.
  • lefeuvr3

    Corrigé
    Code
    //+------------------------------------------------------------------+ //| SRIF-GG-3.mq4 | //| Copyright 2020, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //...EURUSD ...1MN //+------------------------------------------------------------------+ extern int MagicNumber=06112020; extern double StopLoss=80; extern double TakeProfit=100; extern int TrailingStop=40; extern int Slippage=3; extern double LotFactor =90; //lotsize int shift0=0; int shift1=1; int volume1=1; int volume0=0; extern int LevelHigh=80; extern int LevelLow=5; extern int adxperiod= 52; extern int adxthreshold=23; extern int rsiperiodclose=9; extern double multiplicateur=12; int timeframe = PERIOD_M1; double lot; double MarginFree; // Free margin in percentage extern double MinMarginLevel = 100; // Lowest allowed Margin level for new positions to be opened. double wma0L,wma1L,wma2L,wma3L,wma4L,wma5L,wma6L,wma7L,wma8L,wma9L; double wma0H,wma1H,wma2H,wma3H,wma4H,wma5H,wma6H,wma7H,wma8H,wma9H; double rainbow[],rsi[],srsi[],fish[]; double ema0[],ema1[]; double rainbowL,rainbowH,rainbowC; double rainbowC1; double wma0C ,wma1C,wma2C ,wma3C,wma4C ,wma5C ,wma6C ,wma7C ,wma8C ,wma9C; double wma0C1 ,wma1C1,wma2C1 ,wma3C1,wma4C1 ,wma5C1 ,wma6C1 ,wma7C1 ,wma8C1 ,wma9C1; double rsiL,rsiH; double srsiL,srsiH,srsiC; double rsiC1; double srsiC1; double fishC1; double fishL,fishH; double levelup; double leveldown; double fishC; double rsiCS,rsiCL,rsiLL,rsiHS,rsiHL,rsiLS; double rsiC; double imalow ; double imahigh ; double imadiff ; double isbidgreaterthanima ; //+------------------------------------------------------------------+ // 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; //+---------------------------------------- //+---------------------------------------- wma0C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,1); wma1C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,2); wma2C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,3); wma3C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,4); wma4C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,5); wma5C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,6); wma6C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,7); wma7C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,8); wma8C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,9); wma9C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,10); rainbowC1=(5*wma0C1+4*wma1C1+3*wma2C1+2*wma3C1+wma4C1+wma5C1+wma6C1+wma7C1+wma8C1+wma9C1)/20; rsiC1=multiplicateur*0.1 *((iRSI(Symbol(), timeframe,rsiperiodclose,PRICE_CLOSE,1))*rainbowC1)-50; srsiC1=rsiC1+rsiC1-rainbowC1; fishC1=(((MathExp(2*srsiC1)-1)/(MathExp(2*srsiC1)+1)+1)*50); //+------------------------------ //+------------------------------ imalow = ((MathExp(2*srsiC)-1)/(MathExp(2*srsiC)+1)+1)*50; imahigh = ((MathExp(2*srsiC)-1)/(MathExp(2*srsiC)+1)+1)*50; imalow = fishL; imahigh = fishH; imadiff = imahigh-imalow ; isbidgreaterthanima =(fishC >= imahigh + imadiff / 2.0) ; //+---------------------------------------- //+---------------------------------------- wma0C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,0); wma1C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,1); wma2C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,2); wma3C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,3); wma4C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,4); wma5C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,5); wma6C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,6); wma7C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,7); wma8C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,8); wma9C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,9); rainbowC=(5*wma0C+4*wma1C+3*wma2C+2*wma3C+wma4C+wma5C+wma6C+wma7C+wma8C+wma9C)/20; rsiC=multiplicateur*0.1 *((iRSI(Symbol(), timeframe,rsiperiodclose,PRICE_CLOSE,0))*rainbowC)-50; srsiC=rsiC+rsiC-rainbowC; fishC=(((MathExp(2*srsiC)-1)/(MathExp(2*srsiC)+1)+1)*50); //+------------------------------ //+------------------------------ imalow = ((MathExp(2*srsiC)-1)/(MathExp(2*srsiC)+1)+1)*50; imahigh = ((MathExp(2*srsiC)-1)/(MathExp(2*srsiC)+1)+1)*50; //+------------------------------ //+------------------------------ if(((fishC1 <LevelLow )&& (fishC >LevelLow) &&(Volume[volume1]> Volume[volume0]) &&(iADX(Symbol(),0,adxperiod,PRICE_CLOSE,MODE_MAIN,0)> adxthreshold)) ) { if (!IsTradeContextBusy() && IsTradeAllowed()) result=OrderSend(Symbol(),OP_BUY,NR(Lot_Volume()),Ask,Slippage,0,0,"BOLLINGER_BANDS_EA",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); } if(((fishC1 > LevelHigh)&&(fishC<LevelHigh) &&(Volume[volume1]> Volume[volume0]) &&(iADX(Symbol(),0,adxperiod,PRICE_CLOSE,MODE_MAIN,0)> adxthreshold) )) { if (!IsTradeContextBusy() && IsTradeAllowed()) result=OrderSend(Symbol(),OP_SELL,NR(Lot_Volume()),Bid,Slippage,0,0,"BOLLINGER_BANDS_EA",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); }
  • Mikiburger

    Bonjour Lefeuvr3,

    J'ai un problème quasi systématique avec vos robots.
    Je n'arrive pas à avoir les même résultats backtest que vous.

    Je ne dit pas que l'erreur est de votre coté mais j'aimerai comprendre cette différence.
    Je n'ai pas une bonne qualité de modelage mais quand même cette différence est trop importante pour que ça vienne de là.

    Essayez vous vos robots en réel ou en démo ?
    Avez vous les mêmes résultats si vous backtestez ensuite la période où le robot a tourné en compte démo ?

    Bien à vous,
    Mikiburger a joint une image
    srif-gg-3-12472
  • lefeuvr3

    Mon robot tourne sur MT4
    Celui qui tourne en ce moment ,en réel sur ma plateforme est "Bollinger Band ea"
    Pour que le modelage soit parfait à 99.9% j'utilise Tick Story
    Avec un modelage ,comme je le vois de 25% ,les résultats sont totalement différents.
  • Mikiburger

    OK, merci pour l'info.
    Je vais voir pour améliorer mes BT.
  • Matthieuw31 — en réponse à lefeuvr3 dans son message #120128

    Bonjour,

    Quel pack de Tickstory avez-vous pris?
    J'ai seulement essayé le pack gratuit mais j'avais laissé tomber car je n'arrivais pas à importer les données sur MT4. Ca n'avait pas l'air sorcier, mais ça ne fonctionnait pas.
  • lefeuvr3

    J'ai le pack Tickstory gratuit qui me suffit...je l'utilise sur 6 mois sinon ,je trouve que c'est trop long
    il faut utiliser a plusieurs reprise le clic droit de la souris ,-pour importer puis en bas -pour lancer
  • Matthieuw31

    D'accord, merci, je réessaierai alors.
  • lefeuvr3

    Version avec petite Martingale pour amelioration des gains

    Code
    //+------------------------------------------------------------------+ //| SRIF-GG-3-MARTINGALE.mq4 | //| Copyright 2020, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2021, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict //+------------------------------------------------------------------+ //| SRIF-GG-3.mq4 | //| Copyright 2020, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //...EURUSD ...1MN //+------------------------------------------------------------------+ extern int MagicNumber=06112020; extern double StopLoss=80; extern double TakeProfit=100; extern int TrailingStop=40; extern int Slippage=3; extern double LotFactor =250; //lotsize int shift0=0; int shift1=1; int volume1=1; int volume0=0; extern int LevelHigh=80; extern int LevelLow=5; extern int adxperiod= 52; extern int adxthreshold=23; extern double martingale =1.1; double last_profit, last_lot; int last_tip; extern int rsiperiodclose=9; extern double multiplicateur=12; int timeframe = PERIOD_M1; double lot; double MarginFree; // Free margin in percentage extern double MinMarginLevel = 100; // Lowest allowed Margin level for new positions to be opened. double wma0L,wma1L,wma2L,wma3L,wma4L,wma5L,wma6L,wma7L,wma8L,wma9L; double wma0H,wma1H,wma2H,wma3H,wma4H,wma5H,wma6H,wma7H,wma8H,wma9H; double rainbow[],rsi[],srsi[],fish[]; double ema0[],ema1[]; double rainbowL,rainbowH,rainbowC; double rainbowC1; double wma0C ,wma1C,wma2C ,wma3C,wma4C ,wma5C ,wma6C ,wma7C ,wma8C ,wma9C; double wma0C1 ,wma1C1,wma2C1 ,wma3C1,wma4C1 ,wma5C1 ,wma6C1 ,wma7C1 ,wma8C1 ,wma9C1; double rsiL,rsiH; double srsiL,srsiH,srsiC; double rsiC1; double srsiC1; double fishC1; double fishL,fishH; double levelup; double leveldown; double fishC; double rsiCS,rsiCL,rsiLL,rsiHS,rsiHL,rsiLS; double rsiC; double imalow ; double imahigh ; double imadiff ; double isbidgreaterthanima ; //+------------------------------------------------------------------+ // expert start function //+------------------------------------------------------------------+ int start() { //============================================================================ //double llots = 0.1; double llots = (AccountBalance() * 0.01 /LotFactor); if( OrdersTotal() == 0 && OrdersHistoryTotal() == 0) llots =/* Lots*/(AccountBalance() * 0.01 /LotFactor); else if( OrdersTotal() == 0&& OrdersHistoryTotal() > 0 ) last_history_profit(); if( last_profit < 0 ) llots = martingale*last_lot; if( last_profit > 0 ) llots = (AccountBalance() * 0.01 /LotFactor); //============================================================================ 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; //+---------------------------------------- //+---------------------------------------- wma0C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,1); wma1C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,2); wma2C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,3); wma3C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,4); wma4C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,5); wma5C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,6); wma6C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,7); wma7C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,8); wma8C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,9); wma9C1 = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,10); rainbowC1=(5*wma0C1+4*wma1C1+3*wma2C1+2*wma3C1+wma4C1+wma5C1+wma6C1+wma7C1+wma8C1+wma9C1)/20; rsiC1=multiplicateur*0.1 *((iRSI(Symbol(), timeframe,rsiperiodclose,PRICE_CLOSE,1))*rainbowC1)-50; srsiC1=rsiC1+rsiC1-rainbowC1; fishC1=(((MathExp(2*srsiC1)-1)/(MathExp(2*srsiC1)+1)+1)*50); //+------------------------------ //+------------------------------ imalow = ((MathExp(2*srsiC)-1)/(MathExp(2*srsiC)+1)+1)*50; imahigh = ((MathExp(2*srsiC)-1)/(MathExp(2*srsiC)+1)+1)*50; imalow = fishL; imahigh = fishH; imadiff = imahigh-imalow ; isbidgreaterthanima =(fishC >= imahigh + imadiff / 2.0) ; //+---------------------------------------- //+---------------------------------------- wma0C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,0); wma1C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,1); wma2C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,2); wma3C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,3); wma4C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,4); wma5C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,5); wma6C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,6); wma7C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,7); wma8C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,8); wma9C = iMA(NULL, timeframe,2,0,MODE_LWMA,PRICE_CLOSE,9); rainbowC=(5*wma0C+4*wma1C+3*wma2C+2*wma3C+wma4C+wma5C+wma6C+wma7C+wma8C+wma9C)/20; rsiC=multiplicateur*0.1 *((iRSI(Symbol(), timeframe,rsiperiodclose,PRICE_CLOSE,0))*rainbowC)-50; srsiC=rsiC+rsiC-rainbowC; fishC=(((MathExp(2*srsiC)-1)/(MathExp(2*srsiC)+1)+1)*50); //+------------------------------ //+------------------------------ imalow = ((MathExp(2*srsiC)-1)/(MathExp(2*srsiC)+1)+1)*50; imahigh = ((MathExp(2*srsiC)-1)/(MathExp(2*srsiC)+1)+1)*50; //+------------------------------ //+------------------------------ if(((fishC1 <LevelLow )&& (fishC >LevelLow) &&(Volume[volume1]> Volume[volume0]) &&(iADX(Symbol(),0,adxperiod,PRICE_CLOSE,MODE_MAIN,0)> adxthreshold)) ) { if (!IsTradeContextBusy() && IsTradeAllowed()) result=OrderSend(Symbol(),OP_BUY,NR(Lot_Volume()),Ask,Slippage,0,0,"BOLLINGER_BANDS_EA",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); } if(((fishC1 > LevelHigh)&&(fishC<LevelHigh) &&(Volume[volume1]> Volume[volume0]) &&(iADX(Symbol(),0,adxperiod,PRICE_CLOSE,MODE_MAIN,0)> adxthreshold) )) { if (!IsTradeContextBusy() && IsTradeAllowed()) result=OrderSend(Symbol(),OP_SELL,NR(Lot_Volume()),Bid,Slippage,0,0,"BOLLINGER_BANDS_EA",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); } } 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); } //============================================================================ 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 a joint une image
    srif-gg-3-12622
  • Tr4d3r

    Matthieuw31, le 17/11/2020 dit :
    Bonjour, Quel pack de Tickstory avez-vous pris? J'ai seulement essayé le pack gratuit mais j'avais laissé tomber car je n'arrivais pas à importer les données sur MT4. Ca n'avait pas l'air sorcier, mais ça ne fonctionnait pas.


    Bonjour,

    Pareil chez moi, IMPOSSIBLE d'importer les données TickStory sur ma plateforme MT4. J'ai beau faire importer dans MT4, lui dire ou se trouve le dossier de ma plateforme, RIEN, ça ne fonctionne pas.

    Si quelqu'un a une idée, je suis preneur !
  • lefeuvr3

    Bonjour
    Si tu veux ,je peux te l'installer en utilisant Teamviewer
    Pour ce faire ,je te mets mon telephone pour me contacter : 07.69.04.91.33
    Amicalement
    Gerard
  • Tr4d3r

    Bonjour,

    Merci pour ta proposition, mais de là à faire un TeamViewer, c'est trop :D

    C'est sympa en tout cas !

    Je vais tenter de passer sur une autre version de MetaTrader pour voir, en ce moment j'utilise MT4 de chez ActivTrades, mais peut-être que celle d'origine fonctionnera.
  • Mikiburger

    Moi j'ai acheté les données EURUSD, je n'ai pas eu de soucis pour les intégrer à MT4.
    Je peux peut être regarder pour les exporter si tu es intéressé.
  • Tr4d3r

    Merci Mikiburger.

    Ca me dérange même pas en soit de payer pour avoir ces données, mais faut que je sache du coup si je paye pour quelque chose :P

    Déjà, est-ce que tu peux me dire si tu utilises une plateforme MT4 "normale" ou alors celle d'un broker ?

    Et avec tes données EUR/USD, t'es à 99% de modelage ?

    Merci à toi
  • Tr4d3r

    Du coup, j'ai réussi à sortir un résultat à 25%, mais par contre, c'est carrément différent de mes résultats en mode démo.

    J'ai un robot que j'ai fait coder selon ma stratégie, je l'ai fait tourner en total autonomie toute la semaine dernière avec un dépôt de 5000€ avec différents réglages, et niveau gains, je suis à minima avec 180€ de gains en mode safe, et jusqu'à 835€ de gains en mode plus agressif.

    Quand je fais un test sur MT4, il me fait que de la perte avec les même réglages.

    Du coup je ne vais pas faire de tests et je vais laisser tourner le robot quelques semaines encore.

    Merci encore à tous.
  • lefeuvr3

    Il n'y a qu'une seule solution a mon humble avis.
    Un modelage à 99.9% en utilisant un compte réel... Tickstory me semble incontournable.... sinon on va a la catastrophe.
    Bonne journée
    Gerard
    Modifié le 2021-03-22 07:01:24 par lefeuvr3
  • Mikiburger

    Pour moi ça dépend du type de stratégie.

    Si c'est du scalping, même un backtest de 99.9% ne me donnera pas confiance.
    Pour ce type de stratégie, un forwardtest en démo sur quelques semaines est indispensable.

    Pour des stratégies en daily un backtest avec du 25% donne déjà une très bonne idée du résultat. (si bougies M1 ou M5)
    Ce que je fais c'est un forward test en démo d'une semaine que je valide à la fin de la semaine avec un backtest.
  • Tr4d3r

    Oui c'est du scalping que je fais, environ 200 - 300 trades par jour.

    Du coup je laisse tourner en mode démo alors, on va bien voir. Et si un jour je bascule en réel avec ce robot, et bien je serais ultra vigilant au début.