//+------------------------------------------------------------------+
//| Signaux donnés sur Gold Cup / Telegram                           |
//+------------------------------------------------------------------+
#define o_FH5     2        // MOONBERG
#define PAUSE	   100
#import "shell32.dll"
 int ShellExecuteW(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd);
#import
#ifdef o_FH5
enum Terminals {_B3511=0, _88D6C=1, _4A35E=2, _3ECAD=3};
extern Terminals Terminal = _3ECAD;
enum Mgc_nums {GoldFinch=5555551, Prof_VIP=5555552, US30_FX=5555553, MoonBerg=5555554, Smart_FX=5555555};
extern Mgc_nums mgc_num = MoonBerg;
enum EA_nb_TPs {Pos_Standard=0, Pos_Secure_1=1, Pos_Double_2v3a=2, Pos_Double_2v3b=3, Pos_Double_2x2=4, Pos_One_more=5};
extern EA_nb_TPs EA_nb_TP = 1;
extern bool EA_TP_secure = true;
extern double _lot = 0.01;
string arr_Terms[]={"B3511AE7AE29D20268E67E28E5D8DF10", "88D6C84F78813345FFC2EF9CB2EF3EF5", "4A35EA6D7437F34CFBCDB67A8D948D9B", "3ECAD24A7B0CB731B5E16A5D902C9389"};
/*extern */bool EA_20pips = true;
#else
extern bool EA_20pips = true;
#endif
int slip#ifdef o_FH5, tickt_[2], tickt_b[2], EA_n_TP=EA_nb_TP#endif;       double lot=_lot, pips2dbl#ifdef o_FH5, LM_#endif;
string Symb_, Op_20pips, Op_Symbs, Lm_Symbs, Op_Symb2s, terminal=arr_Terms[Terminal], _p;       bool Del_Reps=false;

int OnInit() {
   EventSetTimer(10);
   if (FileIsExist(".\\Op_Symbs_List.txt")) { int handle = FileOpen(".\\Op_Symbs_List.txt", FILE_TXT|FILE_READ);
         if (handle != INVALID_HANDLE) { Op_Symbs = FileReadString(handle);      Sleep(PAUSE);     FileClose(handle);
            Alert("******* File Op_Symbs_List.txt contains: " + Op_Symbs + " *******"); }
         else Alert("*** (1) File Op_Symbs_List.txt not found, the last error is ", GetLastError() + " ***"); }
   if (FileIsExist(".\\Op_Symb2s_List.txt")) { handle = FileOpen(".\\Op_Symb2s_List.txt", FILE_TXT|FILE_READ);
         if (handle != INVALID_HANDLE) { Op_Symb2s = FileReadString(handle);     Sleep(PAUSE);     FileClose(handle);
            Alert("******* File Op_Symb2s_List.txt contains: " + Op_Symb2s + " *******"); }
         else Alert("*** (1) File Op_Symb2s_List.txt not found, the last error is ", GetLastError() + " ***"); }
   if (FileIsExist(".\\Lm_Symbs_List.txt")) { handle = FileOpen(".\\Lm_Symbs_List.txt", FILE_TXT|FILE_READ);
         if (handle != INVALID_HANDLE) { Lm_Symbs = FileReadString(handle);      Sleep(PAUSE);     FileClose(handle);
            Alert("******* File Lm_Symbs_List.txt contains: " + Lm_Symbs + " *******"); }
         else Alert("*** (1) File Lm_Symbs_List.txt not found, the last error is ", GetLastError() + " ***"); }
   return(INIT_SUCCEEDED); }

void OnTick() {
 if (FileIsExist(".\\Telegram\\Copy_Trade_On.txt", 0) || FileIsExist(".\\Telegram\\Copy_Trade_Off.txt", 0)) {
   if (FileIsExist(".\\Telegram\\Copy_Trade_On.txt", 0)) FileMove(".\\Telegram\\Copy_Trade_On.txt", 0, ".\\Telegram\\Copy_Trade_Off.txt", 0);
   int nf, _nrep=1, n_rep=1, nLines=0, row=0, cpt=0;        string filename;       // B3511AE7AE29D20268E67E28E5D8DF10 (FH4)
   int ts=ShellExecuteW(0,"open","C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal\\" + terminal + "\\MQL4\\Files\\Telegram\\"+
      "date_time.bat", ">>logs\\Copy_Trade_All.txt", "C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal\\" + terminal + "\\MQL4\\Files\\Telegram", 1);
#ifdef o_FH5   while(cpt < 23 && (ts=#else   ts =#endif ShellExecuteW(0,"open","C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal\\" + terminal + "\\MQL4\\Files\\Telegram\\"+
         "Copy_Trade_All.bat", ">>logs\\Copy_Trade_All.txt", "C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal\\" + terminal + "\\MQL4\\Files\\Telegram", 1)#ifdef o_FH5) != 42) {
Alert("******* (1) ts = " + IntegerToString(ts) + " *******");         if (cpt) Sleep(PAUSE);        cpt ++; }      cpt = 0;#else;#endif
   Sleep(5 * PAUSE);         #ifdef o_FH5 while(cpt < 23 && FileIsExist(".\\Telegram\\Copy_Trade_Bat_On.txt", 0)) { Sleep(PAUSE);
Alert("******* cpt = " + IntegerToString(cpt) + " *******");            cpt ++; }
   Sleep(PAUSE);              if (FileIsExist(".\\Telegram\\Copy_Trade_Bat_On.txt", 0)) {// FileDelete(".\\Telegram\\Copy_Trade_Off.txt", 0);
Alert("******* cpt = " + IntegerToString(cpt) + " *******");         return; }#endif         nf = 1;
   while((filename=File_Next(0, nf, 0)) != "last_file" && filename != "") if (StringSubstr(filename, StringLen(filename)-4, 4) != ".bat" &&
     #ifdef o_FH5 filename != "Copy_Trade_Bat_Off.txt" &&#endif filename != "Copy_Trade_Off.txt") FileDelete("Telegram\\"+filename, 0);            else  nf ++;
   ts = ShellExecuteW(0,"open","C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal\\" + terminal + "\\MQL4\\Files\\Telegram\\"+
      "date_time.bat", ">>logs\\Del_Trade_Dskt.txt", "C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal\\" + terminal + "\\MQL4\\Files\\Telegram", 1);
   ts = ShellExecuteW(0,"open","C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal\\" + terminal + "\\MQL4\\Files\\Telegram\\"+
      "Del_Trade_Dskt.bat", ">>logs\\Del_Trade_Dskt.txt", "C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal\\" + terminal + "\\MQL4\\Files\\Telegram", 1);
   Sleep(5 * PAUSE);          FileDelete(".\\Telegram\\Copy_Trade_Off.txt", 0);#ifdef o_FH5           cpt = 0;#endif

   while(FileIsExist(".\\Telegram_copied ("+IntegerToString(n_rep)+")\\Copy_Trade_Off.txt",0) || FileIsExist(".\\Telegram_copied ("+IntegerToString(n_rep)+")\\Copy_Trade_Bat_On.txt",0)) n_rep ++;
   n_rep --;   while(_nrep <= n_rep) { nf = 1;   while((filename=File_Next(1, nf, _nrep)) != "last_file" && filename != "") {
      if (StringSubstr(filename, StringLen(filename)-4, 4) != ".bat" &&#ifdef o_FH5 filename != "Copy_Trade_Bat_Off.txt" &&
      filename != "Copy_Trade_Bat_On.txt" &&#endif filename != "Copy_Trade_Off.txt") {
         int handle=FileOpen("Telegram_copied ("+IntegerToString(_nrep)+")\\"+filename, FILE_TXT|FILE_READ);
         string line;    if (handle != INVALID_HANDLE) { while(true) { line = "";    line = FileReadString(handle);
            if (FileIsLineEnding(handle)) nLines ++;           if (FileIsEnding(handle)) break; }        nLines ++;
            FileClose(handle);      Print("******* File "+filename+" contains "+nLines+" line"+(nLines > 1? "s": "")+" *******"); }
         else Alert("*** (1) File "+filename+" not found, the last error is ", GetLastError() + " ***"); }
         nLines ++;     nf ++; }   _nrep ++; }#ifdef o_FH5           Sleep(PAUSE);#endif
   if (line_read[0][0] != "") while(row < nLines + 1 && row < ArraySize(line_read) / 8 && line_read[row][0] != "- - -") {
      line_read[row][0] = "";       line_read[row][1] = "";       line_read[row][2] = "";       line_read[row][3] = "";
      line_read[row][4] = "";       line_read[row][5] = "";       line_read[row][6] = "";       line_read[row][7] = "";    row ++; }
   ArrayResize(line_read, nLines + 1, 1);       _nrep = 1;        row = 0;          int row_;
   while(_nrep <= n_rep) { row_ = row;          while(row_ == row && cpt < 3) {
         nf = 1;        while((filename=File_Next(1, nf, _nrep)) != "last_file" && filename != "") {
            if (StringSubstr(filename, StringLen(filename)-4, 4) != ".bat" &&#ifdef o_FH5 filename != "Copy_Trade_Bat_Off.txt" &&
            filename != "Copy_Trade_Bat_On.txt" &&#endif filename != "Copy_Trade_Off.txt") {
               line_read[row][0] = "--- " + filename + " ---------------------------------";       row ++;
               row = CSV_FILE_READ(row, _nrep, filename);            Sleep(2 * PAUSE); }           nf ++; }
         if (row_ == row) Sleep(2 * PAUSE);        cpt ++; }#ifdef o_FH5            cpt = 0;#endif
      ts = ShellExecuteW(0,"open","C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal\\" + terminal + "\\MQL4\\Files\\Telegram\\"+
         "date_time.bat", ">>logs\\Copy_Trade_All_b.txt", "C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal\\" + terminal + "\\MQL4\\Files\\Telegram", 1);
#ifdef o_FH5   while(cpt < 23 && (ts=#else   ts =#endif ShellExecuteW(0,"open","C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal\\" + terminal + "\\MQL4\\Files\\Telegram\\"+
         "Copy_Trade_All_b.bat", "\"..\\Telegram_copied ("+IntegerToString(_nrep)+")\" >>logs\\Copy_Trade_All_b.txt", "C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal"+
         "\\" + terminal + "\\MQL4\\Files\\Telegram", 1)#ifdef o_FH5) != 42) {
Alert("******* (2) ts = " + IntegerToString(ts) + " *******");         if (cpt) Sleep(PAUSE);        cpt ++; }      cpt = 0;#else;#endif           Sleep(7 * PAUSE);    // <- time en fonction du VPS
#ifdef o_FH5      while(cpt < 23 && FileIsExist(".\\Telegram\\Copy_Trade_Bat_On.txt", 0)) { Sleep(PAUSE);         cpt ++; }/*      if (cpt) Sleep(PAUSE);*/#endif
      ts = ShellExecuteW(0,"open","C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal\\" + terminal + "\\MQL4\\Files\\Telegram\\"+
         "date_time.bat", ">>logs\\Del_Trade_All.txt", "C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal\\" + terminal + "\\MQL4\\Files\\Telegram", 1);
      ts = ShellExecuteW(0,"open","C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal\\" + terminal + "\\MQL4\\Files\\Telegram\\"+
         "Del_Trade_All.bat", "\"..\\Telegram_copied ("+IntegerToString(_nrep)+")\" >>logs\\Del_Trade_All.txt", 
         "C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal\\" + terminal + "\\MQL4\\Files\\Telegram", 1);
      Sleep(2 * PAUSE);          _nrep ++; }       line_read[row][0] = "- - -";

   int col=0;        row = 0;          string temp=TimeToStr(TimeCurrent(), TIME_DATE|TIME_SECONDS);
   while(row < ArraySize(line_read) / 8 && line_read[row][0] != "- - -") {
      temp += (row? "\r\n": " ") + line_read[row][col] + " " + line_read[row][col+1] + " " + line_read[row][col+2] + " " + line_read[row][col+3] + " " +
         line_read[row][col+4] + " " + line_read[row][col+5] + " " + line_read[row][col+6] + " " + line_read[row][col+7];        row ++; }
   temp += "\r\n--------------------------------------------------------------------------------";             copy_file(0, temp);

   int type, ticket;       bool t_close;        row = 0;     col = 0;      cpt = 0;
   while(row < ArraySize(line_read) / 8 && line_read[row][0] != "- - -") {
Alert("*****1* "+IntegerToString(row)+" - "+line_read[row][0]+" *******");
      type = 0;   ticket = 0;    slip = 2;            //      if (line_read[row][0] == "Share") type = 0;
#ifdef o_FH5
      if ((line_read[row-3][0] == "Professor" && StringSubstr(line_read[row-3][1],0,3) == "VIP" && line_read[row-3][2] == "(yearly)," && (Day() !=
      StrToInteger(StringSubstr(line_read[row-3][3],1,2)) || Hour()-StrToInteger(StringSubstr(line_read[row-3][4],0,2))>(Minute()?1:2) || Minute()-StrToInteger(StringSubstr(line_read[row-3][4],3,2)) > 17)) ||
      (line_read[row-1][0] == "Professor" && StringSubstr(line_read[row-1][1],0,3) == "VIP" && line_read[row-1][2] == "(yearly)," && (Day() !=
      StrToInteger(StringSubstr(line_read[row-1][3],1,2)) || Hour()-StrToInteger(StringSubstr(line_read[row-1][4],0,2))>(Minute()?1:2) || Minute()-StrToInteger(StringSubstr(line_read[row-1][4],3,2)) > 17)) ||
      (line_read[row-15][0] == "Professor" && StringSubstr(line_read[row-15][1],0,3) == "VIP" && line_read[row-15][2] == "(yearly)," && (Day() !=
      StrToInteger(StringSubstr(line_read[row-15][3],1,2)) || Hour()-StrToInteger(StringSubstr(line_read[row-15][4],0,2))>(Minute()?1:2) || Minute()-StrToInteger(StringSubstr(line_read[row-15][4],3,2)) > 17)) ||
      (line_read[row-14][0] == "Professor" && StringSubstr(line_read[row-14][1],0,3) == "VIP" && line_read[row-14][2] == "(yearly)," && (Day() !=
      StrToInteger(StringSubstr(line_read[row-14][3],1,2)) || Hour()-StrToInteger(StringSubstr(line_read[row-14][4],0,2))>(Minute()?1:2) || Minute()-StrToInteger(StringSubstr(line_read[row-14][4],3,2)) > 17))) {
#else
      if ((StringSubstr(line_read[row-3][1],0,1) == "[" && StrToInteger(StringSubstr(line_read[row-3][2],0,2)) && StrToInteger(StringSubstr(line_read[row-3][2],3,2)) && (Day() !=
      StrToInteger(StringSubstr(line_read[row-3][1],1,2)) || Hour()-StrToInteger(StringSubstr(line_read[row-3][2],0,2)) > 1 || Minute()-StrToInteger(StringSubstr(line_read[row-3][2],3,2)) > 17)) ||
      (StringSubstr(line_read[row-1][1],0,1) == "[" && StrToInteger(StringSubstr(line_read[row-1][2],0,2)) && StrToInteger(StringSubstr(line_read[row-1][2],3,2)) && (Day() !=
      StrToInteger(StringSubstr(line_read[row-1][1],1,2)) || Hour()-StrToInteger(StringSubstr(line_read[row-1][2],0,2)) > 1 || Minute()-StrToInteger(StringSubstr(line_read[row-1][2],3,2)) > 17))) {
#endif
Alert("*****1b* "+IntegerToString(row)+" - "+line_read[row-3][0]+" - "+line_read[row-3][1]+" - "+line_read[row-3][2]+" - "+line_read[row-3][3]+" - "+line_read[row-3][4]+" - "+
   StringSubstr(line_read[row-3][4], 0, 2) + " - " + StringSubstr(line_read[row-3][4], 3, 2)+" | "+line_read[row-1][0]+" - "+line_read[row-1][1]+" - "+line_read[row-1][2]+" - "+
   line_read[row-1][3]+" - "+line_read[row-1][4]+" - "+StringSubstr(line_read[row-1][4], 0, 2)+" - " + StringSubstr(line_read[row-1][4], 3, 2)+#ifdef o_FH5" | "+line_read[row-15][0]+
   " - "+line_read[row-15][1]+" - "+line_read[row-15][2]+" - "+line_read[row-15][3]+" - "+line_read[row-15][4]+" - "+StringSubstr(line_read[row-15][3], 1, 2)+" - "+StringSubstr(line_read[row-15][4],
   0, 2)+" - "+StringSubstr(line_read[row-15][4], 3, 2)+" | "+line_read[row-14][0]+" - "+line_read[row-14][1]+" - "+line_read[row-14][2]+" - "+line_read[row-14][3]+" - "+line_read[row-14][4]+" - "+
   StringSubstr(line_read[row-14][3], 1, 2)+" - "+StringSubstr(line_read[row-14][4], 0, 2)+" - "+StringSubstr(line_read[row-14][4], 3, 2)+#endif" *******");
         row ++;        continue; }
#ifdef o_FH5 
      type = line_read_type(row);         string Symb;         double LM;
      while((! ticket || ticket == -1) && cpt < 9) { int icase=line_read_switch(type, row);
         ticket = tickt_[0];        Symb = Symb_;        LM = LM_;
         if (type == 2 && ticket) { tickt_b[0] = tickt_[0];       tickt_b[1] = tickt_[1]; }        // else tickt_b = 0;
#else
      if ((line_read[row][0] == "Sell" || line_read[row][0] == "Buy") && line_read[row][1] == "again") type = 1;
      else if ((line_read[row][0] == "Sell" || line_read[row][0] == "Buy") && line_read[row][1] == "limit") type = 2;
      else if ((line_read[row][0] == "TP" || line_read[row][0] == "TO") && line_read[row-1][0] == "SL" && (row+2 > ArraySize(line_read)/8-1 ||
         (StringSubstr(line_read[row+2][0], 3, 4) != "pips" && line_read[row+2][1] != "profit," && line_read[row+2][1] != "again"))) type = 3;
//      if (line_read[row][0] == "GOLD" && line_read[row][1] == "CUP") type = 4;
      else if ((line_read[row][0] == "join" || line_read[row][0] == "@iml_goldcup") && (line_read[row-2][0] == "TP" || line_read[row-2][0] == "TO")) type = 4;
      else if (StringSubstr(line_read[row][0], 3, 4) == "pips" && line_read[row][1] == "profit,") type = 5;
      else if (StringSubstr(line_read[row][0], 2, 4) == "pips" && line_read[row][1] == "profit,") type = 6;
      else if (line_read[row][0] == "CLOSE" || line_read[row][0] == "close") type = 7;
      else if (line_read[row][0] == "DAILY" && line_read[row][1] == "STATS") type = 8;
      else if (line_read[row][0] == "Sell" || line_read[row][0] == "sell" || line_read[row][0] == "Buy" || line_read[row][0] == "buy") type = 9;

      while((! ticket || ticket == -1) && cpt < 9) { switch(type) {
         case 1  :
Alert("*****2-1* "+IntegerToString(row)+" - "+line_read[row][0]+" - "+line_read[row-2][1]+" - "+line_read[row-3][1]+" - "+line_read[row-4][2]+" - "+line_read[row-4][1]+" - "+line_read[row-4][0]+" *******");
            double TP=StrToDouble(line_read[row-2][1]), SL=StrToDouble(line_read[row-3][1]), LM=StrToDouble(line_read[row-4][2]);
            string Symb=line_read[row-4][0];          int icase=0;
            ResetLastError();    if (StringFind(Symb, "/") > 0) Symb = StringSubstr(Symb, 0, StringFind(Symb, "/"));
            if (Symb == "GOLD" || Symb == "Gold") Symb = "XAUUSD";         Symb += "p";         if (Symb == "XBRUSDp") Symb = "BRENT";
// . . .
         break;
         case 2  :
Alert("*****2-2* "+IntegerToString(row)+" - "+line_read[row][0]+" - "+line_read[row-2][1]+" - "+line_read[row-3][1]+" - "+line_read[row-4][2]+" - "+line_read[row-4][1]+" - "+line_read[row-4][0]+" *******");
            LM = StrToDouble(line_read[row][4]);         Symb = line_read[row][2];         ticket = 0;       icase = 0;
            SL = line_read[row+2][0] == "TP"? StrToDouble(line_read[row+3][1]): StrToDouble(line_read[row+2][1]);
            TP = line_read[row+2][0] == "TP"? fabs(LM - StrToDouble(line_read[row+2][1])) > fabs(LM - StrToDouble(line_read[row+1][1]))? 
               StrToDouble(line_read[row+2][1]): StrToDouble(line_read[row+1][1]): StrToDouble(line_read[row+1][1]);
            Bull = line_read[row][0] == "BUY" || line_read[row][0] == "Buy" || line_read[row][0] == "buy";
            ResetLastError();    if (StringFind(Symb, "/") > 0) Symb = StringSubstr(Symb, 0, StringFind(Symb, "/"));
            if (Symb == "GOLD" || Symb == "Gold") Symb = "XAUUSD";         Symb += "p";         if (Symb == "XBRUSDp") Symb = "BRENT";
// . . .
         break;
         case 3  :
Alert("*****2-3* "+IntegerToString(row)+" - "+line_read[row][0]+" - "+line_read[row][1]+" - "+line_read[row-1][1]+" - "+line_read[row-2][2]+" - "+line_read[row-2][1]+" - "+line_read[row-2][0]+" *******");
            TP = StrToDouble(line_read[row][1]);      SL = StrToDouble(line_read[row-1][1]);    LM = StrToDouble(line_read[row-2][2]);
            Bull = line_read[row-2][1] == "BUY";      Symb = line_read[row-2][0];         ticket = 0;       icase = 0;
            ResetLastError();    if (StringFind(Symb, "/") > 0) Symb = StringSubstr(Symb, 0, StringFind(Symb, "/"));
            if (Symb == "GOLD" || Symb == "Gold") Symb = "XAUUSD";         Symb += "p";         if (Symb == "XBRUSDp") Symb = "BRENT";
// . . .
         break;
         case 4  :
Alert("*****2-4* "+IntegerToString(row)+" - "+line_read[row][0]+" - "+line_read[row-2][1]+" - "+line_read[row-3][1]+" - "+line_read[row-4][2]+" - "+line_read[row-4][1]+" - "+line_read[row-4][0]+" *******");
            TP = StrToDouble(line_read[row-2][1]);    SL = StrToDouble(line_read[row-3][1]);    LM = StrToDouble(line_read[row-4][2]);
            Bull = line_read[row-4][1] == "BUY";      Symb = line_read[row-4][0];         ticket = 0;       icase = 0;
            ResetLastError();    if (StringFind(Symb, "/") > 0) Symb = StringSubstr(Symb, 0, StringFind(Symb, "/"));
            if (Symb == "GOLD" || Symb == "Gold") Symb = "XAUUSD";         Symb += "p";         if (Symb == "XBRUSDp") Symb = "BRENT";
// . . .
         break;
         case 7  :
Alert("*****2-7* "+IntegerToString(row)+" - "+line_read[row][0]+" - "+line_read[row][1]+" *******");
            Symb = line_read[row][1];                 ResetLastError();
            if (StringFind(Symb, "/") > 0) Symb = StringSubstr(Symb, 0, StringFind(Symb, "/"));
            if (Symb == "GOLD" || Symb == "Gold") Symb = "XAUUSD";         Symb += "p";         if (Symb == "XBRUSDp") Symb = "BRENT";
// . . .
         break;
         case 9  :
Alert("*****2-9* "+IntegerToString(row)+" - "+line_read[row][0]+" - "+line_read[row][1]+" *******");
            TP = StrToDouble(line_read[row+2][1]);       SL = StrToDouble(line_read[row+1][1]);
            Symb = line_read[row][1];        ResetLastError();       ticket = 0;       icase = 0;
            Bull = line_read[row][0] == "Buy" || line_read[row][0] == "buy";
            if (Symb == "GOLD" || Symb == "gold") Symb = "XAUUSD";
            if (StringFind(Symb, "/") > 0) Symb = StringSubstr(Symb, 0, StringFind(Symb, "/"));
            if (Symb == "GOLD" || Symb == "Gold") Symb = "XAUUSD";         Symb += "p";         if (Symb == "XBRUSDp") Symb = "BRENT";
// . . .
         break;
         default :
Alert("*****2-0* "+IntegerToString(row)+" - "+line_read[row][0]+" - "+line_read[row][1]+" *******"); }
#endif
if (icase) Alert("******* "+IntegerToString(icase)+" - "+DoubleToStr(MarketInfo(Symb,MODE_BID), MarketInfo(Symb, MODE_DIGITS))+" - "+DoubleToStr(MarketInfo(Symb,MODE_ASK), MarketInfo(Symb, MODE_DIGITS))+" - "+
   DoubleToStr(iCustom(Symb, PERIOD_M30, "New folder\\ADX.ex4", 1, 14), 2)+" - "+DoubleToStr(iCustom(Symb, PERIOD_M30, "New folder\\ADX.ex4", 1, 7), 2)+" - "+IntegerToString(ticket)+" - "+GetLastError()+" *******");
#ifdef o_FH5
if (line_read[row-3][2] == "(yearly),") Alert("*****1c* "+IntegerToString(row)+" - "+line_read[row-3][0]+" - "+line_read[row-3][1]+" - "+line_read[row-3][2]+" - "+line_read[row-3][3]+" - "+line_read[row-3][4]+" - "+
#else
if (StrToInteger(StringSubstr(line_read[row-3][1], 1, 2)) == Day() || icase)
   Alert("*****1c* "+IntegerToString(row) + " - " + line_read[row-3][0] + " - " + line_read[row-3][1] + " - " + line_read[row-3][2] + " - " + line_read[row-3][3] + " - " + line_read[row-3][4] + " - " +
#endif
   StringSubstr(line_read[row-3][2], 0, 2) + " - " + StringSubstr(line_read[row-3][2], 3, 2) + " - " + StringSubstr(line_read[row-3][0], 0, 4) + " - " + StringSubstr(line_read[row-3][0], 4, 3) + " - " +
   StringLen(line_read[row-3][0])+ " *******");
      if ((! ticket || ticket == -1) && iCustom(Symb, PERIOD_M30, "New folder\\ADX.ex4", 1, 7) < 47) { if (slip == 2) slip = 5;     else cpt = 9; }      else cpt = 9; }
      cpt = 0;          row ++; } }

   int total=OrdersTotal(), itmp#ifdef o_FH5, n_tcks#endif;      bool tst;      double ordprof, dtmp;
   for (int pos=0; pos < total; pos ++) { slip = 2;
      if (!OrderSelect(pos, SELECT_BY_POS) || OrderMagicNumber()!=mgc_num) continue;      ticket = OrderTicket();       //BrokerDigitAdjust(OrderSymbol());
if (FileIsExist(".\\Telegram\\Copy_Trade_On.txt", 0)) 
Alert("*****1* OrderSelect: "+IntegerToString(pos)+" - "+IntegerToString(total)+" - "+OrderSelect(pos, SELECT_BY_POS)+" - "+IntegerToString(OrderTicket())+" *******");
#ifdef o_FH5      n_tcks = OrderSymbol() == "XAUUSD"+_p? 237: 187;      int ticket_;#endif
      if (StringFind(OrderComment(), "|") > 0 || StringFind(OrderComment(), "-") > 0) {
         if (StringFind(OrderComment(), "|") > 0) LM = StrToDouble(StringSubstr(OrderComment(), 0, StringFind(OrderComment(), "|") - 1));
         if (StringFind(OrderComment(), "-") > 0) LM = StrToDouble(StringSubstr(OrderComment(), StrToInteger(StringSubstr(OrderComment(), 0, 1))? 0: 1, 
            StringFind(OrderComment(), "-") - (StrToInteger(StringSubstr(OrderComment(), 0, 1))? 1: 2)));      //int(pips2dbl / MarketInfo(OrderSymbol(),MODE_POINT))
         ordprof = LM > 0.0? OrderProfit() + ((OrderType()? 1: -1) * (LM - OrderOpenPrice()) / MarketInfo(OrderSymbol(), MODE_TICKSIZE) - 10) *
            MarketInfo(OrderSymbol(), MODE_TICKVALUE) * lot: OrderProfit(); }       else { ordprof = OrderProfit();        LM = 0.0; }    // ^ rapport à 197 ticks
#ifdef o_FH5
      if (! EA_20pips && (! GlobalVariableCheck(OrderSymbol() + StringSubstr(IntegerToString(OrderTicket()), StringLen(IntegerToString(OrderTicket())) - 4) + "_TP1") ||
      GlobalVariableGet(OrderSymbol() + StringSubstr(IntegerToString(OrderTicket()), StringLen(IntegerToString(OrderTicket())) - 4) + "_TP1") == 0.0 ||
      ! GlobalVariableCheck(OrderSymbol() + StringSubstr(IntegerToString(OrderTicket()), StringLen(IntegerToString(OrderTicket())) - 4) + "_TP2") ||
      GlobalVariableGet(OrderSymbol() + StringSubstr(IntegerToString(OrderTicket()), StringLen(IntegerToString(OrderTicket())) - 4) + "_TP2") == 0.0)) continue;
#else
      if (! EA_20pips && StringFind(Op_20pips, OrderSymbol()) == -1) continue;
#endif
#ifdef o_FH5                                                                           // * le cas du mOrdersTotal(OrderSymbol(), OrderStopLoss()) == 3 n'est pas traité correctement *
/*      if (EA_TP_secure && (OrderSymbol() == "XAUUSD" || OrderSymbol() == "DJ30") && AccountBalance() < 200.0 * lot / 0.01 && (mOrdersTotal(OrderSymbol(), OrderStopLoss()) % 2) > 0) EA_n_TP = 1;
      else EA_n_TP = EA_nb_TP; */        switch(EA_n_TP) {
         case 0  :
#endif
      if (round(ordprof*100.0)/100.0 > (dtmp=(n_tcks * lot * MarketInfo(OrderSymbol(), MODE_TICKVALUE))) && OrderType() < 2 && !((itmp=mOrdersTotal(OrderSymbol(), OrderStopLoss())) % 2)) {
         t_close = false;        cpt = 0;          tst = OrderSelect(ticket, SELECT_BY_TICKET);
         while (! t_close && (cpt < 4 || slip == 2)) { t_close = OrderClose(ticket, lot, OrderType()? MarketInfo(OrderSymbol(),MODE_ASK): MarketInfo(OrderSymbol(),MODE_BID), slip, clrNONE);
            if (cpt) { Sleep(5 * PAUSE);        RefreshRates(); }          cpt ++;
            if (slip == 2 && cpt == 4) { slip = 5;       cpt = 0; } }
         if (! t_close) Alert("***** Ticket NOT CLOSED! (2) " + ticket + " - " + GetLastError() + " *****");
         else { Sleep(2 * PAUSE);         pos --;
            if (OrderSelect(mOrderSelect(1, OrderSymbol(), !OrderType()), SELECT_BY_POS)) { ticket = OrderTicket();
               tst = OrderModify(ticket, OrderOpenPrice(), (OrderType() && LM < OrderOpenPrice() && LM > 0.0) || 
                  (! OrderType() && LM > OrderOpenPrice()) ? LM : OrderOpenPrice(), OrderTakeProfit(), 0, clrNONE);
Alert("*****2* (0) OrderSelect: "+IntegerToString(tst)+" - "+IntegerToString(ticket)+" - "+OrderCloseTime()+" - "+IntegerToString(OrderTicket())+" - "+DoubleToStr(LM, MarketInfo(OrderSymbol(), MODE_DIGITS))+" *******");
             }// }
else Alert("*****3* (0) OrderSelect: " + IntegerToString(ticket) + " - " + OrderCloseTime() + " - " + mOrderSelect(1, OrderSymbol(), !OrderType()) + " - " + IntegerToString(OrderTicket()) + " - " +
   DoubleToStr(LM, MarketInfo(OrderSymbol(), MODE_DIGITS))+" *******"); }
if (FileIsExist(".\\Telegram\\Copy_Trade_On.txt", 0)) 
Alert("******* (0) +20pips: "+OrderTicket()+" - "+OrderSymbol()+" - "+OrderProfit()+" - "+DoubleToStr(MarketInfo(OrderSymbol(), MODE_TICKVALUE), MarketInfo(OrderSymbol(), MODE_DIGITS))+" - "+
   DoubleToStr(200 * MarketInfo(OrderSymbol(), MODE_TICKVALUE), MarketInfo(OrderSymbol(), MODE_DIGITS))+" - "+DoubleToStr(200.0 * MarketInfo(OrderSymbol(), MODE_TICKVALUE), MarketInfo(
   OrderSymbol(), MODE_DIGITS))+" - "+DoubleToStr(MarketInfo(OrderSymbol(), MODE_TICKSIZE), MarketInfo(OrderSymbol(), MODE_DIGITS))+" - "+DoubleToStr(200 * MarketInfo(OrderSymbol(), 
   MODE_TICKSIZE), MarketInfo(OrderSymbol(), MODE_DIGITS))+" - "+DoubleToStr(200.0 * MarketInfo(OrderSymbol(), MODE_TICKSIZE), MarketInfo(OrderSymbol(), MODE_DIGITS))+" - "+
   mOrdersTotal(OrderSymbol(), OrderStopLoss())+" | "+IntegerToString(pos)+" - "+IntegerToString(total)+" - "+OrderSelect(pos, SELECT_BY_POS)+" *******"); }
#ifdef o_FH5
         break;
         case 1  :
      if (round(ordprof*100.0)/100.0 > (dtmp=(n_tcks * lot * MarketInfo(OrderSymbol(), MODE_TICKVALUE))) && OrderType() < 2 &&
      fabs(OrderStopLoss() - OrderOpenPrice()) > n_tcks * MarketInfo(OrderSymbol(), MODE_DIGITS)) {
//         if (OrderSelect(mOrderSelect(1, OrderSymbol(), !OrderType()), SELECT_BY_POS)) { ticket = OrderTicket();
            tst = OrderModify(ticket, OrderOpenPrice(), (OrderType() && LM < OrderOpenPrice() && LM > 0.0) || 
               (! OrderType() && LM > OrderOpenPrice()) ? LM : OrderOpenPrice(), OrderTakeProfit(), 0, clrNONE);
Alert("*****2* (1) OrderSelect: "+IntegerToString(tst)+" - "+IntegerToString(ticket)+" - "+OrderCloseTime()+" - "+IntegerToString(OrderTicket())+" - "+DoubleToStr(LM, MarketInfo(OrderSymbol(), MODE_DIGITS))+" *******");
/*             }// }
else Alert("*****3* (1) OrderSelect: " + IntegerToString(ticket) + " - " + OrderCloseTime() + " - " + mOrderSelect(1, OrderSymbol(), !OrderType()) + " - " + IntegerToString(OrderTicket()) + " - " +
   DoubleToStr(LM, MarketInfo(OrderSymbol(), MODE_DIGITS))+" *******");*/ }
         break;
         case 2  :      double TP2=GlobalVariableGet(OrderSymbol() + StringSubstr(IntegerToString(OrderTicket()), StringLen(IntegerToString(OrderTicket())) - 4) + "_TP2"),
            TP3=GlobalVariableGet(OrderSymbol() + StringSubstr(IntegerToString(OrderTicket()), StringLen(IntegerToString(OrderTicket())) - 4) + "_TP3");
      if (round(ordprof*100.0)/100.0 > (dtmp=(n_tcks * lot * MarketInfo(OrderSymbol(), MODE_TICKVALUE))) && OrderType() < 2 && !((itmp=mOrdersTotal(OrderSymbol(), OrderStopLoss())) % 2)) {
         t_close = false;        cpt = 0;          tst = OrderSelect(ticket, SELECT_BY_TICKET);
         while (! t_close && (cpt < 4 || slip == 2)) { t_close = OrderClose(ticket, lot, OrderType()? MarketInfo(OrderSymbol(),MODE_ASK): MarketInfo(OrderSymbol(),MODE_BID), slip, clrNONE);
            if (cpt) { Sleep(5 * PAUSE);        RefreshRates(); }          cpt ++;
            if (slip == 2 && cpt == 4) { slip = 5;       cpt = 0; } }
         if (! t_close) Alert("***** Ticket NOT CLOSED! (2) " + ticket + " - " + GetLastError() + " *****");
         else { Sleep(2 * PAUSE);         pos --;        ticket = 0;
            if (OrderSelect(mOrderSelect(1, OrderSymbol(), !OrderType()), SELECT_BY_POS)) { ticket = OrderTicket();
               tst = OrderModify(ticket, OrderOpenPrice(), (OrderType() && LM < OrderOpenPrice() && LM > 0.0) || 
                  (! OrderType() && LM > OrderOpenPrice()) ? LM : OrderOpenPrice(), TP3, 0, clrNONE);
Alert("*****2* (2) OrderSelect: "+IntegerToString(tst)+" - "+IntegerToString(ticket)+" - "+OrderCloseTime()+" - "+IntegerToString(OrderTicket())+" - "+DoubleToStr(LM, MarketInfo(OrderSymbol(), MODE_DIGITS))+" *******");
             }// }
else Alert("*****3* (2) OrderSelect: " + IntegerToString(ticket) + " - " + OrderCloseTime() + " - " + mOrderSelect(1, OrderSymbol(), !OrderType()) + " - " + IntegerToString(OrderTicket()) + " - " +
   DoubleToStr(LM, MarketInfo(OrderSymbol(), MODE_DIGITS))+" *******"); } }
      double TP1=ticket? GlobalVariableGet(OrderSymbol() + StringSubstr(IntegerToString(ticket), StringLen(IntegerToString(ticket)) - 4) + "_TP1"): 0.0;
      if (((OrderType() && MarketInfo(OrderSymbol(), MODE_BID) < TP2) || (! OrderType() && MarketInfo(OrderSymbol(), MODE_ASK) > TP2)) && ticket &&
      (OrderTakeProfit() != TP3 || OrderStopLoss() != TP1)) tst = OrderModify(ticket, OrderOpenPrice(), TP1, TP3, 0, clrNONE);
         break;
         case 3  :      TP2 = GlobalVariableGet(OrderSymbol() + StringSubstr(IntegerToString(OrderTicket()), StringLen(IntegerToString(OrderTicket())) - 4) + "_TP2");
            TP3 = GlobalVariableGet(OrderSymbol() + StringSubstr(IntegerToString(OrderTicket()), StringLen(IntegerToString(OrderTicket())) - 4) + "_TP3");
      if (round(ordprof*100.0)/100.0 > (dtmp=(n_tcks * lot * MarketInfo(OrderSymbol(), MODE_TICKVALUE))) && OrderType() < 2 && !((itmp=mOrdersTotal(OrderSymbol(), OrderStopLoss())) % 2) &&
      OrderTakeProfit() != TP3) { bool done=GlobalVariableCheck(OrderSymbol() + "_" + DoubleToStr(OrderStopLoss()/MarketInfo(OrderSymbol(), MODE_DIGITS), 0)) &&
         (ticket_=GlobalVariableGet(OrderSymbol() + "_" + DoubleToStr(OrderStopLoss()/MarketInfo(OrderSymbol(), MODE_DIGITS), 0))) > 0 &&
         GlobalVariableCheck(OrderSymbol() + StringSubstr(IntegerToString(ticket_), StringLen(IntegerToString(ticket_)) - 4) + "_TPx");
         if (! done) {
            GlobalVariableSet(OrderSymbol() + StringSubstr(IntegerToString(OrderTicket()), StringLen(IntegerToString(OrderTicket())) - 4) + "_TPx", 1.0);
            GlobalVariableSet(OrderSymbol() + "_" + DoubleToStr(OrderStopLoss()/MarketInfo(OrderSymbol(), MODE_DIGITS), 0), OrderTicket()); }
//         if (OrderSelect(mOrderSelect(1, OrderSymbol(), !OrderType()), SELECT_BY_POS)) { ticket = OrderTicket();
            tst = OrderModify(ticket, OrderOpenPrice(), (OrderType() && LM < OrderOpenPrice() && LM > 0.0) || 
               (! OrderType() && LM > OrderOpenPrice()) ? LM : OrderOpenPrice(), done? TP2: TP3, 0, clrNONE);
Alert("*****2* (3) OrderSelect: "+IntegerToString(tst)+" - "+IntegerToString(ticket)+" - "+OrderCloseTime()+" - "+IntegerToString(OrderTicket())+" - "+DoubleToStr(TP2, MarketInfo(OrderSymbol(), MODE_DIGITS))+
   " - " + DoubleToStr(TP3, MarketInfo(OrderSymbol(), MODE_DIGITS)) + " - " + DoubleToStr(OrderTakeProfit(), MarketInfo(OrderSymbol(), MODE_DIGITS)) + " *******");
/*             }// }
else Alert("*****3* (3) OrderSelect: " + IntegerToString(ticket) + " - " + OrderCloseTime() + " - " + mOrderSelect(1, OrderSymbol(), !OrderType()) + " - " + IntegerToString(OrderTicket()) + " - " +
   DoubleToStr(LM, MarketInfo(OrderSymbol(), MODE_DIGITS))+" *******");*/ }
      TP1 = ticket? GlobalVariableGet(OrderSymbol() + StringSubstr(IntegerToString(ticket), StringLen(IntegerToString(ticket)) - 4) + "_TP1"): 0.0;
      if (((OrderType() && MarketInfo(OrderSymbol(), MODE_BID) < TP2) || (! OrderType() && MarketInfo(OrderSymbol(), MODE_ASK) > TP2)) && ticket &&
      OrderStopLoss() != TP1) tst = OrderModify(ticket, OrderOpenPrice(), TP1, OrderTakeProfit(), 0, clrNONE);
         break;
         case 4  :
         break;
         case 5  :
         break; }
#endif }

   while(Hour() == 22 && StringFind(Op_Symbs, ":" + IntegerToString(Day()-1)) > 0) Op_Symbs = StringSubstr(Op_Symbs, StringFind(Op_Symbs, ":" + IntegerToString(Day()-1)) + 8);
   while(Hour() == 22 && StringFind(Op_Symbs, ":|") > 0) Op_Symbs = StringSubstr(Op_Symbs, StringFind(Op_Symbs, ":|") + 2);
   while(Hour() == 22 && StringFind(Lm_Symbs, ":" + IntegerToString(Day()-1)) > 0) Lm_Symbs = StringSubstr(Lm_Symbs, StringFind(Lm_Symbs, ":" + IntegerToString(Day()-1)) + 8);
   while(Hour() == 22 && StringFind(Lm_Symbs, ":|") > 0) Lm_Symbs = StringSubstr(Lm_Symbs, StringFind(Lm_Symbs, ":|") + 2);
   if (Hour() == 22 && ! Minute() && Seconds() < 15 && ! Del_Reps) { Del_Reps = true;         Op_Symb2s = "";         FileDelete("Op_Symb2s_List.txt", 0);
      ts = ShellExecuteW(0,"open","C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal\\" + terminal + "\\MQL4\\Files\\Telegram\\"+
         "date_time.bat", ">>logs\\Del_Reps_Trades.txt", "C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal\\" + terminal + "\\MQL4\\Files\\Telegram", 1);
      ts = ShellExecuteW(0,"open","C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal\\" + terminal + "\\MQL4\\Files\\Telegram\\"+
         "Del_Reps_Trades.bat", ">>logs\\Del_Reps_Trades.txt", "C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal\\" + terminal + "\\MQL4\\Files\\Telegram", 1); }
   else if (Minute()) Del_Reps = false; }

void OnDeinit(const int reason) {
   if (Op_Symbs != "") { FileDelete("Op_Symbs_List.txt", 0);      Sleep(PAUSE);     copy_file(1, Op_Symbs); }
   if (Op_Symb2s != "") { FileDelete("Op_Symb2s_List.txt", 0);    Sleep(PAUSE);     copy_file(2, Op_Symb2s); }
   if (Lm_Symbs != "") { FileDelete("Lm_Symbs_List.txt", 0);      Sleep(PAUSE);     copy_file(3, Lm_Symbs); }
   EventKillTimer(); }

void OnTimer() { }

string File_Next(bool mode,int nf,int n_rep) {
   string tel_dir=mode? "Telegram"+(n_rep? "_copied ("+IntegerToString(n_rep)+")": "")+"\\*": "Telegram\\*", filename;  // dans .\MQL4\Files
   int i=1, pos=0, last_pos=-1;     bool tst=false;

//--- get the search handle in the root of the local folder
   long search_handle=FileFindFirst(tel_dir, filename, 0);
   if (search_handle==INVALID_HANDLE) { Print("*** INVALID_HANDLE - "+tel_dir+" - "+filename+" ***");   return(""); }

//--- check if the FileFindFirst() is executed successfully
   if (search_handle!=INVALID_HANDLE) {
      //--- in a loop, check if the passed strings are the names of files or directories
      do { ResetLastError();
         //--- if it's a file, the function returns true, and if it's a directory, it returns error ERR_FILE_IS_DIRECTORY
         FileIsExist(StringSubstr(tel_dir, 0, StringLen(tel_dir)-1) + filename);
         if (GetLastError() == ERR_FILE_IS_DIRECTORY) i --;
//         PrintFormat("%d : %s name = %s", i, GetLastError()==ERR_FILE_IS_DIRECTORY? "Directory": "File", filename);
//         if (StringSubstr(filename, 0, StringLen(symbol)) == symbol) break;
         if (i == nf) { tst = true;     break; }    i ++; }    // i peut être utilisé comme numéro de fichier dans la liste

      while(FileFindNext(search_handle,filename));

//      if (!FileFindNext(search_handle, next)) filename = "last_file";
      if (! tst) filename = "last_file";

      //--- close the search handle
      FileFindClose(search_handle); }
   else { Print("Files not found!");   filename = "File not found(0)"; }

//   MessageBox(filename, NULL, MB_OK);
   return(filename); }

string line_read[][8];
int CSV_FILE_READ(int _row,int n_rep,string filename) {
   filename = ".\\Telegram_copied ("+IntegerToString(n_rep)+")\\" + filename;
   int row=_row, col=0, handle=FileOpen(filename,FILE_CSV|FILE_READ, " ");
   if(handle > 0) {
      while(True && col < 8) { string temp=FileReadString(handle);
#ifdef o_FH5
         temp = StringTrimLeft(StringTrimRight(temp));
         line_read[row][col] = temp != "" ? temp : ".";
#else
         line_read[row][col] = temp;
#endif
         if (FileIsEnding(handle)) break;
         if (FileIsLineEnding(handle)) {
            col = 0;       row ++; }
         else#ifdef o_FH5 if (col < 7)#endif col ++; }      row ++;
      FileClose(handle); }
   else Alert("*** (2) File "+filename+" not found, the last error is ", GetLastError() + " ***");
   return(row); }

void copy_file(int Item,string temp) { int handle;
   string filename=Item? Item==1? "Op_Symbs_List.txt": Item==2? "Op_Symb2s_List.txt": "Lm_Symbs_List.txt": "macro_logs_copy.log";
   if (!FileIsExist(filename)) handle = FileOpen (filename,FILE_TXT|FILE_WRITE);
   else   handle = FileOpen (filename,FILE_TXT|FILE_READ|FILE_WRITE);
   if (handle != INVALID_HANDLE) {
      if (FileSize(handle) > 0) FileSeek(handle, FileSize(handle), 0);
      FileWrite(handle, temp); }
   else Print ("*** Problème : handle == INVALID_HANDLE. (2) / "+Symbol()+" / "+GetLastError()+" ***");
   FileClose(handle); }

int mOrdersTotal(string Symb,double SL) { int total=OrdersTotal(), mtotal=0;
  if (Symb == "" || Symb == NULL) return(mtotal);        datetime otime;

  for (int pos=0; pos < total; pos ++) {
      if (! OrderSelect(pos, SELECT_BY_POS)) continue;
      if (!mtotal && OrderSymbol()==Symb && OrderType() < 2 && OrderStopLoss()==0.0 && OrderMagicNumber()==mgc_num) otime = OrderOpenTime();
      if (OrderSymbol() == Symb && OrderType() < 2 && ((SL > 0.0 && SL == OrderStopLoss()) ||
         (SL == 0.0 && fabs(otime - OrderOpenTime()) < 17)) && OrderMagicNumber() == mgc_num) mtotal ++; }
  return(mtotal); }

int mOrderSelect(bool Mode,string Symb,bool Bull) { bool tst=false;
  if (Symb == "" || Symb == NULL) return(0);
  int total=OrdersTotal(), pos0=-1, ticket;        double PL0=0.0;

  for (int pos=0; pos < total; pos ++) {     // && ! tst
      if (! OrderSelect(pos, SELECT_BY_POS)) continue;         ticket = OrderTicket();
      if (OrderSymbol()==Symb && OrderMagicNumber()==mgc_num && (!Mode || (OrderStopLoss()!=OrderOpenPrice() && fabs(OrderStopLoss()-OrderOpenPrice()) > 130 * 
      MarketInfo(OrderSymbol(),MODE_TICKSIZE) && OrderType() == ! Bull && mOrdersTotal(OrderSymbol(), OrderStopLoss())))) {   // tst = true;
         tst = OrderSelect(ticket, SELECT_BY_TICKET);
         pos0 = PL0 < OrderProfit()? pos: pos0;          if (PL0 < OrderProfit()) PL0 = OrderProfit(); } }
  return(pos0); }

void BrokerDigitAdjust(string symbol) {
 int Multiplier = 1;
 if (MarketInfo(symbol,MODE_DIGITS) == 3 || MarketInfo(symbol,MODE_DIGITS) == 5) Multiplier = 10;
 if (MarketInfo(symbol,MODE_DIGITS) == 6) Multiplier = 100;   
 if (MarketInfo(symbol,MODE_DIGITS) == 7) Multiplier = 1000;
 pips2dbl = Multiplier*MarketInfo(symbol,MODE_POINT); }
#ifdef o_FH5 
/* ＭＯＯＮＢ Ξ ＲＧ |ᶜᵃᵖⁱᵗᵃˡ, [14/12/2021 15:46]
[In reply to ＭＯＯＮＢ Ξ ＲＧ |ᶜᵃᵖⁱᵗᵃˡ]
📍TP¹ ✅
+70 pips
+165 pips

ᴍᴏᴠᴇ sʟ ᴛᴏ ᴇɴᴛʀʏ
- - - - - - - - - - - - - - - - - - - - - - - - - - -
ＭＯＯＮＢ Ξ ＲＧ |ᶜᵃᵖⁱᵗᵃˡ, [15/12/2021 09:56]
[In reply to ＭＯＯＮＢ Ξ ＲＧ |ᶜᵃᵖⁱᵗᵃˡ]
in +80 pips profit✅
CLOSE HALF

ᴍᴏᴠᴇ sʟ ᴛᴏ ᴇɴᴛʀʏ
- - - - - - - - - - - - - - - - - - - - - - - - - - -
ＭＯＯＮＢ Ξ ＲＧ |ᶜᵃᵖⁱᵗᵃˡ, [15/12/2021 12:11]
[In reply to ＭＯＯＮＢ Ξ ＲＧ |ᶜᵃᵖⁱᵗᵃˡ]
Move SL To 1.97100
- - - - - - - - - - - - - - - - - - - - - - - - - - -
ＭＯＯＮＢ Ξ ＲＧ |ᶜᵃᵖⁱᵗᵃˡ, [15/12/2021 13:55]
[In reply to ＭＯＯＮＢ Ξ ＲＧ |ᶜᵃᵖⁱᵗᵃˡ]
ENTRY HIT❗️
- - - - - - - - - - - - - - - - - - - - - - - - - - -
ＭＯＯＮＢ Ξ ＲＧ |ᶜᵃᵖⁱᵗᵃˡ, [15/12/2021 13:56]
[In reply to ＭＯＯＮＢ Ξ ＲＧ |ᶜᵃᵖⁱᵗᵃˡ]
Delete buy limit order at 35440
- - - - - - - - - - - - - - - - - - - - - - - - - - -
ＭＯＯＮＢ Ξ ＲＧ |ᶜᵃᵖⁱᵗᵃˡ, [16/12/2021 07:38]
SELL  NASDAQ100  NOW AT 16385


📍TP¹  16320
📍TP²  16230
📍TP³  16120

⭕️STOP LOSS 16505✋

ᴍᴏᴠᴇ sʟ ᴛᴏ ᴇɴᴛʀʏ ᴀғᴛᴇʀ📍ᴛᴘ¹

ᴛʀᴀᴅᴇʀ: ᴛᴏᴍғᴏʀᴅᶠˣ
- - - - - - - - - - - - - - - - - - - - - - - - - - -
ＭＯＯＮＢ Ξ ＲＧ |ᶜᵃᵖⁱᵗᵃˡ, [14/12/2021 17:24]
BUY  US30  NOW AT 35560
Buy Again at 35440



📍TP¹  35660
📍TP²  35760
📍TP³  36000

⭕️STOP LOSS 35340✋

ᴍᴏᴠᴇ sʟ ᴛᴏ ᴇɴᴛʀʏ ᴀғᴛᴇʀ📍ᴛᴘ¹

ᴛʀᴀᴅᴇʀ: ᴛᴏᴍғᴏʀᴅᶠˣ
- - - - - - - - - - - - - - - - - - - - - - - - - - -
ＭＯＯＮＢ Ξ ＲＧ |ᶜᵃᵖⁱᵗᵃˡ, [06/12/2021 14:31]
BUY US30  NOW AT 34810
Again Buy at 34710



📍TP¹  34890
📍TP²  35000
📍TP³  35260

⭕️STOP LOSS 34610✋

ᴍᴏᴠᴇ sʟ ᴛᴏ ᴇɴᴛʀʏ ᴀғᴛᴇʀ📍ᴛᴘ¹

ᴛʀᴀᴅᴇʀ: ᴛᴏᴍғᴏʀᴅᶠˣ
- - - - - - - - - - - - - - - - - - - - - - - - - - -
ＭＯＯＮＢ Ξ ＲＧ |ᶜᵃᵖⁱᵗᵃˡ, [27/12/2021 12:05]
SELL  US30  NOW AT 35990
One more sell at 36070


📍TP¹  35920
📍TP²  35800
📍TP³  35710

⭕️STOP LOSS 36200✋

ᴍᴏᴠᴇ sʟ ᴛᴏ ᴇɴᴛʀʏ ᴀғᴛᴇʀ📍ᴛᴘ¹

ᴛʀᴀᴅᴇʀ: ᴛᴏᴍғᴏʀᴅᶠˣ
- - - - - - - - - - - - - - - - - - - - - - - - - - -
ＭＯＯＮＢ Ξ ＲＧ |ᶜᵃᵖⁱᵗᵃˡ, [16/12/2021 15:19]
[In reply to ＭＯＯＮＢ Ξ ＲＧ |ᶜᵃᵖⁱᵗᵃˡ]
📍TP¹ ✅

ᴍᴏᴠᴇ sʟ ᴛᴏ ᴇɴᴛʀʏ
- - - - - - - - - - - - - - - - - - - - - - - - - - -
ＭＯＯＮＢ Ξ ＲＧ |ᶜᵃᵖⁱᵗᵃˡ, [08/11/2021 14:51]
[In reply to ＭＯＯＮＢ Ξ ＲＧ |ᶜᵃᵖⁱᵗᵃˡ]
Correction:
set TP² at 65400
- - - - - - - - - - - - - - - - - - - - - - - - - - -
ＭＯＯＮＢ Ξ ＲＧ |ᶜᵃᵖⁱᵗᵃˡ, [22/11/2021 11:39]
[In reply to ＭＯＯＮＢ Ξ ＲＧ |ᶜᵃᵖⁱᵗᵃˡ]
Correction:
Modify SL To : 1.27030
- - - - - - - - - - - - - - - - - - - - - - - - - - -
ＭＯＯＮＢ Ξ ＲＧ |ᶜᵃᵖⁱᵗᵃˡ, [29/11/2021 08:21]
[In reply to ＭＯＯＮＢ Ξ ＲＧ |ᶜᵃᵖⁱᵗᵃˡ]
Correction:
STOP LOSS: 126.800
- - - - - - - - - - - - - - - - - - - - - - - - - - -
ＭＯＯＮＢ Ξ ＲＧ |ᶜᵃᵖⁱᵗᵃˡ, [16/12/2021 16:03]
[In reply to ＭＯＯＮＢ Ξ ＲＧ |ᶜᵃᵖⁱᵗᵃˡ]
+255 pips✅
CLOSE FULL
- - - - - - - - - - - - - - - - - - - - - - - - - - -
US30 FX Signals (VIP), [03/01/2022 16:17]
Buy Gold at 1800  */
int line_read_switch(int type,int row) { int ticket1, ticket2, cpt=0;      bool tst=false;      string temp;
      switch(type) {
         case 1  :
Alert("*****2-1* "+IntegerToString(row)+" - "+line_read[row][0]+" - "+line_read[row-2][1]+" - "+line_read[row-3][1]+" - "+line_read[row-4][2]+" - "+line_read[row-4][1]+" - "+line_read[row-4][0]+" *******");
            int nr=StringTrimRight(StringTrimLeft(line_read[row-11][2]))==""? line_read[row-12][0]=="Again" || line_read[row-12][1]=="Again"? 13: 12: line_read[row-11][0]=="Again" || line_read[row-11][1]=="Again"? 12:
               StringTrimRight(StringTrimLeft(line_read[row-10][2]))==""? line_read[row-11][0]=="Again" || line_read[row-11][1]=="Again"? 12: 11: line_read[row-10][0]=="Again" || line_read[row-10][1]=="Again"? 11: 10,
               nc=line_read[row-nr][3]=="AT"? 4: line_read[row-nr][4]=="AT"? 5: line_read[row-nr][5]=="AT"? 6: line_read[row-nr][6]=="AT"? 7: 3, t1, t2;
            double TP=line_read[row-6][1] != ""? StrToDouble(line_read[row-6][2]): StrToDouble(line_read[row-6][1]), 
               TP1=line_read[row-8][1] != ""? StrToDouble(line_read[row-8][2]): StrToDouble(line_read[row-8][1]), 
               TP2=line_read[row-7][1] != ""? StrToDouble(line_read[row-7][2]): StrToDouble(line_read[row-7][1]), TP3=TP,
               SL=line_read[row-4][0] == "."? StrToDouble(line_read[row-4][3]): StrToDouble(line_read[row-4][2]), LM=StrToDouble(line_read[row-nr][nc]);
            string Symb=line_read[row-nr][1] == "."? line_read[row-nr][2]: line_read[row-nr][1];            int icase=0;               Symb = Symb_Check(Symb, LM);
            temp = StringSubstr(line_read[row-nr-1][4],1,2)+StringSubstr(line_read[row-nr-1][5],0,2)+StringSubstr(line_read[row-nr-1][5],3,2);     // line_read[row-nr-1][0]=="ＭＯＯＮＢ" && line_read[row-nr-1][2]=="ＲＧ"? 
            if ((t1=StringFind(Op_Symbs,Symb))>0 && temp == (StringFind(Op_Symbs, "|", t1)? StringSubstr(Op_Symbs, (t2=StringFind(Op_Symbs, ":", t1))+1, StringFind(Op_Symbs, "|", t1)-t2-1):
            StringSubstr(Op_Symbs, (t2=StringFind(Op_Symbs, ":", t1)) + 1, StringLen(Op_Symbs) - t2 - 1))) return(0);
            bool Bull=line_read[row-nr][0] == "BUY" || line_read[row-nr][0] == "Buy" || line_read[row-nr][0] == "buy",
               t_adx=iCustom(Symb,PERIOD_M30,"New folder\\ADX.ex4",1,7)<47 && iCustom(Symb,PERIOD_M30,"New folder\\ADX.ex4",1,14)<40;
            TP = TP2 + (Bull? -1: 1) * MarketInfo(OrderSymbol(), MODE_SPREAD) * MarketInfo(OrderSymbol(), MODE_TICKSIZE) / 2;
Alert("*****2-1b* "+IntegerToString(row)+" - "+Symb+" - "+Bull+" - LM: " + DoubleToStr(Bull? MarketInfo(Symb,MODE_ASK)-LM: LM-MarketInfo(Symb,MODE_BID), MarketInfo(Symb, MODE_DIGITS)) +
   " - " + IntegerToString(tickt_b[0]) + " - " + IntegerToString(tickt_b[1]) + " - " + OrderSelect(tickt_b[0], SELECT_BY_TICKET) + " - " + temp + " - " + DoubleToStr(iCustom(Symb,PERIOD_M30,
   "New folder\\ADX.ex4", 1, 7), 2) + " - " + DoubleToStr(iCustom(Symb,PERIOD_M30,"New folder\\ADX.ex4", 1, 14), 2) + " - " + IntegerToString(t1) + " - " + IntegerToString(t2) + " *******");
//            if (SL <= 0.0 || TP <= 0.0 || TP1 <= 0.0 || TP2 <= 0.0 || LM <= 0.0) return(0);
            if ((Bull && SL > LM) || (! Bull && SL < LM)) Alert("*** ATTENTION ERREUR SL !! " + DoubleToStr(SL, MarketInfo(Symb, MODE_DIGITS)) + " / " + DoubleToStr(LM, MarketInfo(Symb, MODE_DIGITS)) + " ***");
            bool EA_n2_TP=! ((EA_TP_secure && (Symb == "XAUUSD" || Symb == "DJ30") && AccountBalance() < 200.0 * lot / 0.01) || EA_n_TP == 1);
            if (tickt_b[0] && OrderSelect(tickt_b[0], SELECT_BY_TICKET)) { tst = OrderModify(tickt_b[0], OrderOpenPrice(), SL, TP, 0, clrNONE);          tickt_b[0] = 0; }
            if (tickt_b[1] && OrderSelect(tickt_b[1], SELECT_BY_TICKET)) { tst = OrderModify(tickt_b[1], OrderOpenPrice(), SL, TP, 0, clrNONE);          tickt_b[1] = 0; }
            else { if (Bull && LM > 0.0 && MarketInfo(Symb,MODE_ASK) - LM >= (fabs(iClose(Symb,PERIOD_M5,1) - LM) < 700*MarketInfo(Symb,MODE_TICKSIZE)? 1: 2) * 75 * MarketInfo(Symb, MODE_TICKSIZE) && t_adx) {
               if ((t1=StringFind(Lm_Symbs, Symb)) > 0 && temp == (StringFind(Lm_Symbs, "|", t1)? StringSubstr(Lm_Symbs, (t2=StringFind(Lm_Symbs, ":", t1))+1, StringFind(Lm_Symbs, "|", t1)-t2-1):
               StringSubstr(Lm_Symbs, (t2=StringFind(Lm_Symbs, ":", t1)) + 1, StringLen(Lm_Symbs) - t2 - 1)) && temp != "") return(0);
               ticket1 = OrderSend(Symb, OP_BUYLIMIT, lot, LM, slip, SL, TP, "OP_BUYLIMIT", mgc_num, TimeCurrent() + (48 * 3600), clrNONE);//        if (AccountBalance() > 200.0 || Symb != "DJ30") 
               if (EA_n2_TP) ticket2 = OrderSend(Symb, OP_BUYLIMIT, lot, LM, slip, SL, TP, "OP_BUYLIMIT", mgc_num, TimeCurrent() + (48 * 3600), clrNONE);            icase = 1; }
             else  if (Bull) { icase = 2;       // && MarketInfo(Symb,MODE_ASK) - LM < 75 * MarketInfo(Symb, MODE_TICKSIZE)
               while((! ticket1 || ticket1 == -1) && cpt < 7) { if (ticket1) { Sleep(5 * PAUSE);         RefreshRates(); }
                  ticket1 = OrderSend(Symb, OP_BUY, lot, MarketInfo(Symb,MODE_ASK), slip,SL,TP,DoubleToStr(LM,MarketInfo(Symb, MODE_DIGITS))+" | OP_BUY", mgc_num, 0, clrNONE);        cpt ++; }
               if (EA_n2_TP) { ticket2 = 0;           while((! ticket2 || ticket2 == -1) && cpt < 7) { cpt ++;          // AccountBalance() > 200.0 || Symb != "DJ30"
                     if (ticket2) { Sleep(5 * PAUSE);          RefreshRates(); }
                     ticket2 = OrderSend(Symb, OP_BUY, lot, MarketInfo(Symb,MODE_ASK), slip, SL, TP, DoubleToStr(LM,MarketInfo(Symb, MODE_DIGITS))+" | OP_BUY", mgc_num, 0, clrNONE); } } }
             if (! Bull && LM - MarketInfo(Symb,MODE_BID) >= (fabs(iClose(Symb,PERIOD_M5,1) - LM) < 700*MarketInfo(Symb,MODE_TICKSIZE)? 1: 2) * 75 * MarketInfo(Symb, MODE_TICKSIZE) && t_adx) {
               if ((t1=StringFind(Lm_Symbs, Symb)) > 0 && temp == (StringFind(Lm_Symbs, "|", t1)? StringSubstr(Lm_Symbs, (t2=StringFind(Lm_Symbs, ":", t1))+1, StringFind(Lm_Symbs, "|", t1)-t2-1):
               StringSubstr(Lm_Symbs, (t2=StringFind(Lm_Symbs, ":", t1)) + 1, StringLen(Lm_Symbs) - t2 - 1)) && temp != "") return(0);
               ticket1 = OrderSend(Symb, OP_SELLLIMIT, lot, LM, slip, SL, TP, "OP_SELLLIMIT", mgc_num, TimeCurrent() + (48 * 3600), clrNONE);//      if (AccountBalance() > 200.0 || Symb != "DJ30") 
               if (EA_n2_TP) ticket2 = OrderSend(Symb, OP_SELLLIMIT, lot, LM, slip, SL, TP, "OP_SELLLIMIT", mgc_num, TimeCurrent() + (48 * 3600), clrNONE);          icase = 3; }
             else  if (! Bull) { icase = 4;      // && LM - MarketInfo(Symb,MODE_BID) < 75 * MarketInfo(Symb, MODE_TICKSIZE)
               while((! ticket1 || ticket1 == -1) && cpt < 7) { if (ticket1) { Sleep(5 * PAUSE);         RefreshRates(); }
                  ticket1 = OrderSend(Symb, OP_SELL, lot, MarketInfo(Symb,MODE_BID), slip,SL,TP,DoubleToStr(LM,MarketInfo(Symb, MODE_DIGITS))+" | OP_SELL", mgc_num, 0, clrNONE);      cpt ++; }
               if (EA_n2_TP) { ticket2 = 0;           while((! ticket2 || ticket2 == -1) && cpt < 7) { cpt ++;          // AccountBalance() > 200.0 || Symb != "DJ30"
                     if (ticket2) { Sleep(5 * PAUSE);          RefreshRates(); }
                     ticket2 = OrderSend(Symb, OP_SELL, lot, MarketInfo(Symb,MODE_BID), slip, SL, TP, DoubleToStr(LM,MarketInfo(Symb, MODE_DIGITS))+" | OP_SELL", mgc_num, 0, clrNONE); } } } }
            if (TP1 > 0.0 && TP2 > 0.0) { if (ticket1) {
               GlobalVariableSet(Symb + StringSubstr(IntegerToString(ticket1), StringLen(IntegerToString(ticket1)) - 4) + "_TP1", TP1);
               GlobalVariableSet(Symb + StringSubstr(IntegerToString(ticket1), StringLen(IntegerToString(ticket1)) - 4) + "_TP2", TP2);
               GlobalVariableSet(Symb + StringSubstr(IntegerToString(ticket1), StringLen(IntegerToString(ticket1)) - 4) + "_TP3", TP3); }
               if (ticket2) { GlobalVariableSet(Symb + StringSubstr(IntegerToString(ticket2), StringLen(IntegerToString(ticket2)) - 4) + "_TP1", TP1);
               GlobalVariableSet(Symb + StringSubstr(IntegerToString(ticket2), StringLen(IntegerToString(ticket2)) - 4) + "_TP2", TP2);
               GlobalVariableSet(Symb + StringSubstr(IntegerToString(ticket2), StringLen(IntegerToString(ticket2)) - 4) + "_TP3", TP3); } }
            if (ticket1 > 0) if (! (icase % 2) || tst) Op_Symbs += "|" + Symb + ":" + temp;        else Lm_Symbs += "|" + Symb + ":" + temp;       if (tst) ticket1 = tst;
         break;
         case 2  :
Alert("*****2-2* "+IntegerToString(row)+" - "+line_read[row][0]+" - "+line_read[row-2][1]+" - "+line_read[row-3][1]+" - "+line_read[row-4][2]+" - "+line_read[row-4][1]+" - "+line_read[row-4][0]+
   (tickt_b[0] ? " - " + IntegerToString(tickt_b[0]) + " - " + IntegerToString(tickt_b[1]) : "") + " *******");
            if (StringFind(line_read[row][3], "/") > 3) line_read[row][3] = StringSubstr(line_read[row][3], 0, StringFind(line_read[row][3], "/"));
            LM = StrToDouble(line_read[row][3]);         Symb = line_read[row][1];        ticket1 = 0;      ticket2 = 0;      icase = 0;
            Bull = line_read[row][0] == "BUY" || line_read[row][0] == "Buy" || line_read[row][0] == "buy";              Symb = Symb_Check(Symb, LM);
            if (tickt_b[0] || StringFind(Op_Symb2s, Symb + ":" + DoubleToStr(LM, MarketInfo(Symb, MODE_DIGITS)))) { slip = 5;    return(0); }
            temp = StringSubstr(line_read[row-1][3], 1, 2) + StringSubstr(line_read[row-1][4], 0, 2) + StringSubstr(line_read[row-1][4], 3, 2);
            if ((t1=StringFind(Op_Symbs,Symb))>0 && temp == (StringFind(Op_Symbs, "|", t1)? StringSubstr(Op_Symbs, (t2=StringFind(Op_Symbs, ":", t1))+1, StringFind(Op_Symbs, "|", t1)-t2-1):
            StringSubstr(Op_Symbs, (t2=StringFind(Op_Symbs, ":", t1)) + 1, StringLen(Op_Symbs) - t2 - 1))) return(0);
            t_adx = iCustom(Symb, PERIOD_M30, "New folder\\ADX.ex4", 1, 7) < 47 && iCustom(Symb, PERIOD_M30, "New folder\\ADX.ex4", 1, 14) < 40;
Alert("*****2-2b* "+IntegerToString(row)+" - "+Symb+" - "+Bull+" - LM: " + DoubleToStr(Bull? MarketInfo(Symb,MODE_ASK)-LM: LM-MarketInfo(Symb,MODE_BID), MarketInfo(Symb, MODE_DIGITS)) +
   " - " + IntegerToString(tickt_b[0]) + " - " + IntegerToString(tickt_b[1]) + " - " + OrderSelect(tickt_b[0], SELECT_BY_TICKET) + " - " + temp + " - " + DoubleToStr(iCustom(Symb,PERIOD_M30,
   "New folder\\ADX.ex4", 1, 7), 2) + " - " + DoubleToStr(iCustom(Symb,PERIOD_M30,"New folder\\ADX.ex4", 1, 14), 2) + " *******");           int n_tcks=Symb=="XAUUSD"+_p? 150: 75;      // pour case 2 uniquement
            EA_n2_TP = ! ((EA_TP_secure && (Symb == "XAUUSD" || Symb == "DJ30") && AccountBalance() < 200.0 * lot / 0.01) || EA_n_TP == 1);
            if (Bull && LM > 0.0 && MarketInfo(Symb,MODE_ASK) - LM >= n_tcks * MarketInfo(Symb, MODE_TICKSIZE) && t_adx) {
               if ((t1=StringFind(Lm_Symbs, Symb)) > 0 && temp == (StringFind(Lm_Symbs, "|", t1)? StringSubstr(Lm_Symbs, (t2=StringFind(Lm_Symbs, ":", t1))+1, StringFind(Lm_Symbs, "|", t1)-t2-1):
               StringSubstr(Lm_Symbs, (t2=StringFind(Lm_Symbs, ":", t1)) + 1, StringLen(Lm_Symbs) - t2 - 1)) && temp != "") return(0);
               ticket1 = OrderSend(Symb, OP_BUYLIMIT, lot, LM, slip, 0.0, 0.0, "OP_BUYLIMIT", mgc_num, TimeCurrent() + (48 * 3600), clrNONE);
               if (EA_n2_TP) ticket2 = OrderSend(Symb, OP_BUYLIMIT, lot, LM, slip, 0.0, 0.0, "OP_BUYLIMIT", mgc_num, TimeCurrent() + (48 * 3600), clrNONE);       icase = 1; }
            else  if (Bull) { icase = 2;        // && MarketInfo(Symb,MODE_ASK) - LM < 75 * MarketInfo(Symb, MODE_TICKSIZE)
               while((! ticket1 || ticket1 == -1) && cpt < 7) { if (ticket1) { Sleep(5 * PAUSE);         RefreshRates(); }
                  ticket1 = OrderSend(Symb, OP_BUY, lot, MarketInfo(Symb,MODE_ASK), slip,0.0,0.0,DoubleToStr(LM,MarketInfo(Symb, MODE_DIGITS))+" | OP_BUY", mgc_num, 0, clrNONE);      cpt ++; }
               if (EA_n2_TP) { ticket2 = 0;           while((! ticket2 || ticket2 == -1) && cpt < 7) { cpt ++;
                  if (ticket2) { Sleep(5 * PAUSE);          RefreshRates(); }
                  ticket2 = OrderSend(Symb, OP_BUY, lot, MarketInfo(Symb,MODE_ASK), slip, 0.0, 0.0, DoubleToStr(LM,MarketInfo(Symb, MODE_DIGITS))+" | OP_BUY", mgc_num, 0, clrNONE); } } }
            if (! Bull && LM - MarketInfo(Symb,MODE_BID) >= n_tcks * MarketInfo(Symb, MODE_TICKSIZE) && t_adx) {
               if ((t1=StringFind(Lm_Symbs, Symb)) > 0 && temp == (StringFind(Lm_Symbs, "|", t1)? StringSubstr(Lm_Symbs, (t2=StringFind(Lm_Symbs, ":", t1))+1, StringFind(Lm_Symbs, "|", t1)-t2-1):
               StringSubstr(Lm_Symbs, (t2=StringFind(Lm_Symbs, ":", t1)) + 1, StringLen(Lm_Symbs) - t2 - 1)) && temp != "") return(0);
               ticket1 = OrderSend(Symb, OP_SELLLIMIT, lot, LM, slip, 0.0, 0.0, "OP_SELLLIMIT", mgc_num, TimeCurrent() + (48 * 3600), clrNONE);
               if (EA_n2_TP) ticket2 = OrderSend(Symb, OP_SELLLIMIT, lot, LM, slip, 0.0, 0.0, "OP_SELLLIMIT", mgc_num, TimeCurrent() + (48 * 3600), clrNONE);     icase = 3; }
            else  if (! Bull) { icase = 4;      // && LM - MarketInfo(Symb,MODE_BID) < 75 * MarketInfo(Symb, MODE_TICKSIZE)
               while((! ticket1 || ticket1 == -1) && cpt < 7) { if (ticket1) { Sleep(5 * PAUSE);         RefreshRates(); }
                  ticket1 = OrderSend(Symb, OP_SELL, lot, MarketInfo(Symb,MODE_BID), slip,0.0,0.0,DoubleToStr(LM,MarketInfo(Symb, MODE_DIGITS))+" | OP_SELL", mgc_num, 0, clrNONE);    cpt ++; }
               if (EA_n2_TP) { ticket2 = 0;           while((! ticket2 || ticket2 == -1) && cpt < 7) { cpt ++;
                  if (ticket2) { Sleep(5 * PAUSE);          RefreshRates(); }
                  ticket2 = OrderSend(Symb, OP_SELL, lot, MarketInfo(Symb,MODE_BID), slip, 0.0, 0.0, DoubleToStr(LM,MarketInfo(Symb, MODE_DIGITS))+" | OP_SELL", mgc_num, 0, clrNONE); } } }
            if (ticket1 > 0) { if (! (icase % 2)) Op_Symbs += "|" + Symb + ":" + temp;         else Lm_Symbs += "|" + Symb + ":" + temp;
               if (! (icase % 2)) Op_Symb2s += "|" + Symb + ":" + DoubleToStr(LM, MarketInfo(Symb, MODE_DIGITS)); }
         break;
         case 3  :
Alert("*****2-3* "+IntegerToString(row)+" - "+line_read[row][0]+" - "+line_read[row][1]+" - "+line_read[row-1][1]+" - "+line_read[row-2][2]+" - "+line_read[row-2][1]+" - "+line_read[row-2][0]+" *******");
            nc = line_read[row][3]=="AT"? 4: line_read[row][4]=="AT"? 5: line_read[row][5]=="AT"? 6: line_read[row][6]=="AT"? 7: 3;
            TP = line_read[row+6][1] != ""? StrToDouble(line_read[row+6][2]): StrToDouble(line_read[row+6][1]);   TP3 = TP;
            TP1 = line_read[row+4][1] != ""? StrToDouble(line_read[row+4][2]): StrToDouble(line_read[row+4][1]);
            TP2 = line_read[row+5][1] != ""? StrToDouble(line_read[row+5][2]): StrToDouble(line_read[row+5][1]);
            SL = line_read[row+11][0] == "."? StrToDouble(line_read[row+11][3]): StrToDouble(line_read[row+11][2]);
//            if (StringFind(line_read[row][5], "/") > 3) line_read[row][5] = StringSubstr(line_read[row][5], 0, StringFind(line_read[row][5], "/"));
            LM = StrToDouble(line_read[row][nc]);        Symb = line_read[row][2];     ticket1 = 0;      ticket2 = 0;      icase = 0;     Symb = Symb_Check(Symb, LM);
            Bull = line_read[row][0]=="BUY" || line_read[row][1]=="BUY" || line_read[row][0]=="Buy" || line_read[row][1]=="Buy" || line_read[row][0]=="buy" || line_read[row][1]=="buy";
            TP = TP2 + (Bull? -1: 1) * MarketInfo(OrderSymbol(), MODE_SPREAD) * MarketInfo(OrderSymbol(), MODE_TICKSIZE) / 2;
            temp = line_read[row-2][0]=="Professor" && line_read[row-2][2]=="(yearly),"? StringSubstr(line_read[row-2][3],1,2)+StringSubstr(line_read[row-2][4],0,2)+StringSubstr(line_read[row-2][4],3,2):
               StringSubstr(line_read[row-1][3], 1, 2) + StringSubstr(line_read[row-1][4], 0, 2) + StringSubstr(line_read[row-1][4], 3, 2);
            if ((t1=StringFind(Op_Symbs,Symb))>0 && temp == (StringFind(Op_Symbs, "|", t1)? StringSubstr(Op_Symbs, (t2=StringFind(Op_Symbs, ":", t1))+1, StringFind(Op_Symbs, "|", t1)-t2-1):
            StringSubstr(Op_Symbs, (t2=StringFind(Op_Symbs, ":", t1)) + 1, StringLen(Op_Symbs) - t2 - 1))) return(0);
            t_adx = iCustom(Symb, PERIOD_M30, "New folder\\ADX.ex4", 1, 7) < 47 && iCustom(Symb, PERIOD_M30, "New folder\\ADX.ex4", 1, 14) < 40;
Alert("*****2-3b* "+IntegerToString(row)+" - "+Symb+" - "+Bull+" - LM: " + DoubleToStr(Bull? MarketInfo(Symb,MODE_ASK)-LM: LM-MarketInfo(Symb,MODE_BID), MarketInfo(Symb, MODE_DIGITS)) +
   " - " + IntegerToString(tickt_b[0]) + " - " + IntegerToString(tickt_b[1]) + " - " + OrderSelect(tickt_b[0], SELECT_BY_TICKET) + " - " + temp + " - " + DoubleToStr(iCustom(Symb,PERIOD_M30,
   "New folder\\ADX.ex4", 1, 7), 2) + " - " + DoubleToStr(iCustom(Symb,PERIOD_M30,"New folder\\ADX.ex4", 1, 14), 2) + " *******");
            if ((Bull && SL > LM) || (! Bull && SL < LM)) Alert("*** ATTENTION ERREUR SL !! " + DoubleToStr(SL, MarketInfo(Symb, MODE_DIGITS)) + " / " + DoubleToStr(LM, MarketInfo(Symb, MODE_DIGITS)) + " ***");
            EA_n2_TP = ! ((EA_TP_secure && (Symb == "XAUUSD" || Symb == "DJ30") && AccountBalance() < 200.0 * lot / 0.01) || EA_n_TP == 1);
//            if (tickt_b[0] && OrderSelect(tickt_b[0], SELECT_BY_TICKET)) { tst = OrderModify(tickt_b[0], OrderOpenPrice(), SL, TP, 0, clrNONE);          tickt_b[0] = 0; }
//            if (tickt_b[1] && OrderSelect(tickt_b[1], SELECT_BY_TICKET)) { tst = OrderModify(tickt_b[1], OrderOpenPrice(), SL, TP, 0, clrNONE);          tickt_b[1] = 0; }
            if (Bull && LM > 0.0 && ((MarketInfo(Symb,MODE_ASK) - LM >= 75 * MarketInfo(Symb, MODE_TICKSIZE) && t_adx) || line_read[row-1][0] != "Professor")) {        // else { 
               if ((t1=StringFind(Lm_Symbs, Symb)) > 0 && temp == (StringFind(Lm_Symbs, "|", t1)? StringSubstr(Lm_Symbs, (t2=StringFind(Lm_Symbs, ":", t1))+1, StringFind(Lm_Symbs, "|", t1)-t2-1):
               StringSubstr(Lm_Symbs, (t2=StringFind(Lm_Symbs, ":", t1)) + 1, StringLen(Lm_Symbs) - t2 - 1)) && temp != "") return(0);
               ticket1 = OrderSend(Symb, OP_BUYLIMIT, lot, LM, slip, SL, TP, "OP_BUYLIMIT", mgc_num, TimeCurrent() + (48 * 3600), clrNONE);
               if (EA_n2_TP) ticket2 = OrderSend(Symb, OP_BUYLIMIT, lot, LM, slip, SL, TP, "OP_BUYLIMIT", mgc_num, TimeCurrent() + (48 * 3600), clrNONE);         icase = 1; }
            else  if (Bull) { icase = 2;       // && MarketInfo(Symb,MODE_ASK) - LM < 75 * MarketInfo(Symb, MODE_TICKSIZE)
               while((! ticket1 || ticket1 == -1) && cpt < 7) { if (ticket1) { Sleep(5 * PAUSE);         RefreshRates(); }
                  ticket1 = OrderSend(Symb, OP_BUY, lot, MarketInfo(Symb,MODE_ASK), slip,SL,TP,DoubleToStr(LM,MarketInfo(Symb, MODE_DIGITS))+" | OP_BUY", mgc_num, 0, clrNONE);     cpt ++; }
               if (EA_n2_TP) { ticket2 = 0;           while((! ticket2 || ticket2 == -1) && cpt < 7) { cpt ++;
                  if (ticket2) { Sleep(5 * PAUSE);          RefreshRates(); }
                  ticket2 = OrderSend(Symb, OP_BUY, lot, MarketInfo(Symb,MODE_ASK), slip, SL, TP, DoubleToStr(LM,MarketInfo(Symb, MODE_DIGITS))+" | OP_BUY", mgc_num, 0, clrNONE); } } }
            if (! Bull && ((LM - MarketInfo(Symb,MODE_BID) >= 75 * MarketInfo(Symb, MODE_TICKSIZE) && t_adx) || line_read[row-1][0] != "Professor")) {
               if ((t1=StringFind(Lm_Symbs, Symb)) > 0 && temp == (StringFind(Lm_Symbs, "|", t1)? StringSubstr(Lm_Symbs, (t2=StringFind(Lm_Symbs, ":", t1))+1, StringFind(Lm_Symbs, "|", t1)-t2-1):
               StringSubstr(Lm_Symbs, (t2=StringFind(Lm_Symbs, ":", t1)) + 1, StringLen(Lm_Symbs) - t2 - 1)) && temp != "") return(0);
               ticket1 = OrderSend(Symb, OP_SELLLIMIT, lot, LM, slip, SL, TP, "OP_SELLLIMIT", mgc_num, TimeCurrent() + (48 * 3600), clrNONE);
               if (EA_n2_TP) ticket2 = OrderSend(Symb, OP_SELLLIMIT, lot, LM, slip, SL, TP, "OP_SELLLIMIT", mgc_num, TimeCurrent() + (48 * 3600), clrNONE);       icase = 3; }
            else  if (! Bull) { icase = 4;     // && LM - MarketInfo(Symb,MODE_BID) < 75 * MarketInfo(Symb, MODE_TICKSIZE)
               while((! ticket1 || ticket1 == -1) && cpt < 7) { if (ticket1) { Sleep(5 * PAUSE);         RefreshRates(); }
                  ticket1 = OrderSend(Symb, OP_SELL, lot, MarketInfo(Symb,MODE_BID), slip,SL,TP,DoubleToStr(LM,MarketInfo(Symb, MODE_DIGITS))+" | OP_SELL", mgc_num, 0, clrNONE);      cpt ++; }
               if (EA_n2_TP) { ticket2 = 0;           while((! ticket2 || ticket2 == -1) && cpt < 7) { cpt ++;
                  if (ticket2) { Sleep(5 * PAUSE);          RefreshRates(); }
                  ticket2 = OrderSend(Symb, OP_SELL, lot, MarketInfo(Symb,MODE_BID), slip, SL, TP, DoubleToStr(LM,MarketInfo(Symb, MODE_DIGITS))+" | OP_SELL", mgc_num, 0, clrNONE); } } } //}
            if (TP1 > 0.0 && TP2 > 0.0) { if (ticket1) {
               GlobalVariableSet(Symb + StringSubstr(IntegerToString(ticket1), StringLen(IntegerToString(ticket1)) - 4) + "_TP1", TP1);
               GlobalVariableSet(Symb + StringSubstr(IntegerToString(ticket1), StringLen(IntegerToString(ticket1)) - 4) + "_TP2", TP2);
               GlobalVariableSet(Symb + StringSubstr(IntegerToString(ticket1), StringLen(IntegerToString(ticket1)) - 4) + "_TP3", TP3); }
               if (ticket2) { GlobalVariableSet(Symb + StringSubstr(IntegerToString(ticket2), StringLen(IntegerToString(ticket2)) - 4) + "_TP1", TP1);
               GlobalVariableSet(Symb + StringSubstr(IntegerToString(ticket2), StringLen(IntegerToString(ticket2)) - 4) + "_TP2", TP2);
               GlobalVariableSet(Symb + StringSubstr(IntegerToString(ticket2), StringLen(IntegerToString(ticket2)) - 4) + "_TP3", TP3); } }
            if (ticket1 > 0) if (! (icase % 2)) Op_Symbs += "|" + Symb + ":" + temp;         else Lm_Symbs += "|" + Symb + ":" + temp;
            if (line_read[row-1][0] != "Professor") { LM = StrToDouble(line_read[row-1][nc]);         ticket1 = 0;      ticket2 = 0;      icase = 0;
Alert("*****2-3c* "+IntegerToString(row)+" - "+Symb+" - "+Bull+" - LM: " + DoubleToStr(Bull? MarketInfo(Symb,MODE_ASK)-LM: LM-MarketInfo(Symb,MODE_BID), MarketInfo(Symb, MODE_DIGITS)) +
   " - " + IntegerToString(tickt_b[0]) + " - " + IntegerToString(tickt_b[1]) + " - " + OrderSelect(tickt_b[0], SELECT_BY_TICKET) + " - " + temp + " - " + DoubleToStr(iCustom(Symb,PERIOD_M30,
   "New folder\\ADX.ex4", 1, 7), 2) + " - " + DoubleToStr(iCustom(Symb,PERIOD_M30,"New folder\\ADX.ex4", 1, 14), 2) + " *******");
               if (Bull && LM > 0.0 && MarketInfo(Symb,MODE_ASK) - LM >= 75 * MarketInfo(Symb, MODE_TICKSIZE) && t_adx) {
                  if ((t1=StringFind(Lm_Symbs, Symb)) > 0 && temp == (StringFind(Lm_Symbs, "|", t1)? StringSubstr(Lm_Symbs, (t2=StringFind(Lm_Symbs, ":", t1))+1, StringFind(Lm_Symbs, "|", t1)-t2-1):
                  StringSubstr(Lm_Symbs, (t2=StringFind(Lm_Symbs, ":", t1)) + 1, StringLen(Lm_Symbs) - t2 - 1)) && temp != "") return(0);
                  ticket1 = OrderSend(Symb, OP_BUYLIMIT, lot, LM, slip, SL, TP, "OP_BUYLIMIT", mgc_num, TimeCurrent() + (48 * 3600), clrNONE);
                  if (EA_n2_TP) ticket2 = OrderSend(Symb, OP_BUYLIMIT, lot, LM, slip, SL, TP, "OP_BUYLIMIT", mgc_num, TimeCurrent() + (48 * 3600), clrNONE);         icase = 1; }
               else  if (Bull) { icase = 2;        // && MarketInfo(Symb,MODE_ASK) - LM < 75 * MarketInfo(Symb, MODE_TICKSIZE)
                  while((! ticket1 || ticket1 == -1) && cpt < 7) { if (ticket1) { Sleep(5 * PAUSE);         RefreshRates(); }
                     ticket1 = OrderSend(Symb, OP_BUY, lot, MarketInfo(Symb,MODE_ASK), slip,SL,TP,DoubleToStr(LM,MarketInfo(Symb, MODE_DIGITS))+" | OP_BUY", mgc_num, 0, clrNONE);     cpt ++; }
                  if (EA_n2_TP) { ticket2 = 0;         while((! ticket2 || ticket2 == -1) && cpt < 7) { cpt ++;
                     if (ticket2) { Sleep(5 * PAUSE);          RefreshRates(); }
                     ticket2 = OrderSend(Symb, OP_BUY, lot, MarketInfo(Symb,MODE_ASK), slip, SL, TP, DoubleToStr(LM,MarketInfo(Symb, MODE_DIGITS))+" | OP_BUY", mgc_num, 0, clrNONE); } } }
               if (! Bull && LM - MarketInfo(Symb,MODE_BID) >= 75 * MarketInfo(Symb, MODE_TICKSIZE) && t_adx) {
                  if ((t1=StringFind(Lm_Symbs, Symb)) > 0 && temp == (StringFind(Lm_Symbs, "|", t1)? StringSubstr(Lm_Symbs, (t2=StringFind(Lm_Symbs, ":", t1))+1, StringFind(Lm_Symbs, "|", t1)-t2-1):
                  StringSubstr(Lm_Symbs, (t2=StringFind(Lm_Symbs, ":", t1)) + 1, StringLen(Lm_Symbs) - t2 - 1)) && temp != "") return(0);
                  ticket1 = OrderSend(Symb, OP_SELLLIMIT, lot, LM, slip, SL, TP, "OP_SELLLIMIT", mgc_num, TimeCurrent() + (48 * 3600), clrNONE);
                  if (EA_n2_TP) ticket2 = OrderSend(Symb, OP_SELLLIMIT, lot, LM, slip, SL, TP, "OP_SELLLIMIT", mgc_num, TimeCurrent() + (48 * 3600), clrNONE);       icase = 3; }
               else  if (! Bull) { icase = 4;      // && LM - MarketInfo(Symb,MODE_BID) < 75 * MarketInfo(Symb, MODE_TICKSIZE)
                  while((! ticket1 || ticket1 == -1) && cpt < 7) { if (ticket1) { Sleep(5 * PAUSE);         RefreshRates(); }
                     ticket1 = OrderSend(Symb, OP_SELL, lot, MarketInfo(Symb,MODE_BID), slip,SL,TP,DoubleToStr(LM,MarketInfo(Symb, MODE_DIGITS))+" | OP_SELL", mgc_num, 0, clrNONE);   cpt ++; }
                  if (EA_n2_TP) { ticket2 = 0;         while((! ticket2 || ticket2 == -1) && cpt < 7) { cpt ++;
                     if (ticket2) { Sleep(5 * PAUSE);          RefreshRates(); }
                     ticket2 = OrderSend(Symb, OP_SELL, lot, MarketInfo(Symb,MODE_BID), slip, SL, TP, DoubleToStr(LM,MarketInfo(Symb, MODE_DIGITS))+" | OP_SELL", mgc_num, 0, clrNONE); } } }
               if (TP1 > 0.0 && TP2 > 0.0) { if (ticket1) {
                  GlobalVariableSet(Symb + StringSubstr(IntegerToString(ticket1), StringLen(IntegerToString(ticket1)) - 4) + "_TP1", TP1);
                  GlobalVariableSet(Symb + StringSubstr(IntegerToString(ticket1), StringLen(IntegerToString(ticket1)) - 4) + "_TP2", TP2);
                  GlobalVariableSet(Symb + StringSubstr(IntegerToString(ticket1), StringLen(IntegerToString(ticket1)) - 4) + "_TP3", TP3); }
                  if (ticket2) { GlobalVariableSet(Symb + StringSubstr(IntegerToString(ticket2), StringLen(IntegerToString(ticket2)) - 4) + "_TP1", TP1);
                  GlobalVariableSet(Symb + StringSubstr(IntegerToString(ticket2), StringLen(IntegerToString(ticket2)) - 4) + "_TP2", TP2);
                  GlobalVariableSet(Symb + StringSubstr(IntegerToString(ticket2), StringLen(IntegerToString(ticket2)) - 4) + "_TP3", TP3); } }
               if (ticket1 > 0) if (! (icase % 2)) Op_Symbs += "|" + Symb + ":" + temp;         else Lm_Symbs += "|" + Symb + ":" + temp; }
         break;
         case 4  :
Alert("*****2-4* "+IntegerToString(row)+" - "+line_read[row][0]+" - "+line_read[row][1]+" - "+line_read[row-1][1]+" - "+line_read[row-2][2]+" - "+line_read[row-2][1]+" - "+line_read[row-2][0]+" *******");
/*            nc = (line_read[row][1]=="Again" || line_read[row][1]=="again" || (line_read[row][0]=="One" && line_read[row][1]=="More") || (line_read[row][0]=="one" && line_read[row][1]=="more")) &&
               line_read[row-1][0] != "Professor"? line_read[row-1][3]=="AT"? 4: line_read[row-1][4]=="AT"? 5: line_read[row-1][5]=="AT"? 6: line_read[row-1][6]=="AT"? 7: 3: line_read[row][3]=="AT"? 4:
               line_read[row][4]=="AT"? 5: line_read[row][5]=="AT"? 6: line_read[row][6]=="AT"? 7: 3;       TP = line_read[row+6][1] != ""? StrToDouble(line_read[row+6][2]): StrToDouble(line_read[row+6][1]);
            TP1 = line_read[row+4][1] != ""? StrToDouble(line_read[row+4][2]): StrToDouble(line_read[row+4][1]);                    double LM2;
            TP2 = line_read[row+5][1] != ""? StrToDouble(line_read[row+5][2]): StrToDouble(line_read[row+5][1]);
            SL = line_read[row+11][0] == "."? StrToDouble(line_read[row+11][3]): StrToDouble(line_read[row+11][2]);
            Bull = line_read[row][0]=="BUY" || line_read[row][0]=="Buy" || line_read[row][0]=="buy";
            Symb = line_read[row][2];           Symb = Symb_Check(Symb, LM);        ticket = 0;             icase = 0;
            if (StringFind(line_read[row-1][nc], "/") > 3) { temp = StringSubstr(line_read[row-1][nc], 0, StringFind(line_read[row-1][nc], "/"));
               line_read[row-1][nc] = (StrToDouble(temp) > (LM2=StrToDouble(StringSubstr(line_read[row-1][nc], StringFind(line_read[row-1][nc],"/")+1))) && Bull) ||
                  (StrToDouble(temp) < StrToDouble(StringSubstr(line_read[row-1][nc], StringFind(line_read[row-1][nc], "/") + 1)) && line_read[row][0] == "SELL")?
                  temp: StringSubstr(line_read[row-1][nc], StringFind(line_read[row-1][nc], "/") + 1); }
            else if (StringFind(line_read[row][nc], "/") > 3) { temp = StringSubstr(line_read[row][nc], 0, StringFind(line_read[row][nc], "/"));
               line_read[row][nc] = (StrToDouble(temp) > (LM2=StrToDouble(StringSubstr(line_read[row][nc], StringFind(line_read[row][nc], "/") + 1))) && Bull) ||
                  (StrToDouble(temp) < StrToDouble(StringSubstr(line_read[row][nc], StringFind(line_read[row][nc], "/") + 1)) && line_read[row][0] == "SELL")?
                  temp: StringSubstr(line_read[row][nc], StringFind(line_read[row][nc], "/") + 1); }                             else LM2 = 0.0;
            LM = (line_read[row][1]=="Again" || line_read[row][1]=="again") && line_read[row-1][0] != "Professor"? StrToDouble(line_read[row-1][nc]): StrToDouble(line_read[row][nc]);
            TP = TP2 + (Bull? -1: 1) * MarketInfo(OrderSymbol(), MODE_SPREAD) * MarketInfo(OrderSymbol(), MODE_TICKSIZE) / 2;
            temp = line_read[row-2][0]=="Professor" && line_read[row-2][2]=="(yearly),"? StringSubstr(line_read[row-2][3],1,2)+StringSubstr(line_read[row-2][4],0,2)+StringSubstr(line_read[row-2][4],3,2):
               StringSubstr(line_read[row-1][3], 1, 2) + StringSubstr(line_read[row-1][4], 0, 2) + StringSubstr(line_read[row-1][4], 3, 2);
            if ((t1=StringFind(Lm_Symbs, Symb)) > 0 && temp == (StringFind(Lm_Symbs, "|", t1)? StringSubstr(Lm_Symbs, (t2=StringFind(Lm_Symbs, ":", t1))+1, StringFind(Lm_Symbs, "|", t1)-t2-1):
            StringSubstr(Lm_Symbs, (t2=StringFind(Lm_Symbs, ":", t1)) + 1, StringLen(Lm_Symbs) - t2 - 1)) && temp != "") return(0);
Alert("*****2-4b* "+IntegerToString(row)+" - "+Symb+" - "+Bull+" - "+DoubleToStr(TP, MarketInfo(Symb, MODE_DIGITS))+" - "+DoubleToStr(SL, MarketInfo(Symb, MODE_DIGITS))+" - "+
   DoubleToStr(LM, MarketInfo(Symb, MODE_DIGITS))+" - "+IntegerToString(tickt_b[0])+" - "+IntegerToString(tickt_b[1])+" - "+OrderSelect(tickt_b[0], SELECT_BY_TICKET)+" - "+temp+" *******");
            if (Bull) { ticket = OrderSend(Symb, OP_BUYLIMIT, lot, LM, slip, SL, TP, "OP_BUYLIMIT", mgc_num, TimeCurrent() + (48 * 3600), clrNONE);
               ticket = OrderSend(Symb, OP_BUYLIMIT, lot, LM, slip, SL, TP, "OP_BUYLIMIT", mgc_num, TimeCurrent() + (48 * 3600), clrNONE);      icase = 1; }
            else { ticket = OrderSend(Symb, OP_SELLLIMIT, lot, LM, slip, SL, TP, "OP_SELLLIMIT", mgc_num, TimeCurrent() + (48 * 3600), clrNONE);
               ticket = OrderSend(Symb, OP_SELLLIMIT, lot, LM, slip, SL, TP, "OP_SELLLIMIT", mgc_num, TimeCurrent() + (48 * 3600), clrNONE);    icase = 3; }
            if (LM2 > 0.0) if (Bull) { ticket = OrderSend(Symb, OP_BUYLIMIT, lot, LM2, slip, SL, TP, "OP_BUYLIMIT", mgc_num, TimeCurrent() + (48 * 3600), clrNONE);
                  ticket = OrderSend(Symb, OP_BUYLIMIT, lot, LM, slip, SL, TP, "OP_BUYLIMIT", mgc_num, TimeCurrent() + (48 * 3600), clrNONE);      icase = 1; }
               else { ticket = OrderSend(Symb, OP_SELLLIMIT, lot, LM2, slip, SL, TP, "OP_SELLLIMIT", mgc_num, TimeCurrent() + (48 * 3600), clrNONE);
                  ticket = OrderSend(Symb, OP_SELLLIMIT, lot, LM, slip, SL, TP, "OP_SELLLIMIT", mgc_num, TimeCurrent() + (48 * 3600), clrNONE);    icase = 3; }
            if (ticket > 0) Lm_Symbs += "|" + Symb + ":" + temp; */
         break;
         case 5  :
Alert("*****2-5* "+IntegerToString(row)+" - "+line_read[row][0]+" - "+line_read[row-2][1]+" - "+line_read[row-3][1]+" - "+line_read[row-4][2]+" - "+line_read[row-4][1]+" - "+line_read[row-4][0]+" *******");
            int ns=line_read[row-3][0] == "??????:"? 3: line_read[row-4][0] == "??????:"? 4: line_read[row-5][0] == "??????:"? 5: 
               line_read[row-6][0] == "??????:"? 6: line_read[row-7][0] == "??????:"? 7: line_read[row-8][0] == "??????:"? 8: 2;             // if (! ns)  return(0);
            nr = StringTrimRight(StringTrimLeft(line_read[row - 11 - ns][2])) == ""? 12 + ns: 11 + ns;         nc = (line_read[row-nr][1]=="Again" || line_read[row-nr][1]=="again") &&
               line_read[row-12-ns][0] != "ＭＯＯＮＢ"? line_read[row-12-ns][3]=="AT"? 4: line_read[row-12-ns][4]=="AT"? 5: line_read[row-12-ns][5]=="AT"? 6: line_read[row-12-ns][6]=="AT"? 7: 3:
               line_read[row-nr][3]=="AT"? 4: line_read[row-nr][4]=="AT"? 5: line_read[row-nr][5]=="AT"? 6: line_read[row-nr][6]=="AT"? 7: 3;
            if (line_read[row][0] == "Correction:" && line_read[row+1][0] == "TP2:") TP = StrToDouble(line_read[row+1][1]);
            else  TP = line_read[row-7-ns][1] != ""? StrToDouble(line_read[row-7-ns][2]): StrToDouble(line_read[row-7-ns][1]);
//            TP1 = line_read[row-8-ns][1] != ""? StrToDouble(line_read[row-8-ns][2]): StrToDouble(line_read[row-8-ns][1]);
//            TP3 = line_read[row-6-ns][1] != ""? StrToDouble(line_read[row-6-ns][2]): StrToDouble(line_read[row-6-ns][1]);
            if (line_read[row][0] == "Correction:" && line_read[row+1][0] == "SL:") SL = StrToDouble(line_read[row+1][1]);    else  SL = StrToDouble(line_read[row][3]);
            double SL_=line_read[row-3-ns][0] == "."? StrToDouble(line_read[row-3-ns][3]): StrToDouble(line_read[row-3-ns][2]);
            if (StringFind(line_read[row-nr][5], "/") > 3) line_read[row-nr][5] = StringSubstr(line_read[row-nr][5], 0, StringFind(line_read[row-nr][5], "/"));
            LM = (line_read[row-nr][1]=="Again" || line_read[row-nr][1]=="again") && line_read[row-14-ns][0]!="Professor"? StrToDouble(line_read[row-14-ns][nc]): StrToDouble(line_read[row-nr][nc]);
            Bull = line_read[row-nr][0]=="BUY" || line_read[row-nr][0]=="Buy" || line_read[row-nr][0]=="buy";     ticket1 = 0;      ticket2 = 0;      icase = 0;     Symb = Symb_Check(Symb, LM);
//            TP = TP2 + (Bull? -1: 1) * MarketInfo(OrderSymbol(), MODE_SPREAD) * MarketInfo(OrderSymbol(), MODE_TICKSIZE) / 2;
Alert("*****2-5b* "+IntegerToString(row)+" - "+Symb+" - "+Bull+" - "+DoubleToStr(TP, MarketInfo(Symb, MODE_DIGITS))+" - "+DoubleToStr(SL, MarketInfo(Symb, MODE_DIGITS))+" - "+
   DoubleToStr(SL_, MarketInfo(Symb, MODE_DIGITS))+" - "+DoubleToStr(LM, MarketInfo(Symb, MODE_DIGITS))+" - "+IntegerToString(tickt_b[0])+" - "+IntegerToString(tickt_b[1])+" - "+
   OrderSelect(tickt_b[0], SELECT_BY_TICKET)+" *******");               // if (SL <= 0.0 || TP <= 0.0 || LM <= 0.0) return(0);
            if ((Bull && SL > LM) || (! Bull && SL < LM)) Alert("*** ATTENTION ERREUR SL !! " + DoubleToStr(SL, MarketInfo(Symb, MODE_DIGITS)) + " / " + DoubleToStr(LM, MarketInfo(Symb, MODE_DIGITS)) + " ***");
            if (OrderSelect(mOrderSelect(1, Symb, SL_), SELECT_BY_POS)) { ticket1 = OrderTicket();
               if (((line_read[row][0] == "Move" || line_read[row][0] == "MOVE") && line_read[row][1] == "SL") || line_read[row][0] == "Correction:")
                  tst = OrderModify(ticket1, OrderOpenPrice(), line_read[row][3] == "ENTRY"? (OrderType() && LM < OrderOpenPrice() && LM > 0.0) || 
                     (! OrderType() && LM > OrderOpenPrice())? LM: OrderOpenPrice(): SL, TP, 0, clrNONE);
               if (line_read[row][0] == "CLOSE" || line_read[row][0] == "Delete") {
                  tst = OrderClose(ticket1, lot, OrderType()? MarketInfo(Symb,MODE_ASK): MarketInfo(Symb,MODE_BID), slip, clrNONE);
                  if (tst) { GlobalVariableDel(Symb + StringSubstr(IntegerToString(ticket1), StringLen(IntegerToString(ticket1)) - 4) + "_TP1");
                     GlobalVariableDel(Symb + StringSubstr(IntegerToString(ticket1), StringLen(IntegerToString(ticket1)) - 4) + "_TP2");
                     GlobalVariableDel(Symb + StringSubstr(IntegerToString(ticket1), StringLen(IntegerToString(ticket1)) - 4) + "_TP3");
                     GlobalVariableSet(Symb + StringSubstr(IntegerToString(ticket1), StringLen(IntegerToString(ticket1)) - 4) + "_TPx", -1); } } }
            if (OrderSelect(mOrderSelect(1, Symb, SL_), SELECT_BY_POS)) { ticket2 = OrderTicket();
               if (((line_read[row][0] == "Move" || line_read[row][0] == "MOVE") && line_read[row][1] == "SL") || line_read[row][0] == "Correction:")
                  tst = OrderModify(ticket2, OrderOpenPrice(), line_read[row][3] == "ENTRY"? (OrderType() && LM < OrderOpenPrice() && LM > 0.0) || 
                     (! OrderType() && LM > OrderOpenPrice())? LM: OrderOpenPrice(): SL, TP, 0, clrNONE);
               if (line_read[row][0] == "CLOSE" || line_read[row][0] == "Delete") {
                  tst = OrderClose(ticket2, lot, OrderType()? MarketInfo(Symb,MODE_ASK): MarketInfo(Symb,MODE_BID), slip, clrNONE);
                  if (tst) { GlobalVariableDel(Symb + StringSubstr(IntegerToString(ticket2), StringLen(IntegerToString(ticket2)) - 4) + "_TP1");
                     GlobalVariableDel(Symb + StringSubstr(IntegerToString(ticket2), StringLen(IntegerToString(ticket2)) - 4) + "_TP2");
                     GlobalVariableDel(Symb + StringSubstr(IntegerToString(ticket2), StringLen(IntegerToString(ticket2)) - 4) + "_TP3");
                     GlobalVariableSet(Symb + StringSubstr(IntegerToString(ticket2), StringLen(IntegerToString(ticket2)) - 4) + "_TPx", -1); } } }
            else  Alert("******* OrderSelect() Erreur ! " + IntegerToString(row) + " - " + IntegerToString(mOrderSelect(1, Symb, SL_)) + " - " + line_read[row][0] + " - " + Symb + " *******");
         break;
         case 6  :
         break;
         default :
Alert("*****2-0* "+IntegerToString(row)+" - "+line_read[row][0]+" - "+line_read[row][1]+" *******"); }
   tickt_[0] = ticket1;    tickt_[1] = ticket2;    Symb_ = Symb;     LM_ = LM;      return(icase); }

int line_read_type(int row) { int type=0;       string temp=line_read[row-1][0];
      if (line_read[row][0] == "??????:") type = 1;
      else if ((line_read[row][0] == "SELL" || line_read[row][0] == "BUY" || line_read[row][0] == "Sell" || line_read[row][0] == "Buy" ||
         line_read[row][0] == "sell" || line_read[row][0] == "buy") && (temp == "US30" || (StringSubstr(temp, 0, 3) == "---" &&     // == "ＭＯＯＮＢ"
         StringSubstr(temp, StringLen(temp) - 7) == "-------")) && line_read[row+3][0] != "TP1:" && line_read[row+4][0] != "TP1:") type = 2;
      else if (((line_read[row][0] == "SELL" || line_read[row][0] == "BUY" || line_read[row][0] == "Sell" || line_read[row][0] == "Buy" ||
         line_read[row][0] == "sell" || line_read[row][0] == "buy") && (line_read[row][1] == "Again" || line_read[row][1] == "again")) ||    // le cas "again" n'est pas encore prévu
         ((line_read[row][1] == "SELL" || line_read[row][1] == "BUY" || line_read[row][1] == "Sell" || line_read[row][1] == "Buy" ||
         line_read[row][1] == "sell" || line_read[row][1] == "buy") && (line_read[row][0] == "Again" || line_read[row][0] == "again"))) type = -3;
/*      else if ((line_read[row][0] == "SELL" || line_read[row][0] == "BUY" || line_read[row][0] == "Sell" || line_read[row][0] == "Buy" ||
         line_read[row][0] == "sell" || line_read[row][0] == "buy") && (line_read[row][1] == "LIMIT" || line_read[row][1] == "Limit" ||
         line_read[row][1] == "limit" || line_read[row][2] == "LIMIT" || line_read[row][2] == "Limit" || line_read[row][2] == "limit" ||
         line_read[row][3] == "LIMIT" || line_read[row][3] == "Limit" || line_read[row][3] == "limit")) type = 4; */
      else if ((((line_read[row][0]=="Move" || line_read[row][0]=="MOVE") && (line_read[row][1]=="SL" || line_read[row][1]=="STOP")) || (line_read[row][0]=="CLOSE" && line_read[row][1]!="HALF") ||
         (line_read[row][0] == "Correction:" && (line_read[row+1][0] == "Modify" || line_read[row+1][0] == "STOP" || line_read[row+1][0] == "TP2:" || line_read[row+1][0] == "SL:")) ||
         (line_read[row][0] == "Delete" && (line_read[row][1] == "Sell" || line_read[row][1] == "Buy"))) && (line_read[row-2][0] == "??????:" || line_read[row-3][0] == "??????:" ||
         line_read[row-4][0] == "??????:" || line_read[row-5][0] == "??????:" || line_read[row-6][0] == "??????:" || line_read[row-7][0] == "??????:" || line_read[row-8][0] == "??????:")) type = 5;
      else if (line_read[row][0] == "CLOSE" && line_read[row][1] == "HALF") type = 6;     // traité par le +20 pips
   return(type); }
#endif

string Symb_Check(string Symb,double LM) { lot = _lot;
   ResetLastError();    if (StringFind(Symb, "/") > 0) StringReplace(Symb, "/", "");         // Symb = StringSubstr(Symb, 0, StringFind(Symb, "/"));
   string s_comp=AccountCompany();     int i_comp=StringSubstr(s_comp,0,5) == "Black"? 0: StringSubstr(s_comp,0,5) == "FX Ch"? 1: StringSubstr(s_comp,0,5) == "Trade"? 2: 3;
   switch(i_comp) {
         case 0  :
      if (Symb == "GOLD" || Symb == "Gold") Symb = "XAUUSD";         Symb += "p";         if (Symb == "XBRUSDp") Symb = "BRENT";
      if (Symb=="XTIUSDp" || Symb=="USOILp") if (LM > 0.0) Symb = fabs((MarketInfo("WTI",MODE_BID)+MarketInfo("WTI",MODE_ASK))/2 - LM) > 
         fabs((MarketInfo("BRENT",MODE_BID)+MarketInfo("BRENT",MODE_ASK))/2 - LM) ? "BRENT" : "WTI";     else  Symb = "WTI";
      if (StringSubstr(Symb, 0, 3) == "GNP") Symb = "GBP" + StringSubstr(Symb, 3);        if (Symb == "US30p") { Symb = "US30";     lot = 0.1; }
         break;
         case 1  :
      if (Symb == "GOLD" || Symb == "Gold") Symb = "XAUUSD";         if (Symb == "XBRUSD") Symb = "BRENT";           // Symb += "p";
      if (Symb=="XTIUSD" || Symb=="USOIL") if (LM > 0.0) Symb = fabs((MarketInfo("WTI",MODE_BID)+MarketInfo("WTI",MODE_ASK))/2 - LM) > 
         fabs((MarketInfo("BRENT",MODE_BID)+MarketInfo("BRENT",MODE_ASK))/2 - LM) ? "BRENT" : "WTI";     else  Symb = "WTI";
      if (StringSubstr(Symb, 0, 3) == "GNP") Symb = "GBP" + StringSubstr(Symb, 3);        if (Symb == "US30") { Symb = "US30";     lot = 0.1; }
         break;
         case 2  :
         break;
         case 3  :
      if (Symb == "GOLD" || Symb == "Gold") Symb = "XAUUSD";         if (Symb == "XBRUSD") Symb = "BRENT";           // Symb += "p";
      if (Symb=="XTIUSD" || Symb=="USOIL") if (LM > 0.0) Symb = fabs((MarketInfo("WTI",MODE_BID)+MarketInfo("WTI",MODE_ASK))/2 - LM) > 
         fabs((MarketInfo("BRENT",MODE_BID)+MarketInfo("BRENT",MODE_ASK))/2 - LM) ? "BRENT" : "WTI";     else  Symb = "WTI";
      if (StringSubstr(Symb, 0, 3) == "GNP") Symb = "GBP" + StringSubstr(Symb, 3);        if (Symb == "US30") { Symb = "DJ30";     lot = 0.1; }
      if (Symb == "NASdaq100") { Symb = "NAS100";     lot = 0.1; }
         break; }
Alert("******* " + s_comp + " - " + IntegerToString(i_comp) + " *******");       _p = i_comp ? "" : "p";          // pour ajouter aux Symb / BB lorsque c'est nécessaire
 return(Symb); }

/*            MarketInfo(OrderSymbol(), MODE_TICKVALUE) * lot; }       else { ordprof = OrderProfit();        LM = 0.0; }    // ^ rapport à 197 ticks
if (OrderProfit() > 1.6 && mOrdersTotal(OrderSymbol(), OrderStopLoss()) > 1) { tst = OrderSelect(ticket, SELECT_BY_TICKET);
Alert("*****1b* OrderSelect: "+IntegerToString(pos)+" - "+IntegerToString(ticket)+" - "+IntegerToString(total)+" - "+IntegerToString(OrderTicket())+  // OrderSelect(pos, SELECT_BY_POS)+" - "+
   " - " + DoubleToStr(OrderProfit(), MarketInfo(OrderSymbol(), MODE_DIGITS)) + " - " + DoubleToStr(ordprof, MarketInfo(OrderSymbol(), MODE_DIGITS)) + " - " + DoubleToStr(lot, 2) +" - "+
   DoubleToStr(MarketInfo(OrderSymbol(), MODE_TICKVALUE), MarketInfo(OrderSymbol(), MODE_DIGITS))+" - "+OrderSymbol()+" - "+IntegerToString(mOrdersTotal(OrderSymbol(), OrderStopLoss()))+
   " - "+DoubleToStr(n_tcks * lot * MarketInfo(OrderSymbol(), MODE_TICKVALUE), MarketInfo(OrderSymbol(), MODE_DIGITS))+" | "+(ordprof > n_tcks * lot * MarketInfo(OrderSymbol(), MODE_TICKVALUE) && 
   mOrdersTotal(OrderSymbol(), OrderStopLoss()) == 2 && OrderType() < 2)+" - "+(ordprof > n_tcks * lot * MarketInfo(OrderSymbol(), MODE_TICKVALUE))+" - "+(mOrdersTotal(OrderSymbol(), 
   OrderStopLoss()) == 2)+" - "+(OrderType() < 2)+" | "+DoubleToStr(OrderProfit(), MarketInfo(OrderSymbol(), MODE_DIGITS))+" - "+DoubleToStr((OrderType()? 1: -1) * ((LM - OrderOpenPrice()) / 
   MarketInfo(OrderSymbol(), MODE_TICKSIZE) - 10) * MarketInfo(OrderSymbol(), MODE_TICKVALUE) * lot, MarketInfo(OrderSymbol(), MODE_DIGITS))+" - "+DoubleToStr(LM, MarketInfo(OrderSymbol(), 
   MODE_DIGITS))+" - "+DoubleToStr(OrderOpenPrice(), MarketInfo(OrderSymbol(), MODE_DIGITS))+" - "+DoubleToStr(((LM - OrderOpenPrice()) / MarketInfo(OrderSymbol(), MODE_TICKSIZE) - 10), 
   MarketInfo(OrderSymbol(), MODE_DIGITS))+" *******"); }             tst = OrderSelect(ticket, SELECT_BY_TICKET);                                              // - OrderCommission()
      if (round(ordprof*100.0)/100.0 > (dtmp=(n_tcks * lot * MarketInfo(OrderSymbol(), MODE_TICKVALUE))) && !((itmp=mOrdersTotal(OrderSymbol(), OrderStopLoss())) % 2) && OrderType() < 2) {

. . .

         t_close = false;        cpt = 0;          tst = OrderSelect(ticket, SELECT_BY_TICKET);
Alert("*****1c* OrderSelect: "+IntegerToString(pos)+" - "+IntegerToString(ticket)+" - "+IntegerToString(total)+" - "+IntegerToString(OrderTicket())+  // OrderSelect(pos, SELECT_BY_POS)+" - "+
   " - " + DoubleToStr(OrderProfit(), MarketInfo(OrderSymbol(), MODE_DIGITS)) + " - " + DoubleToStr(ordprof, MarketInfo(OrderSymbol(), MODE_DIGITS)) + " - " + DoubleToStr(lot, 2) +" - "+
   DoubleToStr(MarketInfo(OrderSymbol(), MODE_TICKVALUE), MarketInfo(OrderSymbol(), MODE_DIGITS))+" - "+OrderSymbol()+" - "+IntegerToString(mOrdersTotal(OrderSymbol(), OrderStopLoss()))+
   " - "+IntegerToString(itmp)+" - "+DoubleToStr(n_tcks * lot * MarketInfo(OrderSymbol(), MODE_TICKVALUE), MarketInfo(OrderSymbol(), MODE_DIGITS))+" - "+DoubleToStr(dtmp, MarketInfo(OrderSymbol(), 
   MODE_DIGITS))+" | "+(ordprof > n_tcks * lot * MarketInfo(OrderSymbol(), MODE_TICKVALUE) && !(mOrdersTotal(OrderSymbol(), OrderStopLoss()) % 2) && OrderType() < 2)+" - "+(ordprof > n_tcks * lot * 
   MarketInfo(OrderSymbol(), MODE_TICKVALUE))+" - "+(!(mOrdersTotal(OrderSymbol(), OrderStopLoss()) % 2))+" - "+(OrderType() < 2)+" | "+DoubleToStr(OrderProfit(), MarketInfo(OrderSymbol(), 
   MODE_DIGITS))+" - "+DoubleToStr((OrderType()? 1: -1) * ((LM - OrderOpenPrice()) / MarketInfo(OrderSymbol(), MODE_TICKSIZE) - 10) * MarketInfo(OrderSymbol(), MODE_TICKVALUE) * lot, 
   MarketInfo(OrderSymbol(), MODE_DIGITS))+" - "+DoubleToStr(LM, MarketInfo(OrderSymbol(), MODE_DIGITS))+" - "+DoubleToStr(OrderOpenPrice(), MarketInfo(OrderSymbol(), MODE_DIGITS))+" - "+
   DoubleToStr(((LM - OrderOpenPrice()) / MarketInfo(OrderSymbol(), MODE_TICKSIZE) - 10), MarketInfo(OrderSymbol(), MODE_DIGITS))+" *******");     tst = OrderSelect(ticket, SELECT_BY_TICKET);
         while (! t_close && (cpt < 4 || slip == 2)) { t_close = OrderClose(ticket, lot, OrderType()? MarketInfo(OrderSymbol(),MODE_ASK): MarketInfo(OrderSymbol(),MODE_BID), slip, clrNONE);

. . .

         case 1  :
Alert("*****2-1* "+IntegerToString(row)+" - "+line_read[row][0]+" - "+line_read[row-2][1]+" - "+line_read[row-3][1]+" - "+line_read[row-4][2]+" - "+line_read[row-4][1]+" - "+line_read[row-4][0]+" *******");
            double TP=StrToDouble(line_read[row-2][1]), SL=StrToDouble(line_read[row-3][1]), LM=StrToDouble(line_read[row-4][2]);
            string Symb=line_read[row-4][0];          int icase=0;
            ResetLastError();    if (StringFind(Symb, "/") > 0) Symb = StringSubstr(Symb, 0, StringFind(Symb, "/"));
            if (Symb == "GOLD" || Symb == "Gold") Symb = "XAUUSD";         Symb += "p";         if (Symb == "XBRUSDp") Symb = "BRENT";
            if (Symb=="XTIUSDp" || Symb=="USOILp") if (LM > 0.0) Symb = fabs((MarketInfo("WTI",MODE_BID)+MarketInfo("WTI",MODE_ASK))/2 - LM) > 
               fabs((MarketInfo("BRENT",MODE_BID)+MarketInfo("BRENT",MODE_ASK))/2 - LM) ? "BRENT" : "WTI";     else  Symb = "WTI";
            if (StringSubstr(Symb, 0, 3) == "GNP") Symb = "GBP" + StringSubstr(Symb, 3);
            bool Bull=line_read[row-4][1] == "BUY", t_adx=iCustom(Symb,0,"New folder\\ADX.ex4",0,7)<47 && iCustom(Symb,0,"New folder\\ADX.ex4",0,14)<40;
            if (Bull && MarketInfo(Symb,MODE_ASK) - LM >= 75 * MarketInfo(Symb, MODE_TICKSIZE) && t_adx) {
               ticket = OrderSend(Symb, OP_BUYLIMIT, lot, LM, slip, SL, TP, "OP_BUYLIMIT", 0, 0, clrNONE);
               ticket = OrderSend(Symb, OP_BUYLIMIT, lot, LM, slip, SL, TP, "OP_BUYLIMIT", 0, 0, clrNONE);       icase = 1; }
            else  if (Bull) { icase = 2;        // && MarketInfo(Symb,MODE_ASK) - LM < 75 * MarketInfo(Symb, MODE_TICKSIZE)
               while((! ticket || ticket == -1) && cpt < 7) { if (ticket) { Sleep(5 * PAUSE);       RefreshRates(); }
                  ticket = OrderSend(Symb, OP_BUY, lot, MarketInfo(Symb,MODE_ASK), slip, SL, TP, LM+" | OP_BUY", 0, 0, clrNONE);      cpt ++; }
               ticket = 0;          while((! ticket || ticket == -1) && cpt < 7) { cpt ++;
                  if (ticket) { Sleep(5 * PAUSE);           RefreshRates(); }
                  ticket = OrderSend(Symb, OP_BUY, lot, MarketInfo(Symb,MODE_ASK), slip, SL, TP, LM+" | OP_BUY", 0, 0, clrNONE); } }
            if (! Bull && LM - MarketInfo(Symb,MODE_BID) >= 75 * MarketInfo(Symb, MODE_TICKSIZE) && t_adx) {
               ticket = OrderSend(Symb, OP_SELLLIMIT, lot, LM, slip, SL, TP, "OP_SELLLIMIT", 0, 0, clrNONE);
               ticket = OrderSend(Symb, OP_SELLLIMIT, lot, LM, slip, SL, TP, "OP_SELLLIMIT", 0, 0, clrNONE);     icase = 3; }
            else  if (! Bull) { icase = 4;      // && LM - MarketInfo(Symb,MODE_BID) < 75 * MarketInfo(Symb, MODE_TICKSIZE)
               while((! ticket || ticket == -1) && cpt < 7) { if (ticket) { Sleep(5 * PAUSE);       RefreshRates(); }
                  ticket = OrderSend(Symb, OP_SELL, lot, MarketInfo(Symb,MODE_BID), slip, SL, TP, LM+" | OP_SELL", 0, 0, clrNONE);    cpt ++; }
               ticket = 0;          while((! ticket || ticket == -1) && cpt < 7) { cpt ++;
                  if (ticket) { Sleep(5 * PAUSE);           RefreshRates(); }
                  ticket = OrderSend(Symb, OP_SELL, lot, MarketInfo(Symb,MODE_BID), slip, SL, TP, LM+" | OP_SELL", 0, 0, clrNONE); } }
         break;
         case 2  :
Alert("*****2-2* "+IntegerToString(row)+" - "+line_read[row][0]+" - "+line_read[row-2][1]+" - "+line_read[row-3][1]+" - "+line_read[row-4][2]+" - "+line_read[row-4][1]+" - "+line_read[row-4][0]+" *******");
            LM = StrToDouble(line_read[row][4]);         Symb = line_read[row][2];         ticket = 0;       icase = 0;
            SL = line_read[row+2][0] == "TP"? StrToDouble(line_read[row+3][1]): StrToDouble(line_read[row+2][1]);
            TP = line_read[row+2][0] == "TP"? fabs(LM - StrToDouble(line_read[row+2][1])) > fabs(LM - StrToDouble(line_read[row+1][1]))? 
               StrToDouble(line_read[row+2][1]): StrToDouble(line_read[row+1][1]): StrToDouble(line_read[row+1][1]);
            Bull = line_read[row][0] == "BUY" || line_read[row][0] == "Buy" || line_read[row][0] == "buy";
            ResetLastError();    if (StringFind(Symb, "/") > 0) Symb = StringSubstr(Symb, 0, StringFind(Symb, "/"));
            if (Symb == "GOLD" || Symb == "Gold") Symb = "XAUUSD";         Symb += "p";         if (Symb == "XBRUSDp") Symb = "BRENT";
            if (Symb=="XTIUSDp" || Symb=="USOILp") if (LM > 0.0) Symb = fabs((MarketInfo("WTI",MODE_BID)+MarketInfo("WTI",MODE_ASK))/2 - LM) > 
               fabs((MarketInfo("BRENT",MODE_BID)+MarketInfo("BRENT",MODE_ASK))/2 - LM) ? "BRENT" : "WTI";     else  Symb = "WTI";
            if (StringSubstr(Symb, 0, 3) == "GNP") Symb = "GBP" + StringSubstr(Symb, 3);
            if (Bull) { ticket = OrderSend(Symb, OP_BUYLIMIT, lot, LM, slip, SL, TP, "OP_BUYLIMIT", 0, 0, clrNONE);
               ticket = OrderSend(Symb, OP_BUYLIMIT, lot, LM, slip, SL, TP, "OP_BUYLIMIT", 0, 0, clrNONE);     icase = 1; }
            else { ticket = OrderSend(Symb, OP_SELLLIMIT, lot, LM, slip, SL, TP, "OP_SELLLIMIT", 0, 0, clrNONE);
               ticket = OrderSend(Symb, OP_SELLLIMIT, lot, LM, slip, SL, TP, "OP_SELLLIMIT", 0, 0, clrNONE);   icase = 3; }
         break;
         case 3  :
Alert("*****2-3* "+IntegerToString(row)+" - "+line_read[row][0]+" - "+line_read[row][1]+" - "+line_read[row-1][1]+" - "+line_read[row-2][2]+" - "+line_read[row-2][1]+" - "+line_read[row-2][0]+" *******");
            TP = StrToDouble(line_read[row][1]);      SL = StrToDouble(line_read[row-1][1]);    LM = StrToDouble(line_read[row-2][2]);
            Bull = line_read[row-2][1] == "BUY";      Symb = line_read[row-2][0];         ticket = 0;       icase = 0;
            ResetLastError();    if (StringFind(Symb, "/") > 0) Symb = StringSubstr(Symb, 0, StringFind(Symb, "/"));
            if (Symb == "GOLD" || Symb == "Gold") Symb = "XAUUSD";         Symb += "p";         if (Symb == "XBRUSDp") Symb = "BRENT";
            if (Symb=="XTIUSDp" || Symb=="USOILp") if (LM > 0.0) Symb = fabs((MarketInfo("WTI",MODE_BID)+MarketInfo("WTI",MODE_ASK))/2 - LM) > 
               fabs((MarketInfo("BRENT",MODE_BID)+MarketInfo("BRENT",MODE_ASK))/2 - LM) ? "BRENT" : "WTI";     else  Symb = "WTI";
            if (StringSubstr(Symb, 0, 3) == "GNP") Symb = "GBP" + StringSubstr(Symb, 3);
            t_adx = iCustom(Symb, PERIOD_M30, "New folder\\ADX.ex4", 1, 7) < 47 && iCustom(Symb, PERIOD_M30, "New folder\\ADX.ex4", 1, 14) < 40;
            if (Bull && LM > 0.0 && MarketInfo(Symb,MODE_ASK) - LM >= 75 * MarketInfo(Symb, MODE_TICKSIZE) && TP > MarketInfo(Symb,MODE_ASK) && t_adx) {
               ticket = OrderSend(Symb, OP_BUYLIMIT, lot, LM, slip, SL, TP, "OP_BUYLIMIT", 0, 0, clrNONE);
               ticket = OrderSend(Symb, OP_BUYLIMIT, lot, LM, slip, SL, TP, "OP_BUYLIMIT", 0, 0, clrNONE);       icase = 1; }
            else  if (Bull) { icase = 2;        // && MarketInfo(Symb,MODE_ASK) - LM < 75 * MarketInfo(Symb, MODE_TICKSIZE)
               while((! ticket || ticket == -1) && cpt < 7) { if (ticket) { Sleep(5 * PAUSE);       RefreshRates(); }
                  ticket = OrderSend(Symb, OP_BUY, lot, MarketInfo(Symb,MODE_ASK), slip, SL, TP, LM+" | OP_BUY", 0, 0, clrNONE);      cpt ++; }
               ticket = 0;          while((! ticket || ticket == -1) && cpt < 7) { cpt ++;
                  if (ticket) { Sleep(5 * PAUSE);           RefreshRates(); }
                  ticket = OrderSend(Symb, OP_BUY, lot, MarketInfo(Symb,MODE_ASK), slip, SL, TP, LM+" | OP_BUY", 0, 0, clrNONE); } }
            if (! Bull && LM - MarketInfo(Symb,MODE_BID) >= 75 * MarketInfo(Symb, MODE_TICKSIZE) && TP < MarketInfo(Symb,MODE_BID) && t_adx) {
               ticket = OrderSend(Symb, OP_SELLLIMIT, lot, LM, slip, SL, TP, "OP_SELLLIMIT", 0, 0, clrNONE);
               ticket = OrderSend(Symb, OP_SELLLIMIT, lot, LM, slip, SL, TP, "OP_SELLLIMIT", 0, 0, clrNONE);     icase = 3; }
            else  if (! Bull) { icase = 4;      // && LM - MarketInfo(Symb,MODE_BID) < 75 * MarketInfo(Symb, MODE_TICKSIZE)
               while((! ticket || ticket == -1) && cpt < 7) { if (ticket) { Sleep(5 * PAUSE);       RefreshRates(); }
                  ticket = OrderSend(Symb, OP_SELL, lot, MarketInfo(Symb,MODE_BID), slip, SL, TP, LM+" | OP_SELL", 0, 0, clrNONE);    cpt ++; }
               ticket = 0;          while((! ticket || ticket == -1) && cpt < 7) { cpt ++;
                  if (ticket) { Sleep(5 * PAUSE);           RefreshRates(); }
                  ticket = OrderSend(Symb, OP_SELL, lot, MarketInfo(Symb,MODE_BID), slip, SL, TP, LM+" | OP_SELL", 0, 0, clrNONE); } }
         break;
         case 4  :
Alert("*****2-4* "+IntegerToString(row)+" - "+line_read[row][0]+" - "+line_read[row-2][1]+" - "+line_read[row-3][1]+" - "+line_read[row-4][2]+" - "+line_read[row-4][1]+" - "+line_read[row-4][0]+" *******");
            TP = StrToDouble(line_read[row-2][1]);    SL = StrToDouble(line_read[row-3][1]);    LM = StrToDouble(line_read[row-4][2]);
            Bull = line_read[row-4][1] == "BUY";      Symb = line_read[row-4][0];         ticket = 0;       icase = 0;
            ResetLastError();    if (StringFind(Symb, "/") > 0) Symb = StringSubstr(Symb, 0, StringFind(Symb, "/"));
            if (Symb == "GOLD" || Symb == "Gold") Symb = "XAUUSD";         Symb += "p";         if (Symb == "XBRUSDp") Symb = "BRENT";
            if (Symb=="XTIUSDp" || Symb=="USOILp") if (LM > 0.0) Symb = fabs((MarketInfo("WTI",MODE_BID)+MarketInfo("WTI",MODE_ASK))/2 - LM) > 
               fabs((MarketInfo("BRENT",MODE_BID)+MarketInfo("BRENT",MODE_ASK))/2 - LM) ? "BRENT" : "WTI";     else  Symb = "WTI";
            if (StringSubstr(Symb, 0, 3) == "GNP") Symb = "GBP" + StringSubstr(Symb, 3);
            t_adx = iCustom(Symb, PERIOD_M30, "New folder\\ADX.ex4", 1, 7) < 47 && iCustom(Symb, PERIOD_M30, "New folder\\ADX.ex4", 1, 14) < 40;
            if (Bull && MarketInfo(Symb,MODE_ASK) - LM >= 75 * MarketInfo(Symb, MODE_TICKSIZE) && t_adx) {
               ticket = OrderSend(Symb, OP_BUYLIMIT, lot, LM, slip, SL, TP, "OP_BUYLIMIT", 0, 0, clrNONE);
               ticket = OrderSend(Symb, OP_BUYLIMIT, lot, LM, slip, SL, TP, "OP_BUYLIMIT", 0, 0, clrNONE);       icase = 1; }
            else  if (Bull) { icase = 2;        // && MarketInfo(Symb,MODE_ASK) - LM < 75 * MarketInfo(Symb, MODE_TICKSIZE)
               while((! ticket || ticket == -1) && cpt < 7) { if (ticket) { Sleep(5 * PAUSE);       RefreshRates(); }
                  ticket = OrderSend(Symb, OP_BUY, lot, MarketInfo(Symb,MODE_ASK), slip, SL, TP, LM+" | OP_BUY", 0, 0, clrNONE);      cpt ++; }
               ticket = 0;          while((! ticket || ticket == -1) && cpt < 7) { cpt ++;
                  if (ticket) { Sleep(5 * PAUSE);           RefreshRates(); }
                  ticket = OrderSend(Symb, OP_BUY, lot, MarketInfo(Symb,MODE_ASK), slip, SL, TP, LM+" | OP_BUY", 0, 0, clrNONE); } }
            if (! Bull && LM - MarketInfo(Symb,MODE_BID) >= 75 * MarketInfo(Symb, MODE_TICKSIZE) && t_adx) {
               ticket = OrderSend(Symb, OP_SELLLIMIT, lot, LM, slip, SL, TP, "OP_SELLLIMIT", 0, 0, clrNONE);
               ticket = OrderSend(Symb, OP_SELLLIMIT, lot, LM, slip, SL, TP, "OP_SELLLIMIT", 0, 0, clrNONE);     icase = 3; }
            else  if (! Bull) { icase = 4;      // && LM - MarketInfo(Symb,MODE_BID) < 75 * MarketInfo(Symb, MODE_TICKSIZE)
               while((! ticket || ticket == -1) && cpt < 7) { if (ticket) { Sleep(5 * PAUSE);       RefreshRates(); }
                  ticket = OrderSend(Symb, OP_SELL, lot, MarketInfo(Symb,MODE_BID), slip, SL, TP, LM+" | OP_SELL", 0, 0, clrNONE);    cpt ++; }
               ticket = 0;          while((! ticket || ticket == -1) && cpt < 7) { cpt ++;
                  if (ticket) { Sleep(5 * PAUSE);           RefreshRates(); }
                  ticket = OrderSend(Symb, OP_SELL, lot, MarketInfo(Symb,MODE_BID), slip, SL, TP, LM+" | OP_SELL", 0, 0, clrNONE); } }
         break;
         case 7  :
Alert("*****2-7* "+IntegerToString(row)+" - "+line_read[row][0]+" - "+line_read[row][1]+" *******");
            Symb = line_read[row][1];                 ResetLastError();
            if (StringFind(Symb, "/") > 0) Symb = StringSubstr(Symb, 0, StringFind(Symb, "/"));
            if (Symb == "GOLD" || Symb == "Gold") Symb = "XAUUSD";         Symb += "p";         if (Symb == "XBRUSDp") Symb = "BRENT";
            if (Symb=="XTIUSDp" || Symb=="USOILp") if (LM > 0.0) Symb = fabs((MarketInfo("WTI",MODE_BID)+MarketInfo("WTI",MODE_ASK))/2 - LM) > 
               fabs((MarketInfo("BRENT",MODE_BID)+MarketInfo("BRENT",MODE_ASK))/2 - LM) ? "BRENT" : "WTI";     else  Symb = "WTI";
            if (StringSubstr(Symb, 0, 3) == "GNP") Symb = "GBP" + StringSubstr(Symb, 3);
            if (OrderSelect(mOrderSelect(0, Symb, 0), SELECT_BY_POS)) { ticket = OrderTicket();
               while (! t_close && cpt < 4) { t_close = OrderClose(ticket, lot, OrderType()? MarketInfo(Symb,MODE_ASK): MarketInfo(Symb,MODE_BID), slip, clrNONE);
                  if (cpt) { Sleep(5 * PAUSE);        RefreshRates(); }          cpt ++; }
               if (! t_close) Alert("***** Ticket NOT CLOSED! (1) " + ticket + " - " + GetLastError() + " *****"); }
            else  Print("*** -> Ticket Select ERROR! ", GetLastError(), ", pos0: ", mOrderSelect(0, Symb, 0), " ***");
         break;
         case 9  :
Alert("*****2-9* "+IntegerToString(row)+" - "+line_read[row][0]+" - "+line_read[row][1]+" *******");
            TP = StrToDouble(line_read[row+2][1]);       SL = StrToDouble(line_read[row+1][1]);
            Symb = line_read[row][1];        ResetLastError();       ticket = 0;       icase = 0;
            Bull = line_read[row][0] == "Buy" || line_read[row][0] == "buy";
            if (Symb == "GOLD" || Symb == "gold") Symb = "XAUUSD";
            if (StringFind(Symb, "/") > 0) Symb = StringSubstr(Symb, 0, StringFind(Symb, "/"));
            if (Symb == "GOLD" || Symb == "Gold") Symb = "XAUUSD";         Symb += "p";         if (Symb == "XBRUSDp") Symb = "BRENT";
            if (Symb=="XTIUSDp" || Symb=="USOILp") if (LM > 0.0) Symb = fabs((MarketInfo("WTI",MODE_BID)+MarketInfo("WTI",MODE_ASK))/2 - LM) > 
               fabs((MarketInfo("BRENT",MODE_BID)+MarketInfo("BRENT",MODE_ASK))/2 - LM) ? "BRENT" : "WTI";     else  Symb = "WTI";
            if (StringSubstr(Symb, 0, 3) == "GNP") Symb = "GBP" + StringSubstr(Symb, 3);
            if (Bull) { icase = 2;
               while((! ticket || ticket == -1) && cpt < 7) { if (ticket) { Sleep(5 * PAUSE);       RefreshRates(); }
                  ticket = OrderSend(Symb, OP_BUY, lot, MarketInfo(Symb,MODE_ASK), slip, SL > 0.0? SL: 0.0, TP > 0.0? TP: 0.0, 
                     line_read[row][2] + " - OP_BUY", 0, 0, clrNONE);        cpt ++; }
               ticket = 0;          while((! ticket || ticket == -1) && cpt < 7) { cpt ++;
                  if (ticket) { Sleep(5 * PAUSE);           RefreshRates(); }
                  ticket = OrderSend(Symb, OP_BUY, lot, MarketInfo(Symb,MODE_ASK), slip, SL > 0.0? SL: 0.0, TP > 0.0? TP: 0.0, 
                     line_read[row][2] + " - OP_BUY", 0, 0, clrNONE); } }
            if (! Bull) { icase = 4;
               while((! ticket || ticket == -1) && cpt < 7) { if (ticket) { Sleep(5 * PAUSE);       RefreshRates(); }
                  ticket = OrderSend(Symb, OP_SELL, lot, MarketInfo(Symb,MODE_BID), slip, SL > 0.0? SL: 0.0, TP > 0.0? TP: 0.0, 
                     line_read[row][2] + " - OP_SELL", 0, 0, clrNONE);       cpt ++; }
               ticket = 0;          while((! ticket || ticket == -1) && cpt < 7) { cpt ++;
                  if (ticket) { Sleep(5 * PAUSE);           RefreshRates(); }
                  ticket = OrderSend(Symb, OP_SELL, lot, MarketInfo(Symb,MODE_BID), slip, SL > 0.0? SL: 0.0, TP > 0.0? TP: 0.0, 
                     line_read[row][2] + " - OP_SELL", 0, 0, clrNONE); } }
         break; */
