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

    Nouvel Expert Advisor …merci de l'améliorer….ici le capital de depart est de 200 €uros …evolution sur 6 mois.
    Code
    //+------------------------------------------------------------------+ //| QPG KEEP COOL EURUSD DAILY.mq4 | //| QPG | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "QPG" #property link "https://www.mql5.com" #property version "1.00" //#property strict extern string ob="OPEN BUY"; extern double delta_open_buy=15; extern int OB1a=20; extern int OB0a=15; extern int OB1b=4; extern int OB0b=1; extern string os="OPEN SELL"; extern double delta_open_sell=25; extern int OS0a=13; extern int OS1a=17; extern int OS0b=13; extern int OS1b=16; extern string Name_EA = "QPG_KEEP_COOL_EURUSD_DAILY"; extern string mm="MONEY MANAGEMENT"; extern bool Trade_buy = true; extern bool Trade_sell = true; extern int Start_Hour = 1; extern int End_Hour = 23; extern bool Tp_in_Money = true; extern double TP_in_money = 3; extern int TP = 20; extern int SL = 110; extern int Max_order = 10; extern int Amount = 250; extern int LockDown = 310; int Slippage = 50; extern double LotFactor = 99; //lotsize factor extern bool TrailingStop_ = true; extern int TrailingStop = 20; extern int Magic = 76; double lot; extern string re="REGULATOR"; extern int adxperiod =14; extern int adxthreshold =27; extern int rsiperiod = 2; //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 double LotSize; 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 ((Ask>Bid*Point) &&(Open[OB1a]>Open[OB0a]) &&((Open[OB1b]-Open[OB0b])>delta_open_buy*Point) &&(booster) ) signal=1;// open buy //+------------------------------------------------------------------------+ //+------------------------------------------------------------------------+ if// open sell ((Bid>Ask*Point) &&(Close[OS0a]>Close[OS1a]) &&((Close[OS0b]-Close[OS1b])>delta_open_sell*Point) &&(booster) ) signal=2;// open sell //+------------------------------------------------------------------------+ 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; if(totalorder(0)<Max_order && CheckMoneyForTrade(Symbol(), NR(Lot_Volume()), OP_BUY)==True && Trade_buy && signal==1 && wt!=Time[0]) { ticketb=OrderSend(Symbol(),OP_BUY,NR(Lot_Volume()),Ask,3,slb,tpb,Name_EA,Magic,0,Blue); if(ticketb>0) wt=Time[0]; } if(totalorder(1)<Max_order && CheckMoneyForTrade(Symbol(), NR(Lot_Volume()), OP_SELL)==True && Trade_sell && signal==2 && wk!=Time[0]) { tickets=OrderSend(Symbol(),OP_SELL,NR(Lot_Volume()),Bid,3,sls,tps,Name_EA,Magic,0,Red); if(tickets>0) wk=Time[0]; } } //---- 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); } //--------------------------------------------------------------------------- int CheckForClose() { if(getProfit()>=Amount){CloseAll();} if(LockDown>0) { for(int TradeNumber = OrdersTotal(); TradeNumber >= 0; TradeNumber--) { if (OrderSelect(TradeNumber, SELECT_BY_POS, MODE_TRADES)&&(LockDown>0)) { int Pos=OrderType(); if((Pos==OP_BUY)&&(Bid-OrderOpenPrice()>Point*LockDown)&&(OrderStopLoss() == 0)) {bool modif1=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+Point,OrderTakeProfit(),0,CLR_NONE);} if((Pos==OP_SELL)&&(OrderOpenPrice()-Ask>Point*LockDown)&&(OrderStopLoss() == 0)) {bool modif2=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-Point,OrderTakeProfit(),0,CLR_NONE);} } } } return(0); } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- double getProfit() { double Profit = 0; for (int TradeNumber = OrdersTotal(); TradeNumber >= 0; TradeNumber--) { if (OrderSelect(TradeNumber, SELECT_BY_POS, MODE_TRADES)) Profit = Profit + OrderProfit() + OrderSwap(); } return (Profit); } //--------------------------------------------------------------------------- void CloseAll() { bool Result; int i,Pos,Error; int Total=OrdersTotal(); if(Total>0) { for(i=Total-1; i>=0; i--) { if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { Pos=OrderType(); if(Pos==OP_BUY) {Result=OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, CLR_NONE);} if(Pos==OP_SELL) {Result=OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, CLR_NONE);} if((Pos==OP_BUYSTOP)||(Pos==OP_SELLSTOP)||(Pos==OP_BUYLIMIT)||(Pos==OP_SELLLIMIT)) {Result=OrderDelete(OrderTicket(), CLR_NONE);} //----------------------- if(Result!=true) { Error=GetLastError(); Print("LastError = ",Error); } else Error=0; //----------------------- } } } }
    lefeuvr3 a joint une image
    qpg-keep-cool-eurusd-daily-10973
  • lefeuvr3

    Amelioration de l'EA
    Simplification du programme et augmentation de la performance par modification des paramètres
    extern double TP_in_money = 5.9;// act on this lever from 3 to 6.3

    Code
    //+------------------------------------------------------------------+ //| QPG KEEP COOL EURUSD DAILY.mq4 | //| QPG | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "QPG" #property link "https://www.mql5.com" #property version "1.00" extern string ob="OPEN BUY"; extern double delta_open_buy=15; extern int OB1a=20; extern int OB0a=15; extern int OB1b=4; extern int OB0b=1; extern string os="OPEN SELL"; extern double delta_open_sell=25; extern int OS0a=13; extern int OS1a=17; extern int OS0b=13; extern int OS1b=16; extern string Name_EA = "QPG_KEEP_COOL_EURUSD_DAILY"; extern string mm="MONEY MANAGEMENT"; extern bool Trade_buy = true; extern bool Trade_sell = true; extern int Start_Hour = 1; extern int End_Hour = 23; extern string tp="TP IN MONEY"; extern bool Tp_in_Money = true; extern double TP_in_money = 5.9;// act on this lever from 3 to 6.3 extern int TP = 20; extern int SL = 110; extern int Max_order = 10; int Slippage = 50; extern double LotFactor = 99; //lotsize factor extern bool TrailingStop_ = true; extern int TrailingStop = 20; extern int Magic = 76; double lot; extern string re="REGULATOR"; extern int adxperiod =14; extern int adxthreshold =27; extern int rsiperiod = 2; //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 double LotSize; 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 and Strategy //+------------------------------------------------------------------+ 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 ((Ask>Bid*Point) &&(Open[OB1a]>Open[OB0a]) &&((Open[OB1b]-Open[OB0b])>delta_open_buy*Point) &&(booster) ) signal=1;// open buy //+------------------------------------------------------------------------+ //+------------------------------------------------------------------------+ if// open sell ((Bid>Ask*Point) &&(Close[OS0a]>Close[OS1a]) &&((Close[OS0b]-Close[OS1b])>delta_open_sell*Point) &&(booster) ) signal=2;// open sell //+------------------------------------------------------------------------+ 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; if(totalorder(0)<Max_order && CheckMoneyForTrade(Symbol(), NR(Lot_Volume()), OP_BUY)==True && Trade_buy && signal==1 && wt!=Time[0]) { ticketb=OrderSend(Symbol(),OP_BUY,NR(Lot_Volume()),Ask,3,slb,tpb,Name_EA,Magic,0,Blue); if(ticketb>0) wt=Time[0]; } if(totalorder(1)<Max_order && CheckMoneyForTrade(Symbol(), NR(Lot_Volume()), OP_SELL)==True && Trade_sell && signal==2 && wk!=Time[0]) { tickets=OrderSend(Symbol(),OP_SELL,NR(Lot_Volume()),Bid,3,sls,tps,Name_EA,Magic,0,Red); if(tickets>0) wk=Time[0]; } } //---- return(0); } //+------------------------------------------------------------------+ //| Trading Time //+------------------------------------------------------------------+ 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); } //+------------------------------------------------------------------+ //| Total Order //+------------------------------------------------------------------+ 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); } //+------------------------------------------------------------------+ //| Trailing //+------------------------------------------------------------------+ 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); } } } } } //+------------------------------------------------------------------+ // Money //+------------------------------------------------------------------+ 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); } //--------------------------------------------------------------------------- // Close All //--------------------------------------------------------------------------- void CloseAll() { bool Result; int i,Pos,Error; int Total=OrdersTotal(); if(Total>0) { for(i=Total-1; i>=0; i--) { if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { Pos=OrderType(); if(Pos==OP_BUY) {Result=OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, CLR_NONE);} if(Pos==OP_SELL) {Result=OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, CLR_NONE);} if((Pos==OP_BUYSTOP)||(Pos==OP_SELLSTOP)||(Pos==OP_BUYLIMIT)||(Pos==OP_SELLLIMIT)) {Result=OrderDelete(OrderTicket(), CLR_NONE);} //----------------------- if(Result!=true) { Error=GetLastError(); Print("LastError = ",Error); } else Error=0; //----------------------- } } } }
  • lefeuvr3

    Merci d'apporter les ameliorations utiles dans un esprit cooperatif
    lefeuvr3 a joint une image
    qpg-keep-cool-eurusd-daily-10976
  • lefeuvr3

    Nouvelle version améliorée avec modification des parametres
    Toujours securisé
    Les gains sont plus significatifs et s'ajustent au montant sur le compte (account)

    Code
    //+------------------------------------------------------------------+ //| QPG KEEP COOL VERSION 2 | //| 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 2 "; extern int MagicNumber=18092018; 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 = 6.8;//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[0]) //+------------------------------------------------------------------+ // //+------------------------------------------------------------------+ 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[0]) //+------------------------------------------------------------------+ // //+------------------------------------------------------------------+ { 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,Green); } 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); } //---------------------------------------------------------------------------
    lefeuvr3 a joint une image
    qpg-keep-cool-eurusd-daily-10986