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

QPG KEEP COOL EURUSD DAILY

  • lefeuvr3

    Version 3 finalisée
    En fait les modifications a apporter étaient assez minimes….a savoir modification du TP_in_money = 22 et des parametres Shift de Time ...Time[A] et Time [B]

    On va voir maintenant comment il se comporte ,comme le bon vin ,avec le temps….si les résultats sans modification des parametres sont bons ,il faudra envisager un parametrage pour une utilisation en unite de temps minute.
    Bon week end a tous

    [copie]
    //+------------------------------------------------------------------+
    //| QPG KEEP COOL VERSION 3|
    //| QPG |
    //| https://www.mql5.com |
    //+------------------------------------------------------------------+
    //+------------------------------------------------------------------+
    //| EURUSD DAILY |
    //+------------------------------------------------------------------+
    #property copyright "QPG"
    #property link "https://www.mql5.com"
    #property version "1.00"

    extern string Name_EA = " QPG KEEP COOL VERSION 3";
    extern int MagicNumber=20092018;
    double lot ;
    extern double SL=68;
    extern double TP=35;
    extern bool TrailingStop_ = true;
    extern int TrailingStop=17;
    extern int Slippage=3;
    extern double LotFactor = 500; //lotsize factor
    extern int Max_order = 20;
    extern string ob="OPEN BUY";
    extern double delta_open_buy=6;
    extern int OB1a=23;
    extern int OB0a=31;
    extern int OB1b=4;
    extern int OB0b=3;
    extern string os="OPEN SELL";
    extern double delta_open_sell=17;
    extern int OS0a=13;
    extern int OS1a=17;
    extern int OS0b=1;
    extern int OS1b=0;
    extern string tp="TP IN MONEY";
    extern bool Tp_in_Money = true;
    extern double TP_in_money = 22;//agir sur ce levier
    extern bool Trade_buy = true;
    extern bool Trade_sell = true;
    extern int A=1;
    extern int B=0;
    extern string re="REGULATOR";
    extern int adxperiod =14;
    extern int adxthreshold =27;
    extern int rsiperiod = 3; //rsi period
    extern int rsiupper = 80; //rsi upper bound, wont buy above this value
    extern int rsilower = 20; //rsi lower bound, wont sell below this value
    extern int Magic = 76;
    extern int Start_Hour = 1;
    extern int End_Hour = 23;

    double slb,tpb,sls,tps,pt;
    int ras,wt,wk,ticketb,tickets;
    //+------------------------------------------------------------------+
    //| expert initialization function |
    //+------------------------------------------------------------------+
    int init()
    {
    //----
    if(Digits==3 || Digits==5) pt=10*Point; else pt=Point;
    //----
    return(0);
    }
    //+------------------------------------------------------------------+
    //| expert deinitialization function |
    //+------------------------------------------------------------------+
    int deinit()
    {
    //----
    //----
    return(0);
    }
    //+------------------------------------------------------------------+
    //| expert start function |
    //+------------------------------------------------------------------+
    int start()
    {
    if(TrailingStop_)dtrailing();
    if(Tp_in_Money && TP_in_money<=money()) closeall();
    //+------------------------------------------------------------------+

    double booster = Volume[1]> Volume[0]
    &&(iADX(Symbol(),0,adxperiod,PRICE_CLOSE,MODE_MAIN,0)>adxthreshold )
    && iRSI(Symbol(),0,rsiperiod,PRICE_CLOSE,0)>rsilower && iRSI(Symbol(),0,rsiperiod,PRICE_CLOSE,0)<rsiupper;

    int signal;
    //+------------------------------------------------------------------------+
    if// open buy
    (
    (Open[OB1a]>Open[OB0a])
    &&:'((Open[OB1b]-Open[OB0b])>delta_open_buy*Point)
    &&(booster) ) signal=1;// open buy
    //+------------------------------------------------------------------------+
    //+------------------------------------------------------------------------+
    if// open sell
    (
    (Close[OS0a]>Close[OS1a])
    &&:'((Close[OS0b]-Close[OS1b])>delta_open_sell*Point)
    &&(booster) ) signal=2;// open sell
    //+------------------------------------------------------------------+

    //if(Hour_trade()==hour_trade)
    {
    if(SL==0)slb=0;else slb=Ask-SL*pt;
    if(SL==0)sls=0;else sls=Bid+SL*pt;
    if(TP==0)tpb=0;else tpb=Ask+TP*pt;
    if(TP==0)tps=0;else tps=Bid-TP*pt;
    //+------------------------------------------------------------------+

    //+------------------------------------------------------------------+
    if(totalorder(0)<Max_order && CheckMoneyForTrade(Symbol(), NR(Lot_Volume()), OP_BUY)==True && Trade_buy && signal==1 && wt!=Time[B])
    //+------------------------------------------------------------------+

    {
    ticketb=OrderSend(Symbol(),OP_BUY,NR(Lot_Volume()),Ask,3,slb,tpb,Name_EA,Magic,0,Blue);
    if(ticketb>0)wt=Time[A];
    }
    if(totalorder(1)<Max_order && CheckMoneyForTrade(Symbol(), NR(Lot_Volume()), OP_SELL)==True && Trade_sell && signal==2 && wk!=Time[B])
    {
    tickets=OrderSend(Symbol(),OP_SELL,NR(Lot_Volume()),Bid,3,sls,tps,Name_EA,Magic,0,Red);
    if(tickets>0) wk=Time[A];
    }
    }
    //----
    return(0);
    }
    //+------------------------------------------------------------------+
    //| |
    //+------------------------------------------------------------------+
    int Hour_trade()
    {
    bool trade=false;
    if(Start_Hour>End_Hour)
    {
    if(Hour()>=Start_Hour || Hour()<End_Hour) trade=true;
    }
    else
    if(Hour()>=Start_Hour && Hour()<End_Hour) trade=true;

    return (trade);
    }
    //+------------------------------------------------------------------+
    //
    //+------------------------------------------------------------------+

    int totalorder(int tipe)
    {
    int total=0;
    for(int i=0; i<OrdersTotal(); i++)
    {
    if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;
    if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic || OrderType()!=tipe) continue;
    total++;
    }

    return(total);
    }

    //+------------------------------------------------------------------+
    //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);
    }
    //+------------------------------------------------------------------+
    //|
    //+------------------------------------------------------------------+
    void dtrailing()
    {
    int i,r;double tpn;
    for(i=0; i<OrdersTotal(); i++)
    {
    if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;
    if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue;
    tpn=OrderTakeProfit();
    if(OrderType()==OP_BUY)
    {
    if(Bid-OrderOpenPrice()>pt*TrailingStop)
    {
    if((OrderStopLoss()<Bid-pt*TrailingStop) || (OrderStopLoss()==0))
    {
    if(tpn) r=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-pt*TrailingStop,OrderTakeProfit(),0,Green);
    }
    }
    }
    if(OrderType()==OP_SELL)
    {
    if((OrderOpenPrice()-Ask)>(pt*TrailingStop))
    {
    if(OrderStopLoss()>(Ask+pt*TrailingStop) || (OrderStopLoss()==0))
    {
    if(tpn) r=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+pt*TrailingStop,OrderTakeProfit(),0,Red);
    }
    }
    }
    }
    }
    //+------------------------------------------------------------------+
    //|
    //+------------------------------------------------------------------+
    void closeall()
    {
    for(int i=OrdersTotal()-1; i>=0; i--)
    {
    if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;
    if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue;
    if(OrderType()>1) ras=OrderDelete(OrderTicket());
    else
    {
    if(OrderType()==0) ras=OrderClose(OrderTicket(),OrderLots(),Bid,3,CLR_NONE);
    else ras=OrderClose(OrderTicket(),OrderLots(),Ask,3,CLR_NONE);
    }
    }
    }
    //+------------------------------------------------------------------+
    //|
    //+------------------------------------------------------------------+
    double money()
    {
    double dp=0;
    int i;
    for(i=0; i<OrdersTotal(); i++)
    {
    if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;
    if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue;
    dp+=OrderProfit();
    }
    return(dp);
    }
    //+------------------------------------------------------------------+

    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);
    }
    //---------------------------------------------------------------------------

    [/copie]
    Modifié le 2018-09-21 21:21:47 par lefeuvr3 : probleme avec le rendu [copie] et [/copie]
    lefeuvr3 a joint une image
    qpg-keep-cool-eurusd-daily-11009
  • lefeuvr3

    De manière incomprehensible je ne retrouve pas les bons résultats de la veille avec la version 3
    J'ai donc refais une 4° version ,qui espérons le tiendra, cette fois ci , la route.
    Version 4 toujours dans l'optique de la fusion, des 2 premières versions

    Code
    //+------------------------------------------------------------------+ //| QPG KEEP COOL VERSION 4 | //| QPG | //| https://www.mql5.com | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| EURUSD DAILY | //+------------------------------------------------------------------+ #property copyright "QPG" #property link "https://www.mql5.com" #property version "1.00" extern string Name_EA = " QPG KEEP COOL VERSION 4 "; extern int MagicNumber=22092018; double lot ; extern double SL=68; extern double TP=35; extern bool TrailingStop_ = true; extern int TrailingStop=17; extern int Slippage=3; extern double LotFactor = 500; //lotsize factor extern int Max_order = 20; extern string ob="OPEN BUY"; extern double delta_open_buy=6; extern int OB1a=23; extern int OB0a=31; extern int OB1b=4; extern int OB0b=3; extern string os="OPEN SELL"; extern double delta_open_sell=17; extern int OS0a=13; extern int OS1a=17; extern int OS0b=1; extern int OS1b=0; extern string tp="TP IN MONEY"; extern bool Tp_in_Money = true; extern double TP_in_money = 22;//agir sur ce levier extern bool Trade_buy = true; extern bool Trade_sell = true; extern string re="REGULATOR"; extern int adxperiod =14; extern int adxthreshold =27; extern int rsiperiod = 3; //rsi period extern int rsiupper = 80; //rsi upper bound, wont buy above this value extern int rsilower = 20; //rsi lower bound, wont sell below this value extern int Magic = 76; extern int Start_Hour = 1; extern int End_Hour = 23; double slb,tpb,sls,tps,pt; int ras,wt,wk,resultB,resultS,tickets; //+------------------------------------------------------------------+ // expert start function //+------------------------------------------------------------------+ int start() { //+------------------------------------------------------------------+ if(TrailingStop_)dtrailing();// do not remove //+------------------------------------------------------------------+ //|very important .. //| //|whitout we have more money and 3 times less trades if(Tp_in_Money && TP_in_money<=money()) closeall(); //+------------------------------------------------------------------+ double MyPoint=Point; if(Digits==3 || Digits==5) pt=10*Point; else pt=Point; MyPoint=Point*10; double TheStopLoss=0; double TheTakeProfit=0; if( TotalOrdersCount()==0 ) { int result=0; double booster = Volume[1]> Volume[0] &&(iADX(Symbol(),0,adxperiod,PRICE_CLOSE,MODE_MAIN,0)>adxthreshold ) && iRSI(Symbol(),0,rsiperiod,PRICE_CLOSE,0)>rsilower && iRSI(Symbol(),0,rsiperiod,PRICE_CLOSE,0)<rsiupper; int signal; if// open buy ((Ask>Bid*Point) &&(Open[OB1a]>Open[OB0a]) &&((Open[OB1b]-Open[OB0b])>delta_open_buy*Point) &&(booster) ) signal=1;// Here is your open buy rule //+------------------------------------------------------------------+ //|very important .. //| //|whitout we have 3 times more trades +++ .. but bigger DD //+------------------------------------------------------------------+ if(totalorder(0)<Max_order && CheckMoneyForTrade(Symbol(), NR(Lot_Volume()), OP_BUY)==True && Trade_buy && signal==1 && wt!=Time[1]) //+------------------------------------------------------------------+ // //+------------------------------------------------------------------+ if(Hour_trade()==1) { if(SL==0)slb=0;else slb=Ask-SL*pt; if(SL==0)sls=0;else sls=Bid+SL*pt; if(TP==0)tpb=0;else tpb=Ask+TP*pt; if(TP==0)tps=0;else tps=Bid-TP*pt; resultB=OrderSend(Symbol(),OP_BUY,NR(Lot_Volume()),Ask,3,slb,tpb,Name_EA,Magic,0,Blue); if(resultB>0) { TheStopLoss=0; TheTakeProfit=0; if(TP>0) TheTakeProfit=Ask+TP*MyPoint; if(SL>0) TheStopLoss=Ask-SL*MyPoint; if(OrderSelect(result,SELECT_BY_TICKET)) bool modify1 =OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } if// open sell ((Bid>Ask*Point) &&(Close[OS0a]>Close[OS1a]) &&((Close[OS0b]-Close[OS1b])>delta_open_sell*Point) &&(booster) ) signal=2; // Here is your open Sell rule //+------------------------------------------------------------------+ // ///+------------------------------------------------------------------+ if(totalorder(1)<Max_order && CheckMoneyForTrade(Symbol(), NR(Lot_Volume()), OP_SELL)==True && Trade_sell && signal==2 && wk!=Time[1]) //+------------------------------------------------------------------+ // //+------------------------------------------------------------------+ { if(SL==0)slb=0;else slb=Ask-SL*pt; if(SL==0)sls=0;else sls=Bid+SL*pt; if(TP==0)tpb=0;else tpb=Ask+TP*pt; if(TP==0)tps=0;else tps=Bid-TP*pt; resultS=OrderSend(Symbol(),OP_SELL,NR(Lot_Volume()),Bid,3,sls,tps,Name_EA,Magic,0,Red); if(resultS>0) { TheStopLoss=0; TheTakeProfit=0; if(TP>0) TheTakeProfit=Bid-TP*MyPoint; if(SL>0) TheStopLoss=Bid+SL*MyPoint; if(OrderSelect(result,SELECT_BY_TICKET)) bool modify2=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),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); } //+------------------------------------------------------------------+ //| //+------------------------------------------------------------------+ int totalorder(int tipe) { int total=0; for(int i=0; i<OrdersTotal(); i++) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic || OrderType()!=tipe) continue; total++; } return(total); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //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); } //+------------------------------------------------------------------+ //| //+------------------------------------------------------------------+ int Hour_trade() { bool trade=false; if(Start_Hour>End_Hour) { if(Hour()>=Start_Hour || Hour()<End_Hour) trade=true; } else if(Hour()>=Start_Hour && Hour()<End_Hour) trade=true; return (trade); } //+------------------------------------------------------------------+ //| //+------------------------------------------------------------------+ void dtrailing() { int i,r;double tpn; for(i=0; i<OrdersTotal(); i++) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue; tpn=OrderTakeProfit(); if(OrderType()==OP_BUY) { if(Bid-OrderOpenPrice()>pt*TrailingStop) { if((OrderStopLoss()<Bid-pt*TrailingStop) || (OrderStopLoss()==0)) { if(tpn) r=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-pt*TrailingStop,OrderTakeProfit(),0,Green); } } } if(OrderType()==OP_SELL) { if((OrderOpenPrice()-Ask)>(pt*TrailingStop)) { if(OrderStopLoss()>(Ask+pt*TrailingStop) || (OrderStopLoss()==0)) { if(tpn) r=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+pt*TrailingStop,OrderTakeProfit(),0,Red); } } } } } //+------------------------------------------------------------------+ //| //+------------------------------------------------------------------+ void closeall() { for(int i=OrdersTotal()-1; i>=0; i--) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue; if(OrderType()>1) ras=OrderDelete(OrderTicket()); else { if(OrderType()==0) ras=OrderClose(OrderTicket(),OrderLots(),Bid,3,CLR_NONE); else ras=OrderClose(OrderTicket(),OrderLots(),Ask,3,CLR_NONE); } } } //+------------------------------------------------------------------+ //| //+------------------------------------------------------------------+ double money() { double dp=0; int i; for(i=0; i<OrdersTotal(); i++) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue; dp+=OrderProfit(); } return(dp); } //+------------------------------------------------------------------+ 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); } //+------------------------------------------------------------------+
    Modifié le 2018-09-22 11:10:02 par lefeuvr3
    lefeuvr3 a joint une image
    qpg-keep-cool-eurusd-daily-11010
Page 2