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

Comment débrayer un indicateur d'un EA quand il y en a plusieurs sur le même EA?

  • lefeuvr3

    J'ai programmé un EA avec une batterie d'indicateurs RSI ou WPR ou CCI ou MA qui prennent les position non pas en même temps mais indépendamment les uns des autres ...il est très performant mais comme tout EA nécessite de temps en temps un réajustement des paramètres.
    Plutôt que de le reback tester dans sa globalité je voudrais pouvoir débrayer chaque indicateur avec la commande par exemple: bool extern RSI= false;
    bool extern CCI = false;…. et ainsi de suite ...
    Qui peut m'aider?
    Merci d'avance !
    gerard
    lefeuvr3 a joint une vidéo
    Video
  • seven123456789 — en réponse à lefeuvr3 dans son message #57125

    il te suffit juste de rajouter une fonction if..... else sur tes ordres d'achat et vente.

    if CCI= true
    ..........
    else
    ...........
  • lefeuvr3

    Je mets ici un petit programme que j'ai écris pour l'Euro dollar en UT 15
    Si tu pouvais apporter la correction dessus cela serait sympa !
    Pour débrayer RSI ou MA
    Merci déjà pour ta première réponse :)
    Gerard

    Code
    //+------------------------------------------------------------------+ //| This MQL is generated by Expert Advisor Builder | //| http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/ | //| | //| In no event will author be liable for any damages whatsoever. | //| Use at your own risk. | //| | //+------------------- DO NOT REMOVE THIS HEADER --------------------+ #define SIGNAL_NONE 0 #define SIGNAL_BUY 1 #define SIGNAL_SELL 2 #define SIGNAL_CLOSEBUY 3 #define SIGNAL_CLOSESELL 4 #property copyright "Expert Advisor Builder" #property link "http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/" extern int MagicNumber = 0; extern bool SignalMail = False; extern bool EachTickMode = False; extern double Lots = 1.0; extern int Slippage = 3; extern bool UseStopLoss = False; extern int StopLoss = 30; extern bool UseTakeProfit = False; extern int TakeProfit = 60; extern bool UseTrailingStop = False; extern int TrailingStop = 30; //Paramètres RSI extern int RSIPERIODEB1 = 197; extern int RSIPERIODEB2 = 10; extern int RSIPERIODECB1 = 46; extern int RSIPERIODECB2 = 13; extern int RSIPERIODES1 = 140; extern int RSIPERIODES2 = 51; extern int RSIPERIODECS1 = 193; extern int RSIPERIODECS2 = 9; extern int RSISHIFT1 = 0; extern int RSISHIFT2 = 0; //Paramètres MA extern int MAPERIODEB1 = 42; extern int MAPERIODEB2 = 6; extern int MAPERIODECB1 = 113; extern int MAPERIODECB2 = 117; extern int MAPERIODES1 =25; extern int MAPERIODES2 = 50; extern int MAPERIODECS1 = 95; extern int MAPERIODECS2 = 15; extern int MAMASHIFT = 0; extern int MASHIFT1 = 0; extern int MASHIFT2 = 1; extern int MASHIFT3 = 1; extern int MASHIFT4 = 5; extern int MASHIFT5 = 18; extern int MASHIFT6 = 8; extern int MASHIFT7 = 2; extern int MASHIFT8 = 3; extern int MODE1= 0; extern int MODE2= 0; extern int MODE3= 0; extern int MODE4= 0; extern int MODE5= 0; extern int MODE6= 0; extern int MODE7= 0; extern int MODE8= 0; extern int MODE9= 0; extern int MODE10= 0; extern int MODE11= 0; extern int MODE12= 0; extern int MODE13= 0; extern int MODE14= 0; extern int MODE15= 0; extern int MODE16= 0; int BarCount; int Current; bool TickCheck = False; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { BarCount = Bars; if (EachTickMode) Current = 0; else Current = 1; return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { int Order = SIGNAL_NONE; int Total, Ticket; double StopLossLevel, TakeProfitLevel; if (EachTickMode && Bars != BarCount) TickCheck = False; Total = OrdersTotal(); Order = SIGNAL_NONE; //+------------------------------------------------------------------+ //| Variable Begin | //+------------------------------------------------------------------+ double Buy1_1 = iRSI(NULL, 0, RSIPERIODEB1, PRICE_CLOSE, Current + RSISHIFT1); double Buy1_2 = 50; double Buy2_1 = iRSI(NULL, 0, RSIPERIODEB2, PRICE_CLOSE, Current + RSISHIFT2); double Buy2_2 = 50; double Buy3_1 = iMA(NULL, 0, MAPERIODEB1, MAMASHIFT, MODE1, PRICE_CLOSE, Current + MASHIFT1); double Buy3_2 = iMA(NULL, 0, MAPERIODEB2, MAMASHIFT, MODE2, PRICE_CLOSE, Current + MASHIFT1); double Buy4_1 = iMA(NULL, 0, MAPERIODEB1, MAMASHIFT, MODE3, PRICE_CLOSE, Current + MASHIFT2); double Buy4_2 = iMA(NULL, 0, MAPERIODEB2, MAMASHIFT, MODE4, PRICE_CLOSE, Current + MASHIFT2); double Sell1_1 = iRSI(NULL, 0, RSIPERIODES1, PRICE_CLOSE, Current + RSISHIFT1); double Sell1_2 = 50; double Sell2_1 = iRSI(NULL, 0, RSIPERIODES2, PRICE_CLOSE, Current + RSISHIFT2); double Sell2_2 = 50; double Sell3_1 = iMA(NULL, 0, MAPERIODES1, MAMASHIFT, MODE5, PRICE_CLOSE, Current + MASHIFT3); double Sell3_2 = iMA(NULL, 0, MAPERIODES2, MAMASHIFT, MODE6, PRICE_CLOSE, Current + MASHIFT3); double Sell4_1 = iMA(NULL, 0, MAPERIODES1, MAMASHIFT, MODE7, PRICE_CLOSE, Current + MASHIFT4); double Sell4_2 = iMA(NULL, 0, MAPERIODES2, MAMASHIFT, MODE8, PRICE_CLOSE, Current + MASHIFT4); double CloseBuy1_1 = iRSI(NULL, 0, RSIPERIODECB1, PRICE_CLOSE, Current + RSISHIFT1); double CloseBuy1_2 = 50; double CloseBuy2_1 = iRSI(NULL, 0, RSIPERIODECB2, PRICE_CLOSE, Current + RSISHIFT2); double CloseBuy2_2 = 50; double CloseBuy3_1 = iMA(NULL, 0, MAPERIODECB1, MAMASHIFT, MODE9, PRICE_CLOSE, Current + MASHIFT5); double CloseBuy3_2 = iMA(NULL, 0, MAPERIODECB2, MAMASHIFT, MODE10, PRICE_CLOSE, Current + MASHIFT5); double CloseBuy4_1 = iMA(NULL, 0, MAPERIODECB1, MAMASHIFT, MODE11, PRICE_CLOSE, Current + MASHIFT6); double CloseBuy4_2 = iMA(NULL, 0, MAPERIODECB2, MAMASHIFT, MODE12, PRICE_CLOSE, Current + MASHIFT6); double CloseSell1_1 = iRSI(NULL, 0, RSIPERIODECS1, PRICE_CLOSE, Current + RSISHIFT1); double CloseSell1_2 = 50; double CloseSell2_1 = iRSI(NULL, 0, RSIPERIODECS2, PRICE_CLOSE, Current + RSISHIFT2); double CloseSell2_2 = 50; double CloseSell3_1 = iMA(NULL, 0, MAPERIODECS1, MAMASHIFT, MODE13, PRICE_CLOSE, Current + MASHIFT7); double CloseSell3_2 = iMA(NULL, 0, MAPERIODECS2, MAMASHIFT, MODE14, PRICE_CLOSE, Current + MASHIFT7); double CloseSell4_1 = iMA(NULL, 0, MAPERIODECS1, MAMASHIFT, MODE15, PRICE_CLOSE, Current + MASHIFT8); double CloseSell4_2 = iMA(NULL, 0, MAPERIODECS2, MAMASHIFT, MODE16, PRICE_CLOSE, Current + MASHIFT8); //+------------------------------------------------------------------+ //| Variable End | //+------------------------------------------------------------------+ //Check position bool IsTrade = False; for (int i = 0; i < Total; i ++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(OrderType() <= OP_SELL && OrderSymbol() == Symbol()) { IsTrade = True; if(OrderType() == OP_BUY) { //Close //+------------------------------------------------------------------+ //| Signal Begin(Exit Buy) | //+------------------------------------------------------------------+ if ((CloseBuy1_1 > CloseBuy1_2 && CloseBuy2_1 < CloseBuy2_2) || (CloseBuy3_1 > CloseBuy3_2 && CloseBuy4_1 < CloseBuy4_2)) Order = SIGNAL_CLOSEBUY; //+------------------------------------------------------------------+ //| Signal End(Exit Buy) | //+------------------------------------------------------------------+ if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) { OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy"); if (!EachTickMode) BarCount = Bars; IsTrade = False; continue; } //Trailing stop if(UseTrailingStop && TrailingStop > 0) { if(Bid - OrderOpenPrice() > Point * TrailingStop) { if(OrderStopLoss() < Bid - Point * TrailingStop) { OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen); if (!EachTickMode) BarCount = Bars; continue; } } } } else { //Close //+------------------------------------------------------------------+ //| Signal Begin(Exit Sell) | //+------------------------------------------------------------------+ if ((CloseSell1_1 < CloseSell1_2 && CloseSell2_1 > CloseSell2_2) || (CloseSell3_1 < CloseSell3_2 && CloseSell4_1 > CloseSell4_2)) Order = SIGNAL_CLOSESELL; //+------------------------------------------------------------------+ //| Signal End(Exit Sell) | //+------------------------------------------------------------------+ if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) { OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell"); if (!EachTickMode) BarCount = Bars; IsTrade = False; continue; } //Trailing stop if(UseTrailingStop && TrailingStop > 0) { if((OrderOpenPrice() - Ask) > (Point * TrailingStop)) { if((OrderStopLoss() > (Ask + Point * TrailingStop)) || (OrderStopLoss() == 0)) { OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingStop, OrderTakeProfit(), 0, DarkOrange); if (!EachTickMode) BarCount = Bars; continue; } } } } } } //+------------------------------------------------------------------+ //| Signal Begin(Entry) | //+------------------------------------------------------------------+ if ((Buy1_1 < Buy1_2 && Buy2_1 > Buy2_2) || (Buy3_1 < Buy3_2 && Buy4_1 > Buy4_2)) Order = SIGNAL_BUY; if ((Sell1_1 > Sell1_2 && Sell2_1 < Sell2_2) || (Sell3_1 > Sell3_2 && Sell4_1 < Sell4_2)) Order = SIGNAL_SELL; //+------------------------------------------------------------------+ //| Signal End | //+------------------------------------------------------------------+ //Buy if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) { if(!IsTrade) { //Check free margin if (AccountFreeMargin() < (1000 * Lots)) { Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } if (UseStopLoss) StopLossLevel = Ask - StopLoss * Point; else StopLossLevel = 0.0; if (UseTakeProfit) TakeProfitLevel = Ask + TakeProfit * Point; else TakeProfitLevel = 0.0; Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue); if(Ticket > 0) { if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) { Print("BUY order opened : ", OrderOpenPrice()); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy"); } else { Print("Error opening BUY order : ", GetLastError()); } } if (EachTickMode) TickCheck = True; if (!EachTickMode) BarCount = Bars; return(0); } } //Sell if (Order == SIGNAL_SELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) { if(!IsTrade) { //Check free margin if (AccountFreeMargin() < (1000 * Lots)) { Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } if (UseStopLoss) StopLossLevel = Bid + StopLoss * Point; else StopLossLevel = 0.0; if (UseTakeProfit) TakeProfitLevel = Bid - TakeProfit * Point; else TakeProfitLevel = 0.0; Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLossLevel, TakeProfitLevel, "Sell(#" + MagicNumber + ")", MagicNumber, 0, DeepPink); if(Ticket > 0) { if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) { Print("SELL order opened : ", OrderOpenPrice()); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Open Sell"); } else { Print("Error opening SELL order : ", GetLastError()); } } if (EachTickMode) TickCheck = True; if (!EachTickMode) BarCount = Bars; return(0); } } if (!EachTickMode) BarCount = Bars; return(0); } //+------------------------------------------------------------------+
    Modifié le 2012-09-02 07:47:42 par AliX
  • lefeuvr3

    Le voici avec les modifications apportées par tes conseils et ceux de Jean François.
    Il a l'air de tres bien fonctionner maintenant en UT 15 sur l'Euro dollar
    Merci beaucoup pour cet esprit d'entraide et de partage
    Code
    //+------------------------------------------------------------------+ //| This MQL is generated by Expert Advisor Builder | //| http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/ | //| | //| In no event will author be liable for any damages whatsoever. | //| Use at your own risk. | //| | //+------------------- DO NOT REMOVE THIS HEADER --------------------+ #define SIGNAL_NONE 0 #define SIGNAL_BUY 1 #define SIGNAL_SELL 2 #define SIGNAL_CLOSEBUY 3 #define SIGNAL_CLOSESELL 4 #property copyright "Expert Advisor Builder" #property link "http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/" extern int MagicNumber = 0; extern bool SignalMail = False; extern bool EachTickMode = False; extern double Lots = 1.0; extern int Slippage = 3; extern bool UseStopLoss = False; extern int StopLoss = 30; extern bool UseTakeProfit = False; extern int TakeProfit = 60; extern bool UseTrailingStop = False; extern int TrailingStop = 30; //Paramètres RSI extern string separator1 = "*** RSI Settings ***"; extern bool RSI = True; extern int RSIPERIODEB1 = 197; extern int RSIPERIODEB2 = 10; extern int RSIPERIODECB1 = 46; extern int RSIPERIODECB2 = 13; extern int RSIPERIODES1 = 140; extern int RSIPERIODES2 = 51; extern int RSIPERIODECS1 = 193; extern int RSIPERIODECS2 = 9; extern int RSISHIFT1 = 0; extern int RSISHIFT2 = 0; //Paramètres MA extern string separator2 = "*** MA Settings ***"; extern bool MM = True; extern int MAPERIODEB1 = 42; extern int MAPERIODEB2 = 6; extern int MAPERIODECB1 = 113; extern int MAPERIODECB2 = 117; extern int MAPERIODES1 =25; extern int MAPERIODES2 = 50; extern int MAPERIODECS1 = 95; extern int MAPERIODECS2 = 15; extern int MAMASHIFT = 0; extern int MASHIFT1 = 0; extern int MASHIFT2 = 1; extern int MASHIFT3 = 1; extern int MASHIFT4 = 5; extern int MASHIFT5 = 18; extern int MASHIFT6 = 8; extern int MASHIFT7 = 2; extern int MASHIFT8 = 3; extern int MODE1= 0; extern int MODE2= 0; extern int MODE3= 0; extern int MODE4= 0; extern int MODE5= 0; extern int MODE6= 0; extern int MODE7= 0; extern int MODE8= 0; extern int MODE9= 0; extern int MODE10= 0; extern int MODE11= 0; extern int MODE12= 0; extern int MODE13= 0; extern int MODE14= 0; extern int MODE15= 0; extern int MODE16= 0; int BarCount; int Current; bool TickCheck = False; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { BarCount = Bars; if (EachTickMode) Current = 0; else Current = 1; return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { int Order = SIGNAL_NONE; int Total, Ticket; double StopLossLevel, TakeProfitLevel; if (EachTickMode && Bars != BarCount) TickCheck = False; Total = OrdersTotal(); Order = SIGNAL_NONE; //+------------------------------------------------------------------+ //| Variable Begin | //+------------------------------------------------------------------+ double Buy1_1 = iRSI(NULL, 0, RSIPERIODEB1, PRICE_CLOSE, Current + RSISHIFT1); double Buy1_2 = 50; double Buy2_1 = iRSI(NULL, 0, RSIPERIODEB2, PRICE_CLOSE, Current + RSISHIFT2); double Buy2_2 = 50; double Buy3_1 = iMA(NULL, 0, MAPERIODEB1, MAMASHIFT, MODE1, PRICE_CLOSE, Current + MASHIFT1); double Buy3_2 = iMA(NULL, 0, MAPERIODEB2, MAMASHIFT, MODE2, PRICE_CLOSE, Current + MASHIFT1); double Buy4_1 = iMA(NULL, 0, MAPERIODEB1, MAMASHIFT, MODE3, PRICE_CLOSE, Current + MASHIFT2); double Buy4_2 = iMA(NULL, 0, MAPERIODEB2, MAMASHIFT, MODE4, PRICE_CLOSE, Current + MASHIFT2); double Sell1_1 = iRSI(NULL, 0, RSIPERIODES1, PRICE_CLOSE, Current + RSISHIFT1); double Sell1_2 = 50; double Sell2_1 = iRSI(NULL, 0, RSIPERIODES2, PRICE_CLOSE, Current + RSISHIFT2); double Sell2_2 = 50; double Sell3_1 = iMA(NULL, 0, MAPERIODES1, MAMASHIFT, MODE5, PRICE_CLOSE, Current + MASHIFT3); double Sell3_2 = iMA(NULL, 0, MAPERIODES2, MAMASHIFT, MODE6, PRICE_CLOSE, Current + MASHIFT3); double Sell4_1 = iMA(NULL, 0, MAPERIODES1, MAMASHIFT, MODE7, PRICE_CLOSE, Current + MASHIFT4); double Sell4_2 = iMA(NULL, 0, MAPERIODES2, MAMASHIFT, MODE8, PRICE_CLOSE, Current + MASHIFT4); double CloseBuy1_1 = iRSI(NULL, 0, RSIPERIODECB1, PRICE_CLOSE, Current + RSISHIFT1); double CloseBuy1_2 = 50; double CloseBuy2_1 = iRSI(NULL, 0, RSIPERIODECB2, PRICE_CLOSE, Current + RSISHIFT2); double CloseBuy2_2 = 50; double CloseBuy3_1 = iMA(NULL, 0, MAPERIODECB1, MAMASHIFT, MODE9, PRICE_CLOSE, Current + MASHIFT5); double CloseBuy3_2 = iMA(NULL, 0, MAPERIODECB2, MAMASHIFT, MODE10, PRICE_CLOSE, Current + MASHIFT5); double CloseBuy4_1 = iMA(NULL, 0, MAPERIODECB1, MAMASHIFT, MODE11, PRICE_CLOSE, Current + MASHIFT6); double CloseBuy4_2 = iMA(NULL, 0, MAPERIODECB2, MAMASHIFT, MODE12, PRICE_CLOSE, Current + MASHIFT6); double CloseSell1_1 = iRSI(NULL, 0, RSIPERIODECS1, PRICE_CLOSE, Current + RSISHIFT1); double CloseSell1_2 = 50; double CloseSell2_1 = iRSI(NULL, 0, RSIPERIODECS2, PRICE_CLOSE, Current + RSISHIFT2); double CloseSell2_2 = 50; double CloseSell3_1 = iMA(NULL, 0, MAPERIODECS1, MAMASHIFT, MODE13, PRICE_CLOSE, Current + MASHIFT7); double CloseSell3_2 = iMA(NULL, 0, MAPERIODECS2, MAMASHIFT, MODE14, PRICE_CLOSE, Current + MASHIFT7); double CloseSell4_1 = iMA(NULL, 0, MAPERIODECS1, MAMASHIFT, MODE15, PRICE_CLOSE, Current + MASHIFT8); double CloseSell4_2 = iMA(NULL, 0, MAPERIODECS2, MAMASHIFT, MODE16, PRICE_CLOSE, Current + MASHIFT8); //+------------------------------------------------------------------+ //| Variable End | //+------------------------------------------------------------------+ //Check position bool IsTrade = False; for (int i = 0; i < Total; i ++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(OrderType() <= OP_SELL && OrderSymbol() == Symbol()) { IsTrade = True; if(OrderType() == OP_BUY) { //Close //+------------------------------------------------------------------+ //| Signal Begin(Exit Buy) | //+------------------------------------------------------------------+ if ((CloseBuy1_1 > CloseBuy1_2 && CloseBuy2_1 < CloseBuy2_2) || (CloseBuy3_1 > CloseBuy3_2 && CloseBuy4_1 < CloseBuy4_2)) Order = SIGNAL_CLOSEBUY; //+------------------------------------------------------------------+ //| Signal End(Exit Buy) | //+------------------------------------------------------------------+ if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) { OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy"); if (!EachTickMode) BarCount = Bars; IsTrade = False; continue; } //Trailing stop if(UseTrailingStop && TrailingStop > 0) { if(Bid - OrderOpenPrice() > Point * TrailingStop) { if(OrderStopLoss() < Bid - Point * TrailingStop) { OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen); if (!EachTickMode) BarCount = Bars; continue; } } } } else { //Close //+------------------------------------------------------------------+ //| Signal Begin(Exit Sell) | //+------------------------------------------------------------------+ if ((CloseSell1_1 < CloseSell1_2 && CloseSell2_1 > CloseSell2_2) || (CloseSell3_1 < CloseSell3_2 && CloseSell4_1 > CloseSell4_2)) Order = SIGNAL_CLOSESELL; //+------------------------------------------------------------------+ //| Signal End(Exit Sell) | //+------------------------------------------------------------------+ if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) { OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell"); if (!EachTickMode) BarCount = Bars; IsTrade = False; continue; } //Trailing stop if(UseTrailingStop && TrailingStop > 0) { if((OrderOpenPrice() - Ask) > (Point * TrailingStop)) { if((OrderStopLoss() > (Ask + Point * TrailingStop)) || (OrderStopLoss() == 0)) { OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingStop, OrderTakeProfit(), 0, DarkOrange); if (!EachTickMode) BarCount = Bars; continue; } } } } } } //+------------------------------------------------------------------+ //| Signal Begin(Entry) | //+------------------------------------------------------------------+ if (Buy1_1 < Buy1_2 && Buy2_1 > Buy2_2) Order = SIGNAL_BUY == RSI == true; if (Buy3_1 < Buy3_2 && Buy4_1 > Buy4_2) Order = SIGNAL_BUY == MM == true; if (Sell1_1 > Sell1_2 && Sell2_1 < Sell2_2) Order = SIGNAL_SELL == RSI == true; if (Sell3_1 > Sell3_2 && Sell4_1 < Sell4_2) Order = SIGNAL_SELL == MM == true; //+------------------------------------------------------------------+ //| Signal End | //+------------------------------------------------------------------+ //Buy if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) { if(!IsTrade) { //Check free margin if (AccountFreeMargin() < (1000 * Lots)) { Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } if (UseStopLoss) StopLossLevel = Ask - StopLoss * Point; else StopLossLevel = 0.0; if (UseTakeProfit) TakeProfitLevel = Ask + TakeProfit * Point; else TakeProfitLevel = 0.0; Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue); if(Ticket > 0) { if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) { Print("BUY order opened : ", OrderOpenPrice()); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy"); } else { Print("Error opening BUY order : ", GetLastError()); } } if (EachTickMode) TickCheck = True; if (!EachTickMode) BarCount = Bars; return(0); } } //Sell if (Order == SIGNAL_SELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) { if(!IsTrade) { //Check free margin if (AccountFreeMargin() < (1000 * Lots)) { Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } if (UseStopLoss) StopLossLevel = Bid + StopLoss * Point; else StopLossLevel = 0.0; if (UseTakeProfit) TakeProfitLevel = Bid - TakeProfit * Point; else TakeProfitLevel = 0.0; Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLossLevel, TakeProfitLevel, "Sell(#" + MagicNumber + ")", MagicNumber, 0, DeepPink); if(Ticket > 0) { if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) { Print("SELL order opened : ", OrderOpenPrice()); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Open Sell"); } else { Print("Error opening SELL order : ", GetLastError()); } } if (EachTickMode) TickCheck = True; if (!EachTickMode) BarCount = Bars; return(0); } } if (!EachTickMode) BarCount = Bars; return(0); } //+------------------------------------------------------------------+
    Modifié le 2012-09-04 09:44:21 par AliX
  • beans72 — en réponse à lefeuvr3 dans son message #57280

    Bonsoir,
    JE ne vois les modifs apportées
    J'ai essayé le premier set OK il fonctionne
    Le second modifié ne démarre pas :(
  • lefeuvr3

    Voila les modifications mais elles ne me satisfont pas non plus ...je chercher encore....
    Code
    //Paramètres RSI extern string separator1 = "*** RSI Settings ***"; extern bool RSI = True; //Paramètres MA extern string separator2 = "*** MA Settings ***"; extern bool MM = True; //+------------------------------------------------------------------+ //| Signal Begin(Entry) | //+------------------------------------------------------------------+ if (Buy1_1 < Buy1_2 && Buy2_1 > Buy2_2) Order = SIGNAL_BUY == RSI == true; if (Buy3_1 < Buy3_2 && Buy4_1 > Buy4_2) Order = SIGNAL_BUY == MM == true; if (Sell1_1 > Sell1_2 && Sell2_1 < Sell2_2) Order = SIGNAL_SELL == RSI == true; if (Sell3_1 > Sell3_2 && Sell4_1 < Sell4_2) Order = SIGNAL_SELL == MM == true;
    Modifié le 2012-09-04 09:45:56 par AliX
  • lefeuvr3

    Il fonctionne mais les resultats obtenus ne correspondent pas à celuis sans les extern bool :(

    Code
    extern bool RSI = True; extern bool MM = True;
    Modifié le 2012-09-04 09:46:44 par AliX
  • stepaustras

    La vidéo que t'as faite est très intéressante j'aimerais bien optimiser mon EA qui a de bon résultat et ta stratégie que j'ai vu dans tes vidéos me donne des idées supp notamment sur l'optimisation d'un EA en rajoutant des extern int ou bool pour savoir lequel indicateur travail le mieux a tel moment ou quoi.
    Par contre pour ton EA je vois que par exemple pour analyser chaque entrée il faudrait peu être que tu lui donne plus d'option de choix
    if (Buy1_1 < Buy1_2 && Buy2_1 > Buy2_2) Order = SIGNAL_BUY == RSI == true;
    if (Buy3_1 < Buy3_2 && Buy4_1 > Buy4_2) Order = SIGNAL_BUY == MM == true;

    Tu pourrais lui rajouter d'autre IF car là il se cantonne qu'a deux entrée pour un buy ou peu être même à la rigueur rajouter un false ou true sur chaque RSI ou MA
    Si tu veux je peux te décomposer ton EA si tu m'en dis plus si il a 4 trades différents ou autre
    Sinon j'ai vu que tu te servais du site pour faire tes EA il serais en faite judicieux d'utiliser les variables pour décomposer ton EA pour les false et true pour une action d'achat d'un certain buy tu met une variable nommé A par exemple et int = A; et tu rajoute ton extern bool = false ou true.
    Sinon a quoi il servent les mode 1 a 16 ils sont inutiles ?
    Modifié le 2012-11-03 19:24:47 par stepaustras
  • lefeuvr3

    OK je refais un programme avec plus de critères d'entée et en diminuant les paramètres superflus
  • stepaustras — en réponse à lefeuvr3 dans son message #60420

    Après je voudrais pas dire de connerie mais il me semble que la formule que tu as mis avec les MM == true ça risque pas de bien fonctionner si la variable MM n'est pas déclaré dans le bloc Variable Begin et idem pour RSI
    Modifié le 2012-11-04 17:45:55 par stepaustras
  • lefeuvr3

    OK je les vire les MM == true
  • lefeuvr3

    NOUVEAU PROGRAMME
    lefeuvr3 a joint une image
    comment-debrayer-un-indicateur-d-un-ea-quand-il-y-en-a-plusieurs-sur-le-meme-ea-5963
  • lefeuvr3

    RESULTATS
    lefeuvr3 a joint une image
    comment-debrayer-un-indicateur-d-un-ea-quand-il-y-en-a-plusieurs-sur-le-meme-ea-5964
  • lefeuvr3

    PROGRAMME EN UT 15 SUR LE CACOUNET alias CAC40
    a backtester de temps en temps par paquet de quatre parametres rajouté a chaque fois au precedent paquet
    Son Nom le RSI or CCI or WPR or MA
    Code
    //+------------------------------------------------------------------+ //| This MQL is generated by Expert Advisor Builder | //| http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/ | //| | //| In no event will author be liable for any damages whatsoever. | //| Use at your own risk. | //| | //+------------------- DO NOT REMOVE THIS HEADER --------------------+ #define SIGNAL_NONE 0 #define SIGNAL_BUY 1 #define SIGNAL_SELL 2 #define SIGNAL_CLOSEBUY 3 #define SIGNAL_CLOSESELL 4 #property copyright "Expert Advisor Builder" #property link "http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/" extern int MagicNumber = 0; extern bool SignalMail = False; extern bool EachTickMode = False; extern double Lots = 1; extern int Slippage = 3; extern string separator1 = "*** Sortie de trade TP+SL true ou False ***"; extern bool UseStopLoss = False; extern int StopLoss = 30; extern bool UseTakeProfit = False; extern int TakeProfit = 60; extern bool UseTrailingStop = False; extern int TrailingStop = 30; extern int max_trades = 4; extern string separator14 = "*** Backtest à réaliser en rajoutant 4 nouveaux parametres a chaque fois ***"; extern string separator2 = "*** RSI Settings ***"; //Paramètres RSI extern string separator3 = "*** RSI buy et close buy ***"; extern int RSIPERIODEB1 = 18; extern int RSIPERIODEB2 = 137; extern int RSIPERIODECB1 = 277; extern int RSIPERIODECB2 = 292; extern string separator4 = "*** RSI sell et close sell ***"; extern int RSIPERIODES1 = 319; extern int RSIPERIODES2 = 14; extern int RSIPERIODECS1 = 248; extern int RSIPERIODECS2 = 1; extern string separator5 = "*** WPR Settings ***"; //Paramètres WPR extern string separator6 = "*** WPR buy et close buy ***"; extern int WPRPERIODEB1 = 319; extern int WPRPERIODEB2 =10; extern int WPRPERIODECB1 = 487; extern int WPRPERIODECB2 = 64; extern string separator7 = "*** WPR sell et close sell ***"; extern int WPRPERIODES1 = 428; extern int WPRPERIODES2 = 600; extern int WPRPERIODECS1 = 458; extern int WPRPERIODECS2 = 389; extern string separator8 = "*** CCI Settings ***"; //Paramètres CCI extern string separator9 = "*** CCI buy et close buy ***"; extern int CCIPERIODEB1 = 427; extern int CCIPERIODEB2 = 330; extern int CCIPERIODECB1 = 1; extern int CCIPERIODECB2 = 118; extern string separator10 = "*** CCI sell et close sell ***"; extern int CCIPERIODES1 = 5; extern int CCIPERIODES2 = 1; extern int CCIPERIODECS1 = 1; extern int CCIPERIODECS2 = 5; extern string separator11 = "*** MA Settings ***"; //Paramètres MA extern string separator12 = "*** MA buy et close buy ***"; extern int MAPERIODEB1 = 268; extern int MAPERIODEB2 = 256; extern int MAPERIODECB1 = 158; extern int MAPERIODECB2 = 305; extern string separator13 = "*** MA sell et close sell ***"; extern int MAPERIODES1 = 295; extern int MAPERIODES2 = 243; extern int MAPERIODECS1 = 391; extern int MAPERIODECS2 = 115; int BarCount; int Current; bool TickCheck = False; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { BarCount = Bars; if (EachTickMode) Current = 0; else Current = 1; return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { int Order = SIGNAL_NONE; int Total, Ticket; double StopLossLevel, TakeProfitLevel; if (EachTickMode && Bars != BarCount) TickCheck = False; Total = OrdersTotal(); Order = SIGNAL_NONE; //+------------------------------------------------------------------+ //| Variable Begin | //+------------------------------------------------------------------+ double Buy1_1 = iRSI(NULL, 0, RSIPERIODEB1, PRICE_CLOSE, Current + 1); double Buy1_2 = 50; double Buy2_1 = iRSI(NULL, 0, RSIPERIODEB2, PRICE_CLOSE, Current + 0); double Buy2_2 = 50; double Buy3_1 = iWPR(NULL, 0, WPRPERIODEB1, Current + 1); double Buy3_2 = -50; double Buy4_1 = iWPR(NULL, 0, WPRPERIODEB2, Current + 0); double Buy4_2 = -50; double Buy5_1 = iCCI(NULL, 0, CCIPERIODEB1, PRICE_CLOSE, Current + 1); double Buy5_2 = 0; double Buy6_1 = iCCI(NULL, 0, CCIPERIODEB2, PRICE_CLOSE, Current + 0); double Buy6_2 = 0; double Buy7_1 = iMA(NULL, 0, MAPERIODEB1, 0, 0, PRICE_CLOSE, Current + 1); double Buy7_2 = iMA(NULL, 0, MAPERIODEB2, 0, 0, PRICE_CLOSE, Current + 1); double Buy8_1 = iMA(NULL, 0, MAPERIODEB1, 0, 0, PRICE_CLOSE, Current + 0); double Buy8_2 = iMA(NULL, 0, MAPERIODEB2, 0, 0, PRICE_CLOSE, Current + 0); double Sell1_1 = iRSI(NULL, 0, RSIPERIODES1, PRICE_CLOSE, Current + 1); double Sell1_2 = 50; double Sell2_1 = iRSI(NULL, 0, RSIPERIODES2, PRICE_CLOSE, Current + 0); double Sell2_2 = 50; double Sell3_1 = iWPR(NULL, 0, WPRPERIODES1, Current + 1); double Sell3_2 = -50; double Sell4_1 = iWPR(NULL, 0, WPRPERIODES2, Current + 0); double Sell4_2 = -50; double Sell5_1 = iCCI(NULL, 0, CCIPERIODES1, PRICE_CLOSE, Current + 1); double Sell5_2 = 0; double Sell6_1 = iCCI(NULL, 0, CCIPERIODES2, PRICE_CLOSE, Current + 0); double Sell6_2 = 0; double Sell7_1 = iMA(NULL, 0, MAPERIODES1, 0, 0, PRICE_CLOSE, Current + 1); double Sell7_2 = iMA(NULL, 0, MAPERIODES2, 0, 0, PRICE_CLOSE, Current + 1); double Sell8_1 = iMA(NULL, 0, MAPERIODES1, 0, 0, PRICE_CLOSE, Current + 0); double Sell8_2 = iMA(NULL, 0, MAPERIODES2, 0, 0, PRICE_CLOSE, Current + 0); double CloseBuy1_1 = iRSI(NULL, 0, RSIPERIODECB1, PRICE_CLOSE, Current + 1); double CloseBuy1_2 = 50; double CloseBuy2_1 = iRSI(NULL, 0, RSIPERIODECB2, PRICE_CLOSE, Current +0); double CloseBuy2_2 = 50; double CloseBuy3_1 = iWPR(NULL, 0, WPRPERIODECB1, Current + 1); double CloseBuy3_2 = -50; double CloseBuy4_1 = iWPR(NULL, 0, WPRPERIODECB2, Current + 02); double CloseBuy4_2 = -50; double CloseBuy5_1 = iCCI(NULL, 0, CCIPERIODECB1, PRICE_CLOSE, Current + 1); double CloseBuy5_2 = 0; double CloseBuy6_1 = iCCI(NULL, 0, CCIPERIODECB2, PRICE_CLOSE, Current + 0); double CloseBuy6_2 = 0; double CloseBuy7_1 = iMA(NULL, 0, MAPERIODECB1, 0, 0, PRICE_CLOSE, Current + 1); double CloseBuy7_2 = iMA(NULL, 0, MAPERIODECB2, 0, 0, PRICE_CLOSE, Current + 1); double CloseBuy8_1 = iMA(NULL, 0, MAPERIODECB1, 0, 0, PRICE_CLOSE, Current + 0); double CloseBuy8_2 = iMA(NULL, 0, MAPERIODECB2, 0, 0, PRICE_CLOSE, Current + 0); double CloseSell1_1 = iRSI(NULL, 0, RSIPERIODECS1, PRICE_CLOSE, Current + 1); double CloseSell1_2 = 50; double CloseSell2_1 = iRSI(NULL, 0, RSIPERIODECS2, PRICE_CLOSE, Current + 0); double CloseSell2_2 = 50; double CloseSell3_1 = iWPR(NULL, 0, WPRPERIODECS1, Current + 1); double CloseSell3_2 = -50; double CloseSell4_1 = iWPR(NULL, 0, WPRPERIODECS2, Current + 0); double CloseSell4_2 = -50; double CloseSell5_1 = iCCI(NULL, 0, CCIPERIODECS1, PRICE_CLOSE, Current + 1); double CloseSell5_2 = 0; double CloseSell6_1 = iCCI(NULL, 0, CCIPERIODECS2, PRICE_CLOSE, Current + 0); double CloseSell6_2 = 0; double CloseSell7_1 = iMA(NULL, 0, MAPERIODECS1, 0, 0, PRICE_CLOSE, Current + 1); double CloseSell7_2 = iMA(NULL, 0, MAPERIODECS2, 0, 0, PRICE_CLOSE, Current + 1); double CloseSell8_1 = iMA(NULL, 0, MAPERIODECS1, 0, 0, PRICE_CLOSE, Current + 0); double CloseSell8_2 = iMA(NULL, 0, MAPERIODECS2, 0, 0, PRICE_CLOSE, Current + 0); //+------------------------------------------------------------------+ //| Variable End | //+------------------------------------------------------------------+ //Check position bool IsTrade = False; //for (int i = 0; i < Total; i ++) { // à modifier comme suit trades multiples for (int i = max_trades-1; i < Total; i ++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(OrderType() <= OP_SELL && OrderSymbol() == Symbol()) { IsTrade = True; if(OrderType() == OP_BUY) { //Close //+------------------------------------------------------------------+ //| Signal Begin(Exit Buy) | //+------------------------------------------------------------------+ if ((CloseBuy1_1 > CloseBuy1_2 && CloseBuy2_1 < CloseBuy2_2) || (CloseBuy3_1 > CloseBuy3_2 && CloseBuy4_1 < CloseBuy4_2) || (CloseBuy5_1 > CloseBuy5_2 && CloseBuy6_1 < CloseBuy6_2) || (CloseBuy7_1 > CloseBuy7_2 && CloseBuy8_1 < CloseBuy8_2)) Order = SIGNAL_CLOSEBUY; //+------------------------------------------------------------------+ //| Signal End(Exit Buy) | //+------------------------------------------------------------------+ if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) { OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy"); if (!EachTickMode) BarCount = Bars; IsTrade = False; continue; } //Trailing stop if(UseTrailingStop && TrailingStop > 0) { if(Bid - OrderOpenPrice() > Point * TrailingStop) { if(OrderStopLoss() < Bid - Point * TrailingStop) { OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen); if (!EachTickMode) BarCount = Bars; continue; } } } } else { //Close //+------------------------------------------------------------------+ //| Signal Begin(Exit Sell) | //+------------------------------------------------------------------+ if ((CloseSell1_1 < CloseSell1_2 && CloseSell2_1 > CloseSell2_2) || (CloseSell3_1 < CloseSell3_2 && CloseSell4_1 > CloseSell4_2) || (CloseSell5_1 < CloseSell5_2 && CloseSell6_1 > CloseSell6_2) || (CloseSell7_1 < CloseSell7_2 && CloseSell8_1 > CloseSell8_2)) Order = SIGNAL_CLOSESELL; //+------------------------------------------------------------------+ //| Signal End(Exit Sell) | //+------------------------------------------------------------------+ if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) { OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell"); if (!EachTickMode) BarCount = Bars; IsTrade = False; continue; } //Trailing stop if(UseTrailingStop && TrailingStop > 0) { if((OrderOpenPrice() - Ask) > (Point * TrailingStop)) { if((OrderStopLoss() > (Ask + Point * TrailingStop)) || (OrderStopLoss() == 0)) { OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingStop, OrderTakeProfit(), 0, DarkOrange); if (!EachTickMode) BarCount = Bars; continue; } } } } } } //+------------------------------------------------------------------+ //| Signal Begin(Entry) | //+------------------------------------------------------------------+ if ((Buy1_1 < Buy1_2 && Buy2_1 > Buy2_2) || (Buy3_1 < Buy3_2 && Buy4_1 > Buy4_2) || (Buy5_1 < Buy5_2 && Buy6_1 > Buy6_2) ||( Buy7_1 < Buy7_2 && Buy8_1 > Buy8_2)) Order = SIGNAL_BUY; if ((Sell1_1 > Sell1_2 && Sell2_1 < Sell2_2) || (Sell3_1 > Sell3_2 && Sell4_1 < Sell4_2) || (Sell5_1 > Sell5_2 && Sell6_1 < Sell6_2) || (Sell7_1 > Sell7_2 && Sell8_1 < Sell8_2)) Order = SIGNAL_SELL; //+------------------------------------------------------------------+ //| Signal End | //+------------------------------------------------------------------+ //Buy if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) { if(!IsTrade) { //Check free margin if (AccountFreeMargin() < (10 * Lots)) { Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } if (UseStopLoss) StopLossLevel = Ask - StopLoss * Point; else StopLossLevel = 0.0; if (UseTakeProfit) TakeProfitLevel = Ask + TakeProfit * Point; else TakeProfitLevel = 0.0; Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue); if(Ticket > 0) { if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) { Print("BUY order opened : ", OrderOpenPrice()); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy"); } else { Print("Error opening BUY order : ", GetLastError()); } } if (EachTickMode) TickCheck = True; if (!EachTickMode) BarCount = Bars; return(0); } } //Sell if (Order == SIGNAL_SELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) { if(!IsTrade) { //Check free margin if (AccountFreeMargin() < (10 * Lots)) { Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } if (UseStopLoss) StopLossLevel = Bid + StopLoss * Point; else StopLossLevel = 0.0; if (UseTakeProfit) TakeProfitLevel = Bid - TakeProfit * Point; else TakeProfitLevel = 0.0; Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLossLevel, TakeProfitLevel, "Sell(#" + MagicNumber + ")", MagicNumber, 0, DeepPink); if(Ticket > 0) { if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) { Print("SELL order opened : ", OrderOpenPrice()); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Open Sell"); } else { Print("Error opening SELL order : ", GetLastError()); } } if (EachTickMode) TickCheck = True; if (!EachTickMode) BarCount = Bars; return(0); } } if (!EachTickMode) BarCount = Bars; return(0); } //+------------------------------------------------------------------+
    Modifié le 2012-11-05 20:28:21 par AliX
  • stepaustras — en réponse à lefeuvr3 dans son message #60556

    super sympa ton partage par contre utilise les balises BBCODE [code" et a la fin [/code" pour inclure le code dans le post lol car il y a des smiles inattendu ;) j'ai fais exprès d'oublier le ] a la fin sinon ça se voit pas mais ça donne ça j'ai mis des " pour remplacer les ]

    Code
    //+------------------------------------------------------------------+ //| This MQL is generated by Expert Advisor Builder | //| http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/ | //| | //| In no event will author be liable for any damages whatsoever. | //| Use at your own risk. | //| | //+------------------- DO NOT REMOVE THIS HEADER --------------------+ #define SIGNAL_NONE 0 #define SIGNAL_BUY 1 #define SIGNAL_SELL 2 #define SIGNAL_CLOSEBUY 3 #define SIGNAL_CLOSESELL 4 #property copyright "Expert Advisor Builder" #property link "http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/" extern int MagicNumber = 0; extern bool SignalMail = False; extern bool EachTickMode = False; extern double Lots = 1; extern int Slippage = 3; extern string separator1 = "*** Sortie de trade TP+SL true ou False ***"; extern bool UseStopLoss = False; extern int StopLoss = 30; extern bool UseTakeProfit = False; extern int TakeProfit = 60; extern bool UseTrailingStop = False; extern int TrailingStop = 30; extern int max_trades = 4; extern string separator14 = "*** Backtest à réaliser en rajoutant 4 nouveaux parametres a chaque fois ***"; extern string separator2 = "*** RSI Settings ***"; //Paramètres RSI extern string separator3 = "*** RSI buy et close buy ***"; extern int RSIPERIODEB1 = 18; extern int RSIPERIODEB2 = 137; extern int RSIPERIODECB1 = 277; extern int RSIPERIODECB2 = 292; extern string separator4 = "*** RSI sell et close sell ***"; extern int RSIPERIODES1 = 319; extern int RSIPERIODES2 = 14; extern int RSIPERIODECS1 = 248; extern int RSIPERIODECS2 = 1; extern string separator5 = "*** WPR Settings ***"; //Paramètres WPR extern string separator6 = "*** WPR buy et close buy ***"; extern int WPRPERIODEB1 = 319; extern int WPRPERIODEB2 =10; extern int WPRPERIODECB1 = 487; extern int WPRPERIODECB2 = 64; extern string separator7 = "*** WPR sell et close sell ***"; extern int WPRPERIODES1 = 428; extern int WPRPERIODES2 = 600; extern int WPRPERIODECS1 = 458; extern int WPRPERIODECS2 = 389; extern string separator8 = "*** CCI Settings ***"; //Paramètres CCI extern string separator9 = "*** CCI buy et close buy ***"; extern int CCIPERIODEB1 = 427; extern int CCIPERIODEB2 = 330; extern int CCIPERIODECB1 = 1; extern int CCIPERIODECB2 = 118; extern string separator10 = "*** CCI sell et close sell ***"; extern int CCIPERIODES1 = 5; extern int CCIPERIODES2 = 1; extern int CCIPERIODECS1 = 1; extern int CCIPERIODECS2 = 5; extern string separator11 = "*** MA Settings ***"; //Paramètres MA extern string separator12 = "*** MA buy et close buy ***"; extern int MAPERIODEB1 = 268; extern int MAPERIODEB2 = 256; extern int MAPERIODECB1 = 158; extern int MAPERIODECB2 = 305; extern string separator13 = "*** MA sell et close sell ***"; extern int MAPERIODES1 = 295; extern int MAPERIODES2 = 243; extern int MAPERIODECS1 = 391; extern int MAPERIODECS2 = 115; int BarCount; int Current; bool TickCheck = False; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { BarCount = Bars; if (EachTickMode) Current = 0; else Current = 1; return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { int Order = SIGNAL_NONE; int Total, Ticket; double StopLossLevel, TakeProfitLevel; if (EachTickMode && Bars != BarCount) TickCheck = False; Total = OrdersTotal(); Order = SIGNAL_NONE; //+------------------------------------------------------------------+ //| Variable Begin | //+------------------------------------------------------------------+ double Buy1_1 = iRSI(NULL, 0, RSIPERIODEB1, PRICE_CLOSE, Current + 1); double Buy1_2 = 50; double Buy2_1 = iRSI(NULL, 0, RSIPERIODEB2, PRICE_CLOSE, Current + 0); double Buy2_2 = 50; double Buy3_1 = iWPR(NULL, 0, WPRPERIODEB1, Current + 1); double Buy3_2 = -50; double Buy4_1 = iWPR(NULL, 0, WPRPERIODEB2, Current + 0); double Buy4_2 = -50; double Buy5_1 = iCCI(NULL, 0, CCIPERIODEB1, PRICE_CLOSE, Current + 1); double Buy5_2 = 0; double Buy6_1 = iCCI(NULL, 0, CCIPERIODEB2, PRICE_CLOSE, Current + 0); double Buy6_2 = 0; double Buy7_1 = iMA(NULL, 0, MAPERIODEB1, 0, 0, PRICE_CLOSE, Current + 1); double Buy7_2 = iMA(NULL, 0, MAPERIODEB2, 0, 0, PRICE_CLOSE, Current + 1); double Buy8_1 = iMA(NULL, 0, MAPERIODEB1, 0, 0, PRICE_CLOSE, Current + 0); double Buy8_2 = iMA(NULL, 0, MAPERIODEB2, 0, 0, PRICE_CLOSE, Current + 0); double Sell1_1 = iRSI(NULL, 0, RSIPERIODES1, PRICE_CLOSE, Current + 1); double Sell1_2 = 50; double Sell2_1 = iRSI(NULL, 0, RSIPERIODES2, PRICE_CLOSE, Current + 0); double Sell2_2 = 50; double Sell3_1 = iWPR(NULL, 0, WPRPERIODES1, Current + 1); double Sell3_2 = -50; double Sell4_1 = iWPR(NULL, 0, WPRPERIODES2, Current + 0); double Sell4_2 = -50; double Sell5_1 = iCCI(NULL, 0, CCIPERIODES1, PRICE_CLOSE, Current + 1); double Sell5_2 = 0; double Sell6_1 = iCCI(NULL, 0, CCIPERIODES2, PRICE_CLOSE, Current + 0); double Sell6_2 = 0; double Sell7_1 = iMA(NULL, 0, MAPERIODES1, 0, 0, PRICE_CLOSE, Current + 1); double Sell7_2 = iMA(NULL, 0, MAPERIODES2, 0, 0, PRICE_CLOSE, Current + 1); double Sell8_1 = iMA(NULL, 0, MAPERIODES1, 0, 0, PRICE_CLOSE, Current + 0); double Sell8_2 = iMA(NULL, 0, MAPERIODES2, 0, 0, PRICE_CLOSE, Current + 0); double CloseBuy1_1 = iRSI(NULL, 0, RSIPERIODECB1, PRICE_CLOSE, Current + 1); double CloseBuy1_2 = 50; double CloseBuy2_1 = iRSI(NULL, 0, RSIPERIODECB2, PRICE_CLOSE, Current +0); double CloseBuy2_2 = 50; double CloseBuy3_1 = iWPR(NULL, 0, WPRPERIODECB1, Current + 1); double CloseBuy3_2 = -50; double CloseBuy4_1 = iWPR(NULL, 0, WPRPERIODECB2, Current + 02); double CloseBuy4_2 = -50; double CloseBuy5_1 = iCCI(NULL, 0, CCIPERIODECB1, PRICE_CLOSE, Current + 1); double CloseBuy5_2 = 0; double CloseBuy6_1 = iCCI(NULL, 0, CCIPERIODECB2, PRICE_CLOSE, Current + 0); double CloseBuy6_2 = 0; double CloseBuy7_1 = iMA(NULL, 0, MAPERIODECB1, 0, 0, PRICE_CLOSE, Current + 1); double CloseBuy7_2 = iMA(NULL, 0, MAPERIODECB2, 0, 0, PRICE_CLOSE, Current + 1); double CloseBuy8_1 = iMA(NULL, 0, MAPERIODECB1, 0, 0, PRICE_CLOSE, Current + 0); double CloseBuy8_2 = iMA(NULL, 0, MAPERIODECB2, 0, 0, PRICE_CLOSE, Current + 0); double CloseSell1_1 = iRSI(NULL, 0, RSIPERIODECS1, PRICE_CLOSE, Current + 1); double CloseSell1_2 = 50; double CloseSell2_1 = iRSI(NULL, 0, RSIPERIODECS2, PRICE_CLOSE, Current + 0); double CloseSell2_2 = 50; double CloseSell3_1 = iWPR(NULL, 0, WPRPERIODECS1, Current + 1); double CloseSell3_2 = -50; double CloseSell4_1 = iWPR(NULL, 0, WPRPERIODECS2, Current + 0); double CloseSell4_2 = -50; double CloseSell5_1 = iCCI(NULL, 0, CCIPERIODECS1, PRICE_CLOSE, Current + 1); double CloseSell5_2 = 0; double CloseSell6_1 = iCCI(NULL, 0, CCIPERIODECS2, PRICE_CLOSE, Current + 0); double CloseSell6_2 = 0; double CloseSell7_1 = iMA(NULL, 0, MAPERIODECS1, 0, 0, PRICE_CLOSE, Current + 1); double CloseSell7_2 = iMA(NULL, 0, MAPERIODECS2, 0, 0, PRICE_CLOSE, Current + 1); double CloseSell8_1 = iMA(NULL, 0, MAPERIODECS1, 0, 0, PRICE_CLOSE, Current + 0); double CloseSell8_2 = iMA(NULL, 0, MAPERIODECS2, 0, 0, PRICE_CLOSE, Current + 0); //+------------------------------------------------------------------+ //| Variable End | //+------------------------------------------------------------------+ //Check position bool IsTrade = False; //for (int i = 0; i < Total; i ++) { // à modifier comme suit trades multiples for (int i = max_trades-1; i < Total; i ++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(OrderType() <= OP_SELL && OrderSymbol() == Symbol()) { IsTrade = True; if(OrderType() == OP_BUY) { //Close //+------------------------------------------------------------------+ //| Signal Begin(Exit Buy) | //+------------------------------------------------------------------+ if ((CloseBuy1_1 > CloseBuy1_2 && CloseBuy2_1 < CloseBuy2_2) || (CloseBuy3_1 > CloseBuy3_2 && CloseBuy4_1 < CloseBuy4_2) || (CloseBuy5_1 > CloseBuy5_2 && CloseBuy6_1 < CloseBuy6_2) || (CloseBuy7_1 > CloseBuy7_2 && CloseBuy8_1 < CloseBuy8_2)) Order = SIGNAL_CLOSEBUY; //+------------------------------------------------------------------+ //| Signal End(Exit Buy) | //+------------------------------------------------------------------+ if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) { OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy"); if (!EachTickMode) BarCount = Bars; IsTrade = False; continue; } //Trailing stop if(UseTrailingStop && TrailingStop > 0) { if(Bid - OrderOpenPrice() > Point * TrailingStop) { if(OrderStopLoss() < Bid - Point * TrailingStop) { OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen); if (!EachTickMode) BarCount = Bars; continue; } } } } else { //Close //+------------------------------------------------------------------+ //| Signal Begin(Exit Sell) | //+------------------------------------------------------------------+ if ((CloseSell1_1 < CloseSell1_2 && CloseSell2_1 > CloseSell2_2) || (CloseSell3_1 < CloseSell3_2 && CloseSell4_1 > CloseSell4_2) || (CloseSell5_1 < CloseSell5_2 && CloseSell6_1 > CloseSell6_2) || (CloseSell7_1 < CloseSell7_2 && CloseSell8_1 > CloseSell8_2)) Order = SIGNAL_CLOSESELL; //+------------------------------------------------------------------+ //| Signal End(Exit Sell) | //+------------------------------------------------------------------+ if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) { OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell"); if (!EachTickMode) BarCount = Bars; IsTrade = False; continue; } //Trailing stop if(UseTrailingStop && TrailingStop > 0) { if((OrderOpenPrice() - Ask) > (Point * TrailingStop)) { if((OrderStopLoss() > (Ask + Point * TrailingStop)) || (OrderStopLoss() == 0)) { OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingStop, OrderTakeProfit(), 0, DarkOrange); if (!EachTickMode) BarCount = Bars; continue; } } } } } } //+------------------------------------------------------------------+ //| Signal Begin(Entry) | //+------------------------------------------------------------------+ if ((Buy1_1 < Buy1_2 && Buy2_1 > Buy2_2) || (Buy3_1 < Buy3_2 && Buy4_1 > Buy4_2) || (Buy5_1 < Buy5_2 && Buy6_1 > Buy6_2) ||( Buy7_1 < Buy7_2 && Buy8_1 > Buy8_2)) Order = SIGNAL_BUY; if ((Sell1_1 > Sell1_2 && Sell2_1 < Sell2_2) || (Sell3_1 > Sell3_2 && Sell4_1 < Sell4_2) || (Sell5_1 > Sell5_2 && Sell6_1 < Sell6_2) || (Sell7_1 > Sell7_2 && Sell8_1 < Sell8_2)) Order = SIGNAL_SELL; //+------------------------------------------------------------------+ //| Signal End | //+------------------------------------------------------------------+ //Buy if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) { if(!IsTrade) { //Check free margin if (AccountFreeMargin() < (10 * Lots)) { Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } if (UseStopLoss) StopLossLevel = Ask - StopLoss * Point; else StopLossLevel = 0.0; if (UseTakeProfit) TakeProfitLevel = Ask + TakeProfit * Point; else TakeProfitLevel = 0.0; Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ";)", MagicNumber, 0, DodgerBlue); if(Ticket > 0) { if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) { Print("BUY order opened : ", OrderOpenPrice()); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy"); } else { Print("Error opening BUY order : ", GetLastError()); } } if (EachTickMode) TickCheck = True; if (!EachTickMode) BarCount = Bars; return(0); } } //Sell if (Order == SIGNAL_SELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) { if(!IsTrade) { //Check free margin if (AccountFreeMargin() < (10 * Lots)) { Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } if (UseStopLoss) StopLossLevel = Bid + StopLoss * Point; else StopLossLevel = 0.0; if (UseTakeProfit) TakeProfitLevel = Bid - TakeProfit * Point; else TakeProfitLevel = 0.0; Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLossLevel, TakeProfitLevel, "Sell(#" + MagicNumber + ";)", MagicNumber, 0, DeepPink); if(Ticket > 0) { if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) { Print("SELL order opened : ", OrderOpenPrice()); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Open Sell"); } else { Print("Error opening SELL order : ", GetLastError()); } } if (EachTickMode) TickCheck = True; if (!EachTickMode) BarCount = Bars; return(0); } } if (!EachTickMode) BarCount = Bars; return(0); } //+------------------------------------------------------------------+
    Modifié le 2012-11-05 17:31:06 par stepaustras
  • stepaustras

    Je t'ai envoyé message je met le code ici de ton robot modifié comme tu voulais au départ
    Code
    //+------------------------------------------------------------------+ //|                                                          CAC40.mq4 | //|                        Copyright 2012, MetaQuotes Software Corp. | //|                                        http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright 2012, MetaQuotes Software Corp." #property link      "http://www.metaquotes.net" #include <stdlib.mqh> #include <WinUser32.mqh> // exported variables extern string S1="---- Horaires du lundi ouverture ROBOT ------"; extern bool Monday39 = true; extern int HoursFrom48 = 4; extern int HoursTo48 = 24; extern string S2="------ Horaires ouverture du vendredi ROBOT ------"; extern bool Friday22 = true; extern int HoursFrom47 = 0; extern int HoursTo47 = 14; extern string S4="--- Horaires ouverture du mardi au jeudi ROBOT ---"; extern bool Tuesday11 = true; extern bool Wednesday11 = true; extern bool Thursday11 = true; extern int HoursFrom46 = 0; extern int HoursTo46 = 24; extern string S5="--- Horaires du vendredi fermeture ROBOT ------"; extern bool Friday41 = true; extern int HoursFrom40 = 18; extern int HoursTo40 = 20; extern string S6="--------- LOT ET SLIPPAGE ----------"; extern double BuyLots30 = 0.1; extern int BuySlippage30 = 3; extern double SellLots31 = 0.1; extern int SellSlippage31 = 3; extern double BuyLots84 = 0.1; extern int BuySlippage84 = 3; extern double SellLots85 = 0.1; extern int SellSlippage85 = 3; extern double BuyLots129 = 0.1; extern int BuySlippage129 = 3; extern double SellLots126 = 0.1; extern int SellSlippage126 = 3; extern double BuyLots161 = 0.1; extern int BuySlippage161 = 3; extern double SellLots160 = 0.1; extern int SellSlippage160 = 3; // local variables double PipValue=1; // this variable is here to support 5-digit brokers bool Terminated = false; string LF = "\n"; // use this in custom or utility blocks where you need line feeds int NDigits = 4; // used mostly for NormalizeDouble in Flex type blocks int ObjCount = 0; // count of all objects created on the chart, allows creation of objects with unique names int current = 0; extern string S7="--- ROBOT A BUY ET SELL ---"; extern bool ROBOTABUY=true; extern bool ROBOTASELL=true; extern string S8="--- ROBOT B BUY ET SELL ---"; extern bool ROBOTBBUY=true; extern bool ROBOTBSELL=true; extern string S9="--- ROBOT C BUY ET SELL ---"; extern bool ROBOTCBUY=true; extern bool ROBOTCSELL=true; extern string S10="--- ROBOT D BUY ET SELL ---"; extern bool ROBOTDBUY=true; extern bool ROBOTDSELL=true; int init() { NDigits = Digits; if (false) ObjectsDeleteAll(); // clear the chart Comment(""); // clear the chart } // Expert start int start() { if (Bars < 10) { Comment("Not enough bars"); return (0); } if (Terminated == true) { Comment("EA Terminated."); return (0); } OnEveryTick3(); } void OnEveryTick3() { if (true == false && true) PipValue = 10; if (true && (NDigits == 3 || NDigits == 5)) PipValue = 10; WeekdayFilter39(); CustomCode59(); WeekdayFilter41(); TechnicalAnalysis2x49(); TechnicalAnalysis2x52(); TechnicalAnalysis2x88(); TechnicalAnalysis2x89(); TechnicalAnalysis2x136(); TechnicalAnalysis2x137(); TechnicalAnalysis2x172(); TechnicalAnalysis2x173(); } void WeekdayFilter39() { if ((Monday39 && DayOfWeek() == 1) || (true && DayOfWeek() == 2) || (true && DayOfWeek() == 3) || (true && DayOfWeek() == 4) || (true && DayOfWeek() == 5) || (true && DayOfWeek() == 6) || (true && DayOfWeek() == 0)) { HoursFilter48(); } } void HoursFilter48() { int datetime800 = TimeLocal(); int hour0 = TimeHour(datetime800); if ((HoursFrom48 < HoursTo48 && hour0 >= HoursFrom48 && hour0 < HoursTo48) || (HoursFrom48 > HoursTo48 && (hour0 < HoursTo48 || hour0 >= HoursFrom48))) { WeekdayFilter22(); } } void WeekdayFilter22() { if ((true && DayOfWeek() == 1) || (true && DayOfWeek() == 2) || (true && DayOfWeek() == 3) || (true && DayOfWeek() == 4) || (Friday22 && DayOfWeek() == 5) || (true && DayOfWeek() == 6) || (true && DayOfWeek() == 0)) { HoursFilter47(); } } void HoursFilter47() { int datetime800 = TimeLocal(); int hour0 = TimeHour(datetime800); if ((HoursFrom47 < HoursTo47 && hour0 >= HoursFrom47 && hour0 < HoursTo47) || (HoursFrom47 > HoursTo47 && (hour0 < HoursTo47 || hour0 >= HoursFrom47))) { WeekdayFilter11(); } } void WeekdayFilter11() { if ((true && DayOfWeek() == 1) || (Tuesday11 && DayOfWeek() == 2) || (Wednesday11 && DayOfWeek() == 3) || (Thursday11 && DayOfWeek() == 4) || (true && DayOfWeek() == 5) || (true && DayOfWeek() == 6) || (true && DayOfWeek() == 0)) { HoursFilter46(); } } void HoursFilter46() { int datetime800 = TimeLocal(); int hour0 = TimeHour(datetime800); if ((HoursFrom46 < HoursTo46 && hour0 >= HoursFrom46 && hour0 < HoursTo46) || (HoursFrom46 > HoursTo46 && (hour0 < HoursTo46 || hour0 >= HoursFrom46))) { CustomIf55(); CustomIf58(); CustomIf69(); CustomIf70(); CustomIf119(); CustomIf118(); CustomIf164(); CustomIf165(); } } void CustomIf55() { if (ROBOTABUY == true) { TechnicalAnalysis2x62(); } } void TechnicalAnalysis2x62() { if ((iRSI(NULL, NULL,18,PRICE_CLOSE,1) < 50) && (iRSI(NULL, NULL,137,PRICE_CLOSE,0) > 50)) { IfOrderDoesNotExist10(); } } void IfOrderDoesNotExist10() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 1) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists == false) { CustomCode56(); } } void CustomCode56() { ROBOTABUY=true; BuyOrder30(); } void BuyOrder30() { double SL = Ask - 0*PipValue*Point; if (0 == 0) SL = 0; double TP = Ask + 0*PipValue*Point; if (0 == 0) TP = 0; int ticket = -1; if (true) ticket = OrderSend(Symbol(), OP_BUY, BuyLots30, Ask, BuySlippage30, 0, 0, "My Expert", 1, 0, Blue); else ticket = OrderSend(Symbol(), OP_BUY, BuyLots30, Ask, BuySlippage30, SL, TP, "My Expert", 1, 0, Blue); if (ticket > -1) { if (true) { OrderSelect(ticket, SELECT_BY_TICKET); bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue); if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError())); } } else { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } void CustomIf58() { if (ROBOTASELL == true) { TechnicalAnalysis2x1(); } } void TechnicalAnalysis2x1() { if ((iRSI(NULL, NULL,319,PRICE_CLOSE,1) > 50) && (iRSI(NULL, NULL,14,PRICE_CLOSE,0) < 50)) { IfOrderDoesNotExist29(); } } void IfOrderDoesNotExist29() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 1) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists == false) { CustomCode57(); } } void CustomCode57() { ROBOTASELL=true; SellOrder31(); } void SellOrder31() { double SL = Bid + 0*PipValue*Point; if (0 == 0) SL = 0; double TP = Bid - 0*PipValue*Point; if (0 == 0) TP = 0; int ticket = -1; if (true) ticket = OrderSend(Symbol(), OP_SELL, SellLots31, Bid, SellSlippage31, 0, 0, "My Expert", 1, 0, Red); else ticket = OrderSend(Symbol(), OP_SELL, SellLots31, Bid, SellSlippage31, SL, TP, "My Expert", 1, 0, Red); if (ticket > -1) { if (true) { OrderSelect(ticket, SELECT_BY_TICKET); bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red); if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError())); } } else { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } void CustomIf69() { if (ROBOTBBUY == true) { TechnicalAnalysis2x60(); } } void TechnicalAnalysis2x60() { if ((iWPR(NULL, NULL,319,1) < -50) && (iWPR(NULL, NULL,10,0) > -50)) { IfOrderDoesNotExist67(); } } void IfOrderDoesNotExist67() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 2) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists == false) { CustomCode73(); } } void CustomCode73() { ROBOTBBUY=true; BuyOrder84(); } void BuyOrder84() { double SL = Ask - 0*PipValue*Point; if (0 == 0) SL = 0; double TP = Ask + 0*PipValue*Point; if (0 == 0) TP = 0; int ticket = -1; if (true) ticket = OrderSend(Symbol(), OP_BUY, BuyLots84, Ask, BuySlippage84, 0, 0, "My Expert", 2, 0, Blue); else ticket = OrderSend(Symbol(), OP_BUY, BuyLots84, Ask, BuySlippage84, SL, TP, "My Expert", 2, 0, Blue); if (ticket > -1) { if (true) { OrderSelect(ticket, SELECT_BY_TICKET); bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue); if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError())); } } else { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } void CustomIf70() { if (ROBOTBSELL == true) { TechnicalAnalysis2x64(); } } void TechnicalAnalysis2x64() { if ((iWPR(NULL, NULL,428,1) > -50) && (iWPR(NULL, NULL,600,0) < -50)) { IfOrderDoesNotExist71(); } } void IfOrderDoesNotExist71() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 2) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists == false) { CustomCode72(); } } void CustomCode72() { ROBOTBSELL=true; SellOrder85(); } void SellOrder85() { double SL = Bid + 0*PipValue*Point; if (0 == 0) SL = 0; double TP = Bid - 0*PipValue*Point; if (0 == 0) TP = 0; int ticket = -1; if (true) ticket = OrderSend(Symbol(), OP_SELL, SellLots85, Bid, SellSlippage85, 0, 0, "My Expert", 2, 0, Red); else ticket = OrderSend(Symbol(), OP_SELL, SellLots85, Bid, SellSlippage85, SL, TP, "My Expert", 2, 0, Red); if (ticket > -1) { if (true) { OrderSelect(ticket, SELECT_BY_TICKET); bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red); if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError())); } } else { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } void CustomIf119() { if (ROBOTCBUY == true) { TechnicalAnalysis2x132(); } } void TechnicalAnalysis2x132() { if ((iCCI(NULL, NULL,427,PRICE_CLOSE,1) < 0) && (iCCI(NULL, NULL,330,PRICE_CLOSE,0) > 0)) { IfOrderDoesNotExist128(); } } void IfOrderDoesNotExist128() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 3) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists == false) { CustomCode115(); } } void CustomCode115() { ROBOTCBUY=true; BuyOrder129(); } void BuyOrder129() { double SL = Ask - 0*PipValue*Point; if (0 == 0) SL = 0; double TP = Ask + 0*PipValue*Point; if (0 == 0) TP = 0; int ticket = -1; if (true) ticket = OrderSend(Symbol(), OP_BUY, BuyLots129, Ask, BuySlippage129, 0, 0, "My Expert", 3, 0, Blue); else ticket = OrderSend(Symbol(), OP_BUY, BuyLots129, Ask, BuySlippage129, SL, TP, "My Expert", 3, 0, Blue); if (ticket > -1) { if (true) { OrderSelect(ticket, SELECT_BY_TICKET); bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue); if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError())); } } else { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } void CustomIf118() { if (ROBOTCSELL == true) { TechnicalAnalysis2x133(); } } void TechnicalAnalysis2x133() { if ((iCCI(NULL, NULL,5,PRICE_CLOSE,1) > 0) && (iCCI(NULL, NULL,1,PRICE_CLOSE,0) < 0)) { IfOrderDoesNotExist127(); } } void IfOrderDoesNotExist127() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 3) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists == false) { CustomCode112(); } } void CustomCode112() { ROBOTCSELL=true; SellOrder126(); } void SellOrder126() { double SL = Bid + 0*PipValue*Point; if (0 == 0) SL = 0; double TP = Bid - 0*PipValue*Point; if (0 == 0) TP = 0; int ticket = -1; if (true) ticket = OrderSend(Symbol(), OP_SELL, SellLots126, Bid, SellSlippage126, 0, 0, "My Expert", 3, 0, Red); else ticket = OrderSend(Symbol(), OP_SELL, SellLots126, Bid, SellSlippage126, SL, TP, "My Expert", 3, 0, Red); if (ticket > -1) { if (true) { OrderSelect(ticket, SELECT_BY_TICKET); bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red); if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError())); } } else { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } void CustomIf164() { if (ROBOTDBUY == true) { TechnicalAnalysis2x162(); } } void TechnicalAnalysis2x162() { if ((iMA(NULL, NULL,268,0,MODE_SMA,PRICE_CLOSE,1) < iMA(NULL, NULL,256,0,MODE_SMA,PRICE_CLOSE,1)) && (iMA(NULL, NULL,268,0,MODE_SMA,PRICE_CLOSE,0) > iMA(NULL, NULL,256,0,MODE_SMA,PRICE_CLOSE,0))) { IfOrderDoesNotExist157(); } } void IfOrderDoesNotExist157() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 4) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists == false) { CustomCode156(); } } void CustomCode156() { ROBOTDBUY=true; BuyOrder161(); } void BuyOrder161() { double SL = Ask - 0*PipValue*Point; if (0 == 0) SL = 0; double TP = Ask + 0*PipValue*Point; if (0 == 0) TP = 0; int ticket = -1; if (true) ticket = OrderSend(Symbol(), OP_BUY, BuyLots161, Ask, BuySlippage161, 0, 0, "My Expert", 4, 0, Blue); else ticket = OrderSend(Symbol(), OP_BUY, BuyLots161, Ask, BuySlippage161, SL, TP, "My Expert", 4, 0, Blue); if (ticket > -1) { if (true) { OrderSelect(ticket, SELECT_BY_TICKET); bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue); if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError())); } } else { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } void CustomIf165() { if (ROBOTDSELL == true) { TechnicalAnalysis2x163(); } } void TechnicalAnalysis2x163() { if ((iMA(NULL, NULL,295,0,MODE_SMA,PRICE_CLOSE,1) > iMA(NULL, NULL,243,0,MODE_SMA,PRICE_CLOSE,1)) && (iMA(NULL, NULL,295,0,MODE_SMA,PRICE_CLOSE,0) < iMA(NULL, NULL,243,0,MODE_SMA,PRICE_CLOSE,0))) { IfOrderDoesNotExist158(); } } void IfOrderDoesNotExist158() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 4) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists == false) { CustomCode159(); } } void CustomCode159() { ROBOTDSELL=true; SellOrder160(); } void SellOrder160() { double SL = Bid + 0*PipValue*Point; if (0 == 0) SL = 0; double TP = Bid - 0*PipValue*Point; if (0 == 0) TP = 0; int ticket = -1; if (true) ticket = OrderSend(Symbol(), OP_SELL, SellLots160, Bid, SellSlippage160, 0, 0, "My Expert", 4, 0, Red); else ticket = OrderSend(Symbol(), OP_SELL, SellLots160, Bid, SellSlippage160, SL, TP, "My Expert", 4, 0, Red); if (ticket > -1) { if (true) { OrderSelect(ticket, SELECT_BY_TICKET); bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red); if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError())); } } else { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } void CustomCode59() { } void WeekdayFilter41() { if ((false && DayOfWeek() == 1) || (false && DayOfWeek() == 2) || (false && DayOfWeek() == 3) || (false && DayOfWeek() == 4) || (Friday41 && DayOfWeek() == 5) || (false && DayOfWeek() == 6) || (false && DayOfWeek() == 0)) { HoursFilter40(); } } void HoursFilter40() { int datetime800 = TimeLocal(); int hour0 = TimeHour(datetime800); if ((HoursFrom40 < HoursTo40 && hour0 >= HoursFrom40 && hour0 < HoursTo40) || (HoursFrom40 > HoursTo40 && (hour0 < HoursTo40 || hour0 >= HoursFrom40))) { IfOrderExists18(); IfOrderExists23(); IfOrderExists25(); IfOrderExists28(); IfOrderExists100(); IfOrderExists103(); IfOrderExists114(); IfOrderExists101(); } } void IfOrderExists18() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 1) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder19(); } } void CloseOrder19() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 1) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void IfOrderExists23() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 1) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder24(); } } void CloseOrder24() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 1) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void IfOrderExists25() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 2) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder26(); } } void CloseOrder26() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 2) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void IfOrderExists28() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 2) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder27(); } } void CloseOrder27() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 2) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void IfOrderExists100() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 3) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder106(); } } void CloseOrder106() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 3) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void IfOrderExists103() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 3) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder110(); } } void CloseOrder110() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 3) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void IfOrderExists114() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 4) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder117(); } } void CloseOrder117() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 4) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void IfOrderExists101() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 4) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder109(); } } void CloseOrder109() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 4) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void TechnicalAnalysis2x49() { if ((iRSI(NULL, NULL,248,PRICE_CLOSE,1) < 50) && (iRSI(NULL, NULL,1,PRICE_CLOSE,0) > 50)) { IfOrderExists50(); } } void IfOrderExists50() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 1) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder51(); } } void CloseOrder51() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 1) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void TechnicalAnalysis2x52() { if ((iRSI(NULL, NULL,277,PRICE_CLOSE,1) > 50) && (iRSI(NULL, NULL,292,PRICE_CLOSE,0) < 50)) { IfOrderExists53(); } } void IfOrderExists53() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 1) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder54(); } } void CloseOrder54() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 1) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void TechnicalAnalysis2x88() { if ((iWPR(NULL, NULL,458,1) < -50) && (iWPR(NULL, NULL,389,0) > -50)) { IfOrderExists91(); } } void IfOrderExists91() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 2) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder94(); } } void CloseOrder94() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 2) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void TechnicalAnalysis2x89() { if ((iWPR(NULL, NULL,484,1) > -50) && (iWPR(NULL, NULL,64,0) < -50)) { IfOrderExists90(); } } void IfOrderExists90() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 2) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder93(); } } void CloseOrder93() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 2) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void TechnicalAnalysis2x136() { if ((iCCI(NULL, NULL,1,PRICE_CLOSE,1) < 0) && (iCCI(NULL, NULL,5,PRICE_CLOSE,0) > 0)) { IfOrderExists139(); } } void IfOrderExists139() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 3) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder141(); } } void CloseOrder141() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 3) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void TechnicalAnalysis2x137() { if ((iCCI(NULL, NULL,1,PRICE_CLOSE,1) > 0) && (iCCI(NULL, NULL,118,PRICE_CLOSE,0) < 0)) { IfOrderExists138(); } } void IfOrderExists138() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 3) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder140(); } } void CloseOrder140() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 3) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void TechnicalAnalysis2x172() { if ((iMA(NULL, NULL,158,0,MODE_SMA,PRICE_CLOSE,1) > iMA(NULL, NULL,305,0,MODE_SMA,PRICE_CLOSE,1)) && (iMA(NULL, NULL,158,0,MODE_SMA,PRICE_CLOSE,0) < iMA(NULL, NULL,305,0,MODE_SMA,PRICE_CLOSE,0))) { IfOrderExists171(); } } void IfOrderExists171() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 4) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder168(); } } void CloseOrder168() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 4) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void TechnicalAnalysis2x173() { if ((iMA(NULL, NULL,391,0,MODE_SMA,PRICE_CLOSE,1) < iMA(NULL, NULL,115,0,MODE_SMA,PRICE_CLOSE,1)) && (iMA(NULL, NULL,391,0,MODE_SMA,PRICE_CLOSE,0) > iMA(NULL, NULL,115,0,MODE_SMA,PRICE_CLOSE,0))) { IfOrderExists169(); } } void IfOrderExists169() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 4) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder170(); } } void CloseOrder170() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 4) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } int deinit() { if (false) ObjectsDeleteAll(); }
    Modifié le 2012-11-06 00:07:38 par stepaustras
  • lefeuvr3

    Merci pour ta collaboration
    Cela me ferais plaisir d'avoir un échange par téléphone
    Je suis dispo demain au 0**** modération****
    Je posterai demain sur la file car je bosse aujourd'hui
    Amicalement
    Gerard
    Modifié le 2012-11-06 14:10:26 par AliX : les infos perso se transmettent par Messages privés
  • lefeuvr3

    je l'ai un peu modifié pour permettre le backtest de toutes les valeurs internes
    Code
    //+------------------------------------------------------------------+ //| CAC40.mq4 | //| Copyright 2012, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright 2012, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #include <stdlib.mqh> #include <WinUser32.mqh> // exported variables extern string S1="---- Horaires du lundi ouverture ROBOT ------"; extern bool Monday39 = true; extern int HoursFrom48 = 4; extern int HoursTo48 = 24; extern string S2="------ Horaires ouverture du vendredi ROBOT ------"; extern bool Friday22 = true; extern int HoursFrom47 = 0; extern int HoursTo47 = 14; extern string S4="--- Horaires ouverture du mardi au jeudi ROBOT ---"; extern bool Tuesday11 = true; extern bool Wednesday11 = true; extern bool Thursday11 = true; extern int HoursFrom46 = 0; extern int HoursTo46 = 24; extern string S5="--- Horaires du vendredi fermeture ROBOT ------"; extern bool Friday41 = true; extern int HoursFrom40 = 18; extern int HoursTo40 = 20; extern string S6="--------- LOT ET SLIPPAGE ----------"; extern double BuyLots30 = 0.1; extern int BuySlippage30 = 3; extern double SellLots31 = 0.1; extern int SellSlippage31 = 3; extern double BuyLots84 = 0.1; extern int BuySlippage84 = 3; extern double SellLots85 = 0.1; extern int SellSlippage85 = 3; extern double BuyLots129 = 0.1; extern int BuySlippage129 = 3; extern double SellLots126 = 0.1; extern int SellSlippage126 = 3; extern double BuyLots161 = 0.1; extern int BuySlippage161 = 3; extern double SellLots160 = 0.1; extern int SellSlippage160 = 3; extern string S11="--------- PARAMETRES INTERNES ----------"; extern string S12="--------- MA ----------"; extern int PERMA268 =268; extern int PERMA256 =256; extern int PERMA295 =295; extern int PERMA243 =243; extern int PERMA158 =158; extern int PERMA305=305; extern int PERMA391=391; extern int PERMA115 =115; extern string S113="--------- RSI ----------"; extern int PERSI319 =319; extern int PERSI14 =14; extern int PERSI277 =277; extern int PERSI292 =292; extern int PERSI18 =118; extern int PERSI137=137; extern int PERSI114=114; extern int PERSI248=248; extern int PERSI1=1; extern string S14="--------- WPR ----------"; extern int PERWPR319 =319; extern int PERWPR10 =10; extern int PERWPR428 =428; extern int PERWPR600 =600; extern int PERWPR458 =458; extern int PERWPR389 =389; extern int PERWPR484 =484; extern int PERWPR64 =64; extern string S15="--------- CCI ----------"; extern int PERCCI427 =427; extern int PERCCI330 =330; extern int PERCCI15 =15; extern int PERCCI1 =1; extern int PERCCI01 =1; extern int PERCCI5 =5; extern int PERCCI001 =1; extern int PERCCI118 =118; // local variables double PipValue=1; // this variable is here to support 5-digit brokers bool Terminated = false; string LF = "\n"; // use this in custom or utility blocks where you need line feeds int NDigits = 4; // used mostly for NormalizeDouble in Flex type blocks int ObjCount = 0; // count of all objects created on the chart, allows creation of objects with unique names int current = 0; extern string S7="--- ROBOT A BUY ET SELL ---"; extern bool ROBOTABUY=true; extern bool ROBOTASELL=true; extern string S8="--- ROBOT B BUY ET SELL ---"; extern bool ROBOTBBUY=true; extern bool ROBOTBSELL=true; extern string S9="--- ROBOT C BUY ET SELL ---"; extern bool ROBOTCBUY=true; extern bool ROBOTCSELL=true; extern string S10="--- ROBOT D BUY ET SELL ---"; extern bool ROBOTDBUY=true; extern bool ROBOTDSELL=true; int init() { NDigits = Digits; if (false) ObjectsDeleteAll(); // clear the chart Comment(""); // clear the chart } // Expert start int start() { if (Bars < 10) { Comment("Not enough bars"); return (0); } if (Terminated == true) { Comment("EA Terminated."); return (0); } OnEveryTick3(); } void OnEveryTick3() { if (true == false && true) PipValue = 10; if (true && (NDigits == 3 || NDigits == 5)) PipValue = 10; WeekdayFilter39(); CustomCode59(); WeekdayFilter41(); TechnicalAnalysis2x49(); TechnicalAnalysis2x52(); TechnicalAnalysis2x88(); TechnicalAnalysis2x89(); TechnicalAnalysis2x136(); TechnicalAnalysis2x137(); TechnicalAnalysis2x172(); TechnicalAnalysis2x173(); } void WeekdayFilter39() { if ((Monday39 && DayOfWeek() == 1) || (true && DayOfWeek() == 2) || (true && DayOfWeek() == 3) || (true && DayOfWeek() == 4) || (true && DayOfWeek() == 5) || (true && DayOfWeek() == 6) || (true && DayOfWeek() == 0)) { HoursFilter48(); } } void HoursFilter48() { int datetime800 = TimeLocal(); int hour0 = TimeHour(datetime800); if ((HoursFrom48 < HoursTo48 && hour0 >= HoursFrom48 && hour0 < HoursTo48) || (HoursFrom48 > HoursTo48 && (hour0 < HoursTo48 || hour0 >= HoursFrom48))) { WeekdayFilter22(); } } void WeekdayFilter22() { if ((true && DayOfWeek() == 1) || (true && DayOfWeek() == 2) || (true && DayOfWeek() == 3) || (true && DayOfWeek() == 4) || (Friday22 && DayOfWeek() == 5) || (true && DayOfWeek() == 6) || (true && DayOfWeek() == 0)) { HoursFilter47(); } } void HoursFilter47() { int datetime800 = TimeLocal(); int hour0 = TimeHour(datetime800); if ((HoursFrom47 < HoursTo47 && hour0 >= HoursFrom47 && hour0 < HoursTo47) || (HoursFrom47 > HoursTo47 && (hour0 < HoursTo47 || hour0 >= HoursFrom47))) { WeekdayFilter11(); } } void WeekdayFilter11() { if ((true && DayOfWeek() == 1) || (Tuesday11 && DayOfWeek() == 2) || (Wednesday11 && DayOfWeek() == 3) || (Thursday11 && DayOfWeek() == 4) || (true && DayOfWeek() == 5) || (true && DayOfWeek() == 6) || (true && DayOfWeek() == 0)) { HoursFilter46(); } } void HoursFilter46() { int datetime800 = TimeLocal(); int hour0 = TimeHour(datetime800); if ((HoursFrom46 < HoursTo46 && hour0 >= HoursFrom46 && hour0 < HoursTo46) || (HoursFrom46 > HoursTo46 && (hour0 < HoursTo46 || hour0 >= HoursFrom46))) { CustomIf55(); CustomIf58(); CustomIf69(); CustomIf70(); CustomIf119(); CustomIf118(); CustomIf164(); CustomIf165(); } } void CustomIf55() { if (ROBOTABUY == true) { TechnicalAnalysis2x62(); } } void TechnicalAnalysis2x62() { if ((iRSI(NULL, NULL,PERSI18,PRICE_CLOSE,1) < 50) && (iRSI(NULL, NULL,PERSI137,PRICE_CLOSE,0) > 50)) { IfOrderDoesNotExist10(); } } void IfOrderDoesNotExist10() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 1) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists == false) { CustomCode56(); } } void CustomCode56() { ROBOTABUY=true; BuyOrder30(); } void BuyOrder30() { double SL = Ask - 0*PipValue*Point; if (0 == 0) SL = 0; double TP = Ask + 0*PipValue*Point; if (0 == 0) TP = 0; int ticket = -1; if (true) ticket = OrderSend(Symbol(), OP_BUY, BuyLots30, Ask, BuySlippage30, 0, 0, "My Expert", 1, 0, Blue); else ticket = OrderSend(Symbol(), OP_BUY, BuyLots30, Ask, BuySlippage30, SL, TP, "My Expert", 1, 0, Blue); if (ticket > -1) { if (true) { OrderSelect(ticket, SELECT_BY_TICKET); bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue); if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError())); } } else { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } void CustomIf58() { if (ROBOTASELL == true) { TechnicalAnalysis2x1(); } } void TechnicalAnalysis2x1() { if ((iRSI(NULL, NULL,PERSI319,PRICE_CLOSE,1) > 50) && (iRSI(NULL, NULL,PERSI14,PRICE_CLOSE,0) < 50)) { IfOrderDoesNotExist29(); } } void IfOrderDoesNotExist29() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 1) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists == false) { CustomCode57(); } } void CustomCode57() { ROBOTASELL=true; SellOrder31(); } void SellOrder31() { double SL = Bid + 0*PipValue*Point; if (0 == 0) SL = 0; double TP = Bid - 0*PipValue*Point; if (0 == 0) TP = 0; int ticket = -1; if (true) ticket = OrderSend(Symbol(), OP_SELL, SellLots31, Bid, SellSlippage31, 0, 0, "My Expert", 1, 0, Red); else ticket = OrderSend(Symbol(), OP_SELL, SellLots31, Bid, SellSlippage31, SL, TP, "My Expert", 1, 0, Red); if (ticket > -1) { if (true) { OrderSelect(ticket, SELECT_BY_TICKET); bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red); if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError())); } } else { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } void CustomIf69() { if (ROBOTBBUY == true) { TechnicalAnalysis2x60(); } } void TechnicalAnalysis2x60() { if ((iWPR(NULL, NULL,PERWPR319,1) < -50) && (iWPR(NULL, NULL,PERWPR10,0) > -50)) { IfOrderDoesNotExist67(); } } void IfOrderDoesNotExist67() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 2) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists == false) { CustomCode73(); } } void CustomCode73() { ROBOTBBUY=true; BuyOrder84(); } void BuyOrder84() { double SL = Ask - 0*PipValue*Point; if (0 == 0) SL = 0; double TP = Ask + 0*PipValue*Point; if (0 == 0) TP = 0; int ticket = -1; if (true) ticket = OrderSend(Symbol(), OP_BUY, BuyLots84, Ask, BuySlippage84, 0, 0, "My Expert", 2, 0, Blue); else ticket = OrderSend(Symbol(), OP_BUY, BuyLots84, Ask, BuySlippage84, SL, TP, "My Expert", 2, 0, Blue); if (ticket > -1) { if (true) { OrderSelect(ticket, SELECT_BY_TICKET); bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue); if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError())); } } else { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } void CustomIf70() { if (ROBOTBSELL == true) { TechnicalAnalysis2x64(); } } void TechnicalAnalysis2x64() { if ((iWPR(NULL, NULL,PERWPR428,1) > -50) && (iWPR(NULL, NULL,PERWPR600,0) < -50)) { IfOrderDoesNotExist71(); } } void IfOrderDoesNotExist71() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 2) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists == false) { CustomCode72(); } } void CustomCode72() { ROBOTBSELL=true; SellOrder85(); } void SellOrder85() { double SL = Bid + 0*PipValue*Point; if (0 == 0) SL = 0; double TP = Bid - 0*PipValue*Point; if (0 == 0) TP = 0; int ticket = -1; if (true) ticket = OrderSend(Symbol(), OP_SELL, SellLots85, Bid, SellSlippage85, 0, 0, "My Expert", 2, 0, Red); else ticket = OrderSend(Symbol(), OP_SELL, SellLots85, Bid, SellSlippage85, SL, TP, "My Expert", 2, 0, Red); if (ticket > -1) { if (true) { OrderSelect(ticket, SELECT_BY_TICKET); bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red); if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError())); } } else { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } void CustomIf119() { if (ROBOTCBUY == true) { TechnicalAnalysis2x132(); } } void TechnicalAnalysis2x132() { if ((iCCI(NULL, NULL,PERCCI427,PRICE_CLOSE,1) < 0) && (iCCI(NULL, NULL,PERCCI330,PRICE_CLOSE,0) > 0)) { IfOrderDoesNotExist128(); } } void IfOrderDoesNotExist128() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 3) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists == false) { CustomCode115(); } } void CustomCode115() { ROBOTCBUY=true; BuyOrder129(); } void BuyOrder129() { double SL = Ask - 0*PipValue*Point; if (0 == 0) SL = 0; double TP = Ask + 0*PipValue*Point; if (0 == 0) TP = 0; int ticket = -1; if (true) ticket = OrderSend(Symbol(), OP_BUY, BuyLots129, Ask, BuySlippage129, 0, 0, "My Expert", 3, 0, Blue); else ticket = OrderSend(Symbol(), OP_BUY, BuyLots129, Ask, BuySlippage129, SL, TP, "My Expert", 3, 0, Blue); if (ticket > -1) { if (true) { OrderSelect(ticket, SELECT_BY_TICKET); bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue); if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError())); } } else { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } void CustomIf118() { if (ROBOTCSELL == true) { TechnicalAnalysis2x133(); } } void TechnicalAnalysis2x133() { if ((iCCI(NULL, NULL,PERCCI5,PRICE_CLOSE,1) > 0) && (iCCI(NULL, NULL,PERCCI1,PRICE_CLOSE,0) < 0)) { IfOrderDoesNotExist127(); } } void IfOrderDoesNotExist127() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 3) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists == false) { CustomCode112(); } } void CustomCode112() { ROBOTCSELL=true; SellOrder126(); } void SellOrder126() { double SL = Bid + 0*PipValue*Point; if (0 == 0) SL = 0; double TP = Bid - 0*PipValue*Point; if (0 == 0) TP = 0; int ticket = -1; if (true) ticket = OrderSend(Symbol(), OP_SELL, SellLots126, Bid, SellSlippage126, 0, 0, "My Expert", 3, 0, Red); else ticket = OrderSend(Symbol(), OP_SELL, SellLots126, Bid, SellSlippage126, SL, TP, "My Expert", 3, 0, Red); if (ticket > -1) { if (true) { OrderSelect(ticket, SELECT_BY_TICKET); bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red); if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError())); } } else { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } void CustomIf164() { if (ROBOTDBUY == true) { TechnicalAnalysis2x162(); } } void TechnicalAnalysis2x162() { if ((iMA(NULL, NULL,PERMA268,0,MODE_SMA,PRICE_CLOSE,1) < iMA(NULL, NULL,PERMA256,0,MODE_SMA,PRICE_CLOSE,1)) && (iMA(NULL, NULL,PERMA268,0,MODE_SMA,PRICE_CLOSE,0) > iMA(NULL, NULL,PERMA256,0,MODE_SMA,PRICE_CLOSE,0))) { IfOrderDoesNotExist157(); } } void IfOrderDoesNotExist157() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 4) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists == false) { CustomCode156(); } } void CustomCode156() { ROBOTDBUY=true; BuyOrder161(); } void BuyOrder161() { double SL = Ask - 0*PipValue*Point; if (0 == 0) SL = 0; double TP = Ask + 0*PipValue*Point; if (0 == 0) TP = 0; int ticket = -1; if (true) ticket = OrderSend(Symbol(), OP_BUY, BuyLots161, Ask, BuySlippage161, 0, 0, "My Expert", 4, 0, Blue); else ticket = OrderSend(Symbol(), OP_BUY, BuyLots161, Ask, BuySlippage161, SL, TP, "My Expert", 4, 0, Blue); if (ticket > -1) { if (true) { OrderSelect(ticket, SELECT_BY_TICKET); bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue); if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError())); } } else { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } void CustomIf165() { if (ROBOTDSELL == true) { TechnicalAnalysis2x163(); } } void TechnicalAnalysis2x163() { if ((iMA(NULL, NULL,PERMA295,0,MODE_SMA,PRICE_CLOSE,1) > iMA(NULL, NULL,PERMA243,0,MODE_SMA,PRICE_CLOSE,1)) && (iMA(NULL, NULL,PERMA295,0,MODE_SMA,PRICE_CLOSE,0) < iMA(NULL, NULL,PERMA243,0,MODE_SMA,PRICE_CLOSE,0))) { IfOrderDoesNotExist158(); } } void IfOrderDoesNotExist158() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 4) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists == false) { CustomCode159(); } } void CustomCode159() { ROBOTDSELL=true; SellOrder160(); } void SellOrder160() { double SL = Bid + 0*PipValue*Point; if (0 == 0) SL = 0; double TP = Bid - 0*PipValue*Point; if (0 == 0) TP = 0; int ticket = -1; if (true) ticket = OrderSend(Symbol(), OP_SELL, SellLots160, Bid, SellSlippage160, 0, 0, "My Expert", 4, 0, Red); else ticket = OrderSend(Symbol(), OP_SELL, SellLots160, Bid, SellSlippage160, SL, TP, "My Expert", 4, 0, Red); if (ticket > -1) { if (true) { OrderSelect(ticket, SELECT_BY_TICKET); bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red); if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError())); } } else { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } void CustomCode59() { } void WeekdayFilter41() { if ((false && DayOfWeek() == 1) || (false && DayOfWeek() == 2) || (false && DayOfWeek() == 3) || (false && DayOfWeek() == 4) || (Friday41 && DayOfWeek() == 5) || (false && DayOfWeek() == 6) || (false && DayOfWeek() == 0)) { HoursFilter40(); } } void HoursFilter40() { int datetime800 = TimeLocal(); int hour0 = TimeHour(datetime800); if ((HoursFrom40 < HoursTo40 && hour0 >= HoursFrom40 && hour0 < HoursTo40) || (HoursFrom40 > HoursTo40 && (hour0 < HoursTo40 || hour0 >= HoursFrom40))) { IfOrderExists18(); IfOrderExists23(); IfOrderExists25(); IfOrderExists28(); IfOrderExists100(); IfOrderExists103(); IfOrderExists114(); IfOrderExists101(); } } void IfOrderExists18() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 1) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder19(); } } void CloseOrder19() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 1) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void IfOrderExists23() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 1) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder24(); } } void CloseOrder24() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 1) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void IfOrderExists25() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 2) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder26(); } } void CloseOrder26() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 2) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void IfOrderExists28() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 2) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder27(); } } void CloseOrder27() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 2) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void IfOrderExists100() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 3) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder106(); } } void CloseOrder106() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 3) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void IfOrderExists103() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 3) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder110(); } } void CloseOrder110() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 3) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void IfOrderExists114() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 4) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder117(); } } void CloseOrder117() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 4) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void IfOrderExists101() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 4) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder109(); } } void CloseOrder109() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 4) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void TechnicalAnalysis2x49() { if ((iRSI(NULL, NULL,PERSI248,PRICE_CLOSE,1) < 50) && (iRSI(NULL, NULL,PERSI1,PRICE_CLOSE,0) > 50)) { IfOrderExists50(); } } void IfOrderExists50() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 1) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder51(); } } void CloseOrder51() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 1) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void TechnicalAnalysis2x52() { if ((iRSI(NULL, NULL,PERSI277,PRICE_CLOSE,1) > 50) && (iRSI(NULL, NULL,PERSI292,PRICE_CLOSE,0) < 50)) { IfOrderExists53(); } } void IfOrderExists53() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 1) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder54(); } } void CloseOrder54() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 1) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void TechnicalAnalysis2x88() { if ((iWPR(NULL, NULL,PERWPR458,1) < -50) && (iWPR(NULL, NULL,PERWPR389,0) > -50)) { IfOrderExists91(); } } void IfOrderExists91() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 2) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder94(); } } void CloseOrder94() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 2) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void TechnicalAnalysis2x89() { if ((iWPR(NULL, NULL,PERWPR484,1) > -50) && (iWPR(NULL, NULL,PERWPR64,0) < -50)) { IfOrderExists90(); } } void IfOrderExists90() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 2) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder93(); } } void CloseOrder93() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 2) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void TechnicalAnalysis2x136() { if ((iCCI(NULL, NULL,PERCCI01,PRICE_CLOSE,1) < 0) && (iCCI(NULL, NULL,PERCCI5,PRICE_CLOSE,0) > 0)) { IfOrderExists139(); } } void IfOrderExists139() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 3) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder141(); } } void CloseOrder141() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 3) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void TechnicalAnalysis2x137() { if ((iCCI(NULL, NULL,PERCCI1,PRICE_CLOSE,1) > 0) && (iCCI(NULL, NULL,PERCCI118,PRICE_CLOSE,0) < 0)) { IfOrderExists138(); } } void IfOrderExists138() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 3) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder140(); } } void CloseOrder140() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 3) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void TechnicalAnalysis2x172() { if ((iMA(NULL, NULL,PERMA158,0,MODE_SMA,PRICE_CLOSE,1) > iMA(NULL, NULL,PERMA305,0,MODE_SMA,PRICE_CLOSE,1)) && (iMA(NULL, NULL,PERMA158,0,MODE_SMA,PRICE_CLOSE,0) < iMA(NULL, NULL,PERMA305,0,MODE_SMA,PRICE_CLOSE,0))) { IfOrderExists171(); } } void IfOrderExists171() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 4) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder168(); } } void CloseOrder168() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 4) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void TechnicalAnalysis2x173() { if ((iMA(NULL, NULL,PERMA391,0,MODE_SMA,PRICE_CLOSE,1) < iMA(NULL, NULL,PERMA115,0,MODE_SMA,PRICE_CLOSE,1)) && (iMA(NULL, NULL,PERMA391,0,MODE_SMA,PRICE_CLOSE,0) > iMA(NULL, NULL,PERMA115,0,MODE_SMA,PRICE_CLOSE,0))) { IfOrderExists169(); } } void IfOrderExists169() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 4) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder170(); } } void CloseOrder170() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 4) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } int deinit() { if (false) ObjectsDeleteAll(); }
  • lefeuvr3

    resultats du backtest UT 15 du 16.05.2012 a aujourdh'ui sur l'euro /usd

    Bars en test 9271
    Ticks modelés 18442
    Qualité du modelage n/a
    Erreurs des graphiques désaccordés 0
    Dépot initial 10000.00
    Profit total net 508136.80
    Profit brut 731845.60
    Perte brute -223708.80
    Facteur de profit 3.27
    Rémunération espérée 1770.51
    Chute absolue 0.00
    Chute maximal (%) 34154.16 (18.15%)
    Enfoncement relatif 37.80% (11517.72)
    Total des Trades 287
    Positions SHORT (vente) gagnées % 47 (57.45%)
    Positions LONG (achat) gagnées % 240 (21.67%)
    Profits des Trades (% du total) 79 (27.53%)
    Pertes des Trades (% du total) 208 (72.47%)
    Le plus large
    gains par Trade 38207.16
    pertes par Trade -16100.00
    Average (moyenne)
    gains par Trade 9263.87
    pertes par Trade -1075.52
    Maximum
    gains consecutifs (profit en $) 6 (26505.08)
    pertes consecutives (perte en $) 28 (-4810.44)
    Maximal
    Gains consecutifs (coups gagnants) 101806.80 (3)
    Pertes consecutives (coups perdants) -19893.44 (2)
    Average (moyenne)
    gains consecutifs 2
    Pertes consecutives 6


    Voici programmes avec les parametres de mon backtest
    Code
    //+------------------------------------------------------------------+ //| CAC40.mq4 | //| Copyright 2012, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright 2012, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #include <stdlib.mqh> #include <WinUser32.mqh> // exported variables extern string S1="---- Horaires du lundi ouverture ROBOT ------"; extern bool Monday39 = true; extern int HoursFrom48 = 0; extern int HoursTo48 = 24; extern string S2="------ Horaires ouverture du vendredi ROBOT ------"; extern bool Friday22 = true; extern int HoursFrom47 = 21; extern int HoursTo47 = 18; extern string S4="--- Horaires ouverture du mardi au jeudi ROBOT ---"; extern bool Tuesday11 = true; extern bool Wednesday11 = true; extern bool Thursday11 = true; extern int HoursFrom46 = 16; extern int HoursTo46 = 14; extern string S5="--- Horaires du vendredi fermeture ROBOT ------"; extern bool Friday41 = true; extern int HoursFrom40 = 19; extern int HoursTo40 = 24; extern string S6="--------- LOT ET SLIPPAGE ----------"; extern double BuyLots30 = 10.2; extern int BuySlippage30 = 3; extern double SellLots31 = 10.2; extern int SellSlippage31 = 3; extern double BuyLots84 = 10.2; extern int BuySlippage84 = 3; extern double SellLots85 =10.2; extern int SellSlippage85 = 3; extern double BuyLots129 = 7.8; extern int BuySlippage129 = 3; extern double SellLots126 = 7; extern int SellSlippage126 = 3; extern double BuyLots161 = 10.2; extern int BuySlippage161 = 3; extern double SellLots160 = 9.8; extern int SellSlippage160 = 3; extern string S11="--------- PARAMETRES INTERNES ----------"; extern string S12="--------- MA ----------"; extern int PERMA268 =153; extern int PERMA256 =136; extern int PERMA295 =288; extern int PERMA243 =384; extern int PERMA158 =142; extern int PERMA305=342; extern int PERMA391=374; extern int PERMA115 =43; extern string S113="--------- RSI ----------"; extern int PERSI319 =84; extern int PERSI14 =84; extern int PERSI277 =140; extern int PERSI292 =128; extern int PERSI18 =64; extern int PERSI137=116; extern int PERSI114=196; extern int PERSI248=212; extern int PERSI1=0; extern string S14="--------- WPR ----------"; extern int PERWPR319 =500; extern int PERWPR10 =488; extern int PERWPR428 =408; extern int PERWPR600 =336; extern int PERWPR458 =388; extern int PERWPR389 =384; extern int PERWPR484 =244; extern int PERWPR64 =356; extern string S15="--------- CCI ----------"; extern int PERCCI427 =20; extern int PERCCI330 =52; extern int PERCCI15 =52; extern int PERCCI1 =252; extern int PERCCI01 =224; extern int PERCCI5 =432; extern int PERCCI001 =64; extern int PERCCI118 =380; // local variables double PipValue=1; // this variable is here to support 5-digit brokers bool Terminated = false; string LF = "\n"; // use this in custom or utility blocks where you need line feeds int NDigits = 4; // used mostly for NormalizeDouble in Flex type blocks int ObjCount = 0; // count of all objects created on the chart, allows creation of objects with unique names int current = 0; extern string S7="--- ROBOT A BUY ET SELL ---"; extern bool ROBOTABUY=true; extern bool ROBOTASELL=true; extern string S8="--- ROBOT B BUY ET SELL ---"; extern bool ROBOTBBUY=true; extern bool ROBOTBSELL=true; extern string S9="--- ROBOT C BUY ET SELL ---"; extern bool ROBOTCBUY=true; extern bool ROBOTCSELL=true; extern string S10="--- ROBOT D BUY ET SELL ---"; extern bool ROBOTDBUY=true; extern bool ROBOTDSELL=true; int init() { NDigits = Digits; if (false) ObjectsDeleteAll(); // clear the chart Comment(""); // clear the chart } // Expert start int start() { if (Bars < 10) { Comment("Not enough bars"); return (0); } if (Terminated == true) { Comment("EA Terminated."); return (0); } OnEveryTick3(); } void OnEveryTick3() { if (true == false && true) PipValue = 10; if (true && (NDigits == 3 || NDigits == 5)) PipValue = 10; WeekdayFilter39(); CustomCode59(); WeekdayFilter41(); TechnicalAnalysis2x49(); TechnicalAnalysis2x52(); TechnicalAnalysis2x88(); TechnicalAnalysis2x89(); TechnicalAnalysis2x136(); TechnicalAnalysis2x137(); TechnicalAnalysis2x172(); TechnicalAnalysis2x173(); } void WeekdayFilter39() { if ((Monday39 && DayOfWeek() == 1) || (true && DayOfWeek() == 2) || (true && DayOfWeek() == 3) || (true && DayOfWeek() == 4) || (true && DayOfWeek() == 5) || (true && DayOfWeek() == 6) || (true && DayOfWeek() == 0)) { HoursFilter48(); } } void HoursFilter48() { int datetime800 = TimeLocal(); int hour0 = TimeHour(datetime800); if ((HoursFrom48 < HoursTo48 && hour0 >= HoursFrom48 && hour0 < HoursTo48) || (HoursFrom48 > HoursTo48 && (hour0 < HoursTo48 || hour0 >= HoursFrom48))) { WeekdayFilter22(); } } void WeekdayFilter22() { if ((true && DayOfWeek() == 1) || (true && DayOfWeek() == 2) || (true && DayOfWeek() == 3) || (true && DayOfWeek() == 4) || (Friday22 && DayOfWeek() == 5) || (true && DayOfWeek() == 6) || (true && DayOfWeek() == 0)) { HoursFilter47(); } } void HoursFilter47() { int datetime800 = TimeLocal(); int hour0 = TimeHour(datetime800); if ((HoursFrom47 < HoursTo47 && hour0 >= HoursFrom47 && hour0 < HoursTo47) || (HoursFrom47 > HoursTo47 && (hour0 < HoursTo47 || hour0 >= HoursFrom47))) { WeekdayFilter11(); } } void WeekdayFilter11() { if ((true && DayOfWeek() == 1) || (Tuesday11 && DayOfWeek() == 2) || (Wednesday11 && DayOfWeek() == 3) || (Thursday11 && DayOfWeek() == 4) || (true && DayOfWeek() == 5) || (true && DayOfWeek() == 6) || (true && DayOfWeek() == 0)) { HoursFilter46(); } } void HoursFilter46() { int datetime800 = TimeLocal(); int hour0 = TimeHour(datetime800); if ((HoursFrom46 < HoursTo46 && hour0 >= HoursFrom46 && hour0 < HoursTo46) || (HoursFrom46 > HoursTo46 && (hour0 < HoursTo46 || hour0 >= HoursFrom46))) { CustomIf55(); CustomIf58(); CustomIf69(); CustomIf70(); CustomIf119(); CustomIf118(); CustomIf164(); CustomIf165(); } } void CustomIf55() { if (ROBOTABUY == true) { TechnicalAnalysis2x62(); } } void TechnicalAnalysis2x62() { if ((iRSI(NULL, NULL,PERSI18,PRICE_CLOSE,1) < 50) && (iRSI(NULL, NULL,PERSI137,PRICE_CLOSE,0) > 50)) { IfOrderDoesNotExist10(); } } void IfOrderDoesNotExist10() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 1) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists == false) { CustomCode56(); } } void CustomCode56() { ROBOTABUY=true; BuyOrder30(); } void BuyOrder30() { double SL = Ask - 0*PipValue*Point; if (0 == 0) SL = 0; double TP = Ask + 0*PipValue*Point; if (0 == 0) TP = 0; int ticket = -1; if (true) ticket = OrderSend(Symbol(), OP_BUY, BuyLots30, Ask, BuySlippage30, 0, 0, "My Expert", 1, 0, Blue); else ticket = OrderSend(Symbol(), OP_BUY, BuyLots30, Ask, BuySlippage30, SL, TP, "My Expert", 1, 0, Blue); if (ticket > -1) { if (true) { OrderSelect(ticket, SELECT_BY_TICKET); bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue); if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError())); } } else { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } void CustomIf58() { if (ROBOTASELL == true) { TechnicalAnalysis2x1(); } } void TechnicalAnalysis2x1() { if ((iRSI(NULL, NULL,PERSI319,PRICE_CLOSE,1) > 50) && (iRSI(NULL, NULL,PERSI14,PRICE_CLOSE,0) < 50)) { IfOrderDoesNotExist29(); } } void IfOrderDoesNotExist29() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 1) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists == false) { CustomCode57(); } } void CustomCode57() { ROBOTASELL=true; SellOrder31(); } void SellOrder31() { double SL = Bid + 0*PipValue*Point; if (0 == 0) SL = 0; double TP = Bid - 0*PipValue*Point; if (0 == 0) TP = 0; int ticket = -1; if (true) ticket = OrderSend(Symbol(), OP_SELL, SellLots31, Bid, SellSlippage31, 0, 0, "My Expert", 1, 0, Red); else ticket = OrderSend(Symbol(), OP_SELL, SellLots31, Bid, SellSlippage31, SL, TP, "My Expert", 1, 0, Red); if (ticket > -1) { if (true) { OrderSelect(ticket, SELECT_BY_TICKET); bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red); if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError())); } } else { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } void CustomIf69() { if (ROBOTBBUY == true) { TechnicalAnalysis2x60(); } } void TechnicalAnalysis2x60() { if ((iWPR(NULL, NULL,PERWPR319,1) < -50) && (iWPR(NULL, NULL,PERWPR10,0) > -50)) { IfOrderDoesNotExist67(); } } void IfOrderDoesNotExist67() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 2) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists == false) { CustomCode73(); } } void CustomCode73() { ROBOTBBUY=true; BuyOrder84(); } void BuyOrder84() { double SL = Ask - 0*PipValue*Point; if (0 == 0) SL = 0; double TP = Ask + 0*PipValue*Point; if (0 == 0) TP = 0; int ticket = -1; if (true) ticket = OrderSend(Symbol(), OP_BUY, BuyLots84, Ask, BuySlippage84, 0, 0, "My Expert", 2, 0, Blue); else ticket = OrderSend(Symbol(), OP_BUY, BuyLots84, Ask, BuySlippage84, SL, TP, "My Expert", 2, 0, Blue); if (ticket > -1) { if (true) { OrderSelect(ticket, SELECT_BY_TICKET); bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue); if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError())); } } else { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } void CustomIf70() { if (ROBOTBSELL == true) { TechnicalAnalysis2x64(); } } void TechnicalAnalysis2x64() { if ((iWPR(NULL, NULL,PERWPR428,1) > -50) && (iWPR(NULL, NULL,PERWPR600,0) < -50)) { IfOrderDoesNotExist71(); } } void IfOrderDoesNotExist71() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 2) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists == false) { CustomCode72(); } } void CustomCode72() { ROBOTBSELL=true; SellOrder85(); } void SellOrder85() { double SL = Bid + 0*PipValue*Point; if (0 == 0) SL = 0; double TP = Bid - 0*PipValue*Point; if (0 == 0) TP = 0; int ticket = -1; if (true) ticket = OrderSend(Symbol(), OP_SELL, SellLots85, Bid, SellSlippage85, 0, 0, "My Expert", 2, 0, Red); else ticket = OrderSend(Symbol(), OP_SELL, SellLots85, Bid, SellSlippage85, SL, TP, "My Expert", 2, 0, Red); if (ticket > -1) { if (true) { OrderSelect(ticket, SELECT_BY_TICKET); bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red); if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError())); } } else { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } void CustomIf119() { if (ROBOTCBUY == true) { TechnicalAnalysis2x132(); } } void TechnicalAnalysis2x132() { if ((iCCI(NULL, NULL,PERCCI427,PRICE_CLOSE,1) < 0) && (iCCI(NULL, NULL,PERCCI330,PRICE_CLOSE,0) > 0)) { IfOrderDoesNotExist128(); } } void IfOrderDoesNotExist128() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 3) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists == false) { CustomCode115(); } } void CustomCode115() { ROBOTCBUY=true; BuyOrder129(); } void BuyOrder129() { double SL = Ask - 0*PipValue*Point; if (0 == 0) SL = 0; double TP = Ask + 0*PipValue*Point; if (0 == 0) TP = 0; int ticket = -1; if (true) ticket = OrderSend(Symbol(), OP_BUY, BuyLots129, Ask, BuySlippage129, 0, 0, "My Expert", 3, 0, Blue); else ticket = OrderSend(Symbol(), OP_BUY, BuyLots129, Ask, BuySlippage129, SL, TP, "My Expert", 3, 0, Blue); if (ticket > -1) { if (true) { OrderSelect(ticket, SELECT_BY_TICKET); bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue); if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError())); } } else { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } void CustomIf118() { if (ROBOTCSELL == true) { TechnicalAnalysis2x133(); } } void TechnicalAnalysis2x133() { if ((iCCI(NULL, NULL,PERCCI5,PRICE_CLOSE,1) > 0) && (iCCI(NULL, NULL,PERCCI1,PRICE_CLOSE,0) < 0)) { IfOrderDoesNotExist127(); } } void IfOrderDoesNotExist127() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 3) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists == false) { CustomCode112(); } } void CustomCode112() { ROBOTCSELL=true; SellOrder126(); } void SellOrder126() { double SL = Bid + 0*PipValue*Point; if (0 == 0) SL = 0; double TP = Bid - 0*PipValue*Point; if (0 == 0) TP = 0; int ticket = -1; if (true) ticket = OrderSend(Symbol(), OP_SELL, SellLots126, Bid, SellSlippage126, 0, 0, "My Expert", 3, 0, Red); else ticket = OrderSend(Symbol(), OP_SELL, SellLots126, Bid, SellSlippage126, SL, TP, "My Expert", 3, 0, Red); if (ticket > -1) { if (true) { OrderSelect(ticket, SELECT_BY_TICKET); bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red); if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError())); } } else { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } void CustomIf164() { if (ROBOTDBUY == true) { TechnicalAnalysis2x162(); } } void TechnicalAnalysis2x162() { if ((iMA(NULL, NULL,PERMA268,0,MODE_SMA,PRICE_CLOSE,1) < iMA(NULL, NULL,PERMA256,0,MODE_SMA,PRICE_CLOSE,1)) && (iMA(NULL, NULL,PERMA268,0,MODE_SMA,PRICE_CLOSE,0) > iMA(NULL, NULL,PERMA256,0,MODE_SMA,PRICE_CLOSE,0))) { IfOrderDoesNotExist157(); } } void IfOrderDoesNotExist157() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 4) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists == false) { CustomCode156(); } } void CustomCode156() { ROBOTDBUY=true; BuyOrder161(); } void BuyOrder161() { double SL = Ask - 0*PipValue*Point; if (0 == 0) SL = 0; double TP = Ask + 0*PipValue*Point; if (0 == 0) TP = 0; int ticket = -1; if (true) ticket = OrderSend(Symbol(), OP_BUY, BuyLots161, Ask, BuySlippage161, 0, 0, "My Expert", 4, 0, Blue); else ticket = OrderSend(Symbol(), OP_BUY, BuyLots161, Ask, BuySlippage161, SL, TP, "My Expert", 4, 0, Blue); if (ticket > -1) { if (true) { OrderSelect(ticket, SELECT_BY_TICKET); bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue); if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError())); } } else { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } void CustomIf165() { if (ROBOTDSELL == true) { TechnicalAnalysis2x163(); } } void TechnicalAnalysis2x163() { if ((iMA(NULL, NULL,PERMA295,0,MODE_SMA,PRICE_CLOSE,1) > iMA(NULL, NULL,PERMA243,0,MODE_SMA,PRICE_CLOSE,1)) && (iMA(NULL, NULL,PERMA295,0,MODE_SMA,PRICE_CLOSE,0) < iMA(NULL, NULL,PERMA243,0,MODE_SMA,PRICE_CLOSE,0))) { IfOrderDoesNotExist158(); } } void IfOrderDoesNotExist158() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 4) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists == false) { CustomCode159(); } } void CustomCode159() { ROBOTDSELL=true; SellOrder160(); } void SellOrder160() { double SL = Bid + 0*PipValue*Point; if (0 == 0) SL = 0; double TP = Bid - 0*PipValue*Point; if (0 == 0) TP = 0; int ticket = -1; if (true) ticket = OrderSend(Symbol(), OP_SELL, SellLots160, Bid, SellSlippage160, 0, 0, "My Expert", 4, 0, Red); else ticket = OrderSend(Symbol(), OP_SELL, SellLots160, Bid, SellSlippage160, SL, TP, "My Expert", 4, 0, Red); if (ticket > -1) { if (true) { OrderSelect(ticket, SELECT_BY_TICKET); bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red); if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError())); } } else { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } void CustomCode59() { } void WeekdayFilter41() { if ((false && DayOfWeek() == 1) || (false && DayOfWeek() == 2) || (false && DayOfWeek() == 3) || (false && DayOfWeek() == 4) || (Friday41 && DayOfWeek() == 5) || (false && DayOfWeek() == 6) || (false && DayOfWeek() == 0)) { HoursFilter40(); } } void HoursFilter40() { int datetime800 = TimeLocal(); int hour0 = TimeHour(datetime800); if ((HoursFrom40 < HoursTo40 && hour0 >= HoursFrom40 && hour0 < HoursTo40) || (HoursFrom40 > HoursTo40 && (hour0 < HoursTo40 || hour0 >= HoursFrom40))) { IfOrderExists18(); IfOrderExists23(); IfOrderExists25(); IfOrderExists28(); IfOrderExists100(); IfOrderExists103(); IfOrderExists114(); IfOrderExists101(); } } void IfOrderExists18() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 1) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder19(); } } void CloseOrder19() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 1) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void IfOrderExists23() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 1) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder24(); } } void CloseOrder24() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 1) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void IfOrderExists25() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 2) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder26(); } } void CloseOrder26() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 2) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void IfOrderExists28() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 2) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder27(); } } void CloseOrder27() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 2) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void IfOrderExists100() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 3) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder106(); } } void CloseOrder106() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 3) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void IfOrderExists103() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 3) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder110(); } } void CloseOrder110() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 3) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void IfOrderExists114() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 4) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder117(); } } void CloseOrder117() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 4) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void IfOrderExists101() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 4) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder109(); } } void CloseOrder109() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 4) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void TechnicalAnalysis2x49() { if ((iRSI(NULL, NULL,PERSI248,PRICE_CLOSE,1) < 50) && (iRSI(NULL, NULL,PERSI1,PRICE_CLOSE,0) > 50)) { IfOrderExists50(); } } void IfOrderExists50() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 1) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder51(); } } void CloseOrder51() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 1) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void TechnicalAnalysis2x52() { if ((iRSI(NULL, NULL,PERSI277,PRICE_CLOSE,1) > 50) && (iRSI(NULL, NULL,PERSI292,PRICE_CLOSE,0) < 50)) { IfOrderExists53(); } } void IfOrderExists53() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 1) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder54(); } } void CloseOrder54() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 1) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void TechnicalAnalysis2x88() { if ((iWPR(NULL, NULL,PERWPR458,1) < -50) && (iWPR(NULL, NULL,PERWPR389,0) > -50)) { IfOrderExists91(); } } void IfOrderExists91() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 2) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder94(); } } void CloseOrder94() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 2) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void TechnicalAnalysis2x89() { if ((iWPR(NULL, NULL,PERWPR484,1) > -50) && (iWPR(NULL, NULL,PERWPR64,0) < -50)) { IfOrderExists90(); } } void IfOrderExists90() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 2) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder93(); } } void CloseOrder93() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 2) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void TechnicalAnalysis2x136() { if ((iCCI(NULL, NULL,PERCCI01,PRICE_CLOSE,1) < 0) && (iCCI(NULL, NULL,PERCCI5,PRICE_CLOSE,0) > 0)) { IfOrderExists139(); } } void IfOrderExists139() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 3) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder141(); } } void CloseOrder141() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 3) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void TechnicalAnalysis2x137() { if ((iCCI(NULL, NULL,PERCCI1,PRICE_CLOSE,1) > 0) && (iCCI(NULL, NULL,PERCCI118,PRICE_CLOSE,0) < 0)) { IfOrderExists138(); } } void IfOrderExists138() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 3) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder140(); } } void CloseOrder140() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 3) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void TechnicalAnalysis2x172() { if ((iMA(NULL, NULL,PERMA158,0,MODE_SMA,PRICE_CLOSE,1) > iMA(NULL, NULL,PERMA305,0,MODE_SMA,PRICE_CLOSE,1)) && (iMA(NULL, NULL,PERMA158,0,MODE_SMA,PRICE_CLOSE,0) < iMA(NULL, NULL,PERMA305,0,MODE_SMA,PRICE_CLOSE,0))) { IfOrderExists171(); } } void IfOrderExists171() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 4) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder168(); } } void CloseOrder168() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 4) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } void TechnicalAnalysis2x173() { if ((iMA(NULL, NULL,PERMA391,0,MODE_SMA,PRICE_CLOSE,1) < iMA(NULL, NULL,PERMA115,0,MODE_SMA,PRICE_CLOSE,1)) && (iMA(NULL, NULL,PERMA391,0,MODE_SMA,PRICE_CLOSE,0) > iMA(NULL, NULL,PERMA115,0,MODE_SMA,PRICE_CLOSE,0))) { IfOrderExists169(); } } void IfOrderExists169() { bool exists = false; for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 4) { exists = true; } } else { Print("OrderSelect() error - ", ErrorDescription(GetLastError())); } if (exists) { CloseOrder170(); } } void CloseOrder170() { int orderstotal = OrdersTotal(); int orders = 0; int ordticket[30][2]; for (int i = 0; i < orderstotal; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 4) { continue; } ordticket[orders][0] = OrderOpenTime(); ordticket[orders][1] = OrderTicket(); orders++; } if (orders > 1) { ArrayResize(ordticket,orders); ArraySort(ordticket); } for (i = 0; i < orders; i++) { if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true) { bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); if (ret == false) Print("OrderClose() error - ", ErrorDescription(GetLastError())); } } } int deinit() { if (false) ObjectsDeleteAll(); }
  • lefeuvr3

    voici le graphique
    lefeuvr3 a joint une image
    comment-debrayer-un-indicateur-d-un-ea-quand-il-y-en-a-plusieurs-sur-le-meme-ea-5986