/* Le fichier "Liste dObjets EA nr-0_BTC.mq4" est dans le rép. "\mes backups".
Il est identique au fichier "Liste dObjets EA nr-0.mq4" au moment de la création et modification de la version
utilisée "Liste dObjets EA nr-1_BTC.mq4" */
//#property strict         // sauvé dans "Liste dObjets EA (FH2).mq4" avant intégration de VM2 à partir de "Liste dObjets EA (FH2-VM2).mq4" option v_opfx
//#define v_opfx 1           // <=> v_VM2
#define v_opfx_0           // pour récupérer du code de "#ifdef v_opfx" qui concerne aussi "#ifndef v_opfx"
#define v_dump_1           // pour activer les copy_file_(4,  dans "EA-write-file_Logs COMPLET.txt"
#define v_dump_2           // pour activer les copy_file_(4,  pour la première ligne
#define mkt_stocks         // marchés indices + cryptos + actions
#define scrShot2web        // pour valider "ScreenShot2webspace EA v1.1.mq4"
#define supertrend         // pour valider iCustom(NULL, 0, "SuperTrend_.ex4",
#define PAUSE      100
extern double lot = 0.01;  // Taille des lots
extern int slip = 5;       // Taille du slippage
//extern int comm = 13;      // Commission (pipettes)
//extern int comm = 156;    // Commission (points BTC)
extern int nBars = 300;    // nombre de barres lues
#ifdef v_opfx_0
/*enum DayOWs {dimanche=0, lundi=1, mardi=2, mercredi=3, jeudi=4, vendredi=5};
extern DayOWs First_Day = 1; */     int First_Day = 0;
// nomenclature : marché=1 digit, support=2 digits, période=4 digits, type=1 digit
enum magic_nbs {CHN_60=50100600, HKG_60=50200600, SPX_60=50300600, AUS_60=50400600, 
   UKg_60=50500600, USx_60=50600600, GER_60=50700600, JPN_60=50800600, 
   EUS_60=10100600, BTC_60=20100600, GLD_60=30100600, BRT_60=30300600, 
   CJP_60=10200600, EGB_60=10300600, EJP_60=10400600, GJP_60=10500600, UTR_60=10600600, 
   NAS_60=50900600, FRA_60=51000600, EST_60=51100600, ITA_60=51200600, SUI_60=51300600, 
   CHN_60_lm=50100601, HKG_60_lm=50200601, SPX_60_lm=50300601, AUS_60_lm=50400601, 
   UKg_60_lm=50500601, USx_60_lm=50600601, GER_60_lm=50700601, JPN_60_lm=50800601, 
   EUS_60_lm=10100601, BTC_60_lm=20100601, GLD_60_lm=30100601, BRT_60_lm=30300601, 
   CJP_60_lm=10200601, EGB_60_lm=10300601, EJP_60_lm=10400601, GJP_60_lm=10500601, UTR_60_lm=10600601, 
   NAS_60_lm=50900601, FRA_60_lm=51000601, EST_60_lm=51100601, ITA_60_lm=51200601, SUI_60_lm=51300601};
extern bool magic_on = true;
extern magic_nbs magic_nb = 50100600;
//extern magic_nbs magic_lm = 50100601;
extern bool Fl_Trade = true;

#import "shell32.dll"
 int ShellExecuteW(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd);
#import
#endif

//                test v iOPen/(iHigh+iLow)/2
bool ea_show=false, Op_OHL=true, Op_Show=false, Op_DDw=false, Op_HiLo=false, Op_Liq2=false, Op_Liq3=false, Op_Liq4=false#ifdef v_opfx_0, op_Liq_=false#endif,
      rate1c=false, rate2c=true, rate3c=false, rate4c=false#ifdef v_opfx, ha_Prev=false, ha_Buff=false, ha_Opt=false, Op_2xBl=false, Op_1xBl#endif, r_copyFtp=true;
int frameX=20, frameY=35, per_target, cpt=1, ticket, ac_ticket, ac_tickt2, total2=0, total3=0, total2_, total3_, Op_Liqu=1, tsh,
   r1_coporder, r2_coporder, r3_coporder, r4_coporder, cpt_wav=0, tmfr#ifdef v_opfx_0, so_cpt=0, r_coptime, t_web=-1#endif#ifdef supertrend, sectrend#endif;
bool t_clo_=false,t_blue=true,t_vilt=true,t_orge=true,bull_,pass1,endbull,St_Trd2,tr_allow=TerminalInfoInteger(TERMINAL_TRADE_ALLOWED)#ifdef supertrend, t_suptr=false#endif;
datetime blue_time,blue_time2,blue_time3, vilt_time,vilt_time2,vilt_time3, orge_time,orge_time2, ADX_time, BE_b, BE_s;
double pips2dbl, WM=0.0, AccBalance, p_Coef, ha1Open, ha1Close, haOpen, haClose, haHigh, haLow#ifdef supertrend, sup_trend#endif, ac_lmtick, SL2, TP2;
string bar_Dirs[],bar_Dir, sym_target, LabelNameEnd,LabelNameEnd2,LabelNameStp, s1_coporder,s2_coporder,s3_coporder,s4_coporder, stmfr;
#ifndef v_opfx
double ExtOpenBuffer[], ExtCloseBuffer[]/*, ExtLowHighBuffer[], ExtHighLowBuffer[]*/;
datetime prevTimeCurrent=TimeCurrent(), last_liq_t1, last_liq_t2;
bool infoMarket;     double last_liq_pr, last_ntr_pr;
#else
string tmp3, s_name, s_coptime, str_DCC;
datetime prevTimeCurrent=TimeCurrent(), last_liq_t1, last_liq_t2;
bool infoMarket;     double last_liq_pr, last_ntr_pr, op_Liq_pr, op_Liq_sp;   //int prevMinute=0;
#endif
#ifdef v_opfx_0
string tmp3, s_name, s_coptime, str_DCC, LabelNameSt2, f_tmp, f_tmp4="", f_tmp5="",
   tck_vstr,bull_str,tmfr0_str,tmfr1_str,tmfr2_str,l_rct_str,Chart_str,t1_Chart_str,t2_Chart_str,t1_Bull_str,t2_Bull_str,t3_Bull_str,t4_Bull_str,i_Cht_str,t_ATS_str,p_Ver_str;
int prevMinute=0,prevMinut2=0,tmfr_,tmfr_b,t3,test0=-1,test1=-1,test2=-1,HOp,Rect_Ks[50];       long Chart_M5;          string rect_str, Rect_Ns[50][2], EA_cht_str,EA_Ch2_str,EA_Ch3_str;
datetime tim_Chart_M5, tim_Chart_M5b, tim_Alt_M5, last_rect, next_vert, last_rct_=0, i_Cht_M5, curr_time, ATS_Time, tst_5c, tim_M15, tim_flt, tim_flt_=Time[0],
   last_liq_t12, last_liq_t22, last_liq_t13, last_liq_t23, tmp_savd2;
bool t5a_Bullish, t5b_Bullish, t5a_Bull_b, t5b_Bull_b, pass1b, t_night, t_h6, tst_5b, t_ngt0, ha_Shw=false, tmp_saved, t_TST1, t_TST2, Liqu_x2, t_M15_H1=false, t_M5_M15=false,
   OS1_tick=true, OS2_tick=true, OS3_tick=true, OS4_tick=true, OS5_tick=true, OS6_tick=true, OS9_tick=true, bull2, trd_on, fl_Trade=Fl_Trade, t_rsi51_, t_rsi515, t_rsi515o,
   tmf_Diff, no_OS5=false, inv_LiqLine, inv_ExpLine, tmp_savd3;
int sprd, comm, H1, H2, H3, H3_, diff, nb_ticks, Mg_N, nb_tcks_N, NR, rect_HG, haCoef=1, liqu_x2_n, tmf_Diff_b, be_tick;   // be_trade, be_tick pour partie BE
double SL, Rect_Hs[50][2], AccBalance_day, be_trade, last_liq_p2, last_ntr_p2, last_liq_p3, last_ntr_p3;          // comm=13  (6+7)   spr2=20
#endif

#ifndef v_opfx
#include <Liste dObjets EA.mqh>
#ifdef v_opfx_0
#include <Enable current EA.mqh>
#endif
#include <ind Accélération ++.mqh>
#include <view All Params new.mqh>
#else
#include <Liste dObjets (all).mqh>
#endif
#include <close_after_target_back (FH4).mqh>
#include <stdlib.mqh>

void OnInit() { ObjectsDelete(1, ""#ifdef v_opfx_0,0, 1#endif);
  EventSetMillisecondTimer(2000);
#ifdef v_opfx if (! EventSetTimer(60))
//  infoMarket = DayOfWeek() < 6 && (DayOfWeek() || Hour() >= 23) && (DayOfWeek() < 5 || Hour() <= 23);
  infoMarket = DayOfWeek() < 6 && (DayOfWeek() || Hour() >= 23) && (DayOfWeek() < 5 || Hour() <= H3); #endif
  ChartSetInteger(0,CHART_SHOW_GRID,true);   ChartSetInteger(0,CHART_SHOW_PERIOD_SEP,true);
  ChartSetInteger(0,CHART_COLOR_BACKGROUND,clrMidnightBlue);
  ChartSetInteger(0, CHART_SCALE, 0, Period() > PERIOD_M15? 5: Period() > PERIOD_M5? 4: 3);  // revoir les autres
#ifdef v_opfx
            GlobalVariableSet("_RateOC1", false);        GlobalVariableSet("_RateOC2", false);
            GlobalVariableSet("_RateOC3", true);         GlobalVariableSet("_RateOC4", false);
            GlobalVariableSet("_H_A_Opt", false);        GlobalVariableSet("_Op_Liqu", true);
            GlobalVariableSet("_op_HiLo", true);         GlobalVariableSet("_op_30p1", true);
            GlobalVariableSet("_op_20p1", true);         GlobalVariableSet("_op_20p2", true);
            GlobalVariableSet("_op_Exp",  false);        GlobalVariableSet("_Op_OHL",  true);
            GlobalVariableSet("_op_20p5", true);         GlobalVariableSet("_op_20p3", true);
            GlobalVariableSet("_op_20p4", true);         GlobalVariableSet("_op_30p2", true);
            GlobalVariableSet("_op_75p1", true);         GlobalVariableSet("_op_Exp1", false);
            GlobalVariableSet("_op_HiLo1", true);        GlobalVariableSet("_op_20p6", true);
            GlobalVariableSet("_op_Exp2", false);        GlobalVariableSet("_op_HiLo2", true);
            GlobalVariableSet("_op_20p7", true);         GlobalVariableSet("_Op_Liq2", false);
            GlobalVariableSet("_Op_Liq3", false);        GlobalVariableSet("_Op_Liq4", false);
            GlobalVariableSet("_op_HAp1", false);        GlobalVariableSet("_op_HAp2", false);
            GlobalVariableSet("_op_HAp3", false);        GlobalVariableSet("_H_A_Buff", false);
            GlobalVariableSet("_H_A_Prev", false);       GlobalVariableSet("_Op_2xBl", false);
            GlobalVariableSet("_Op_Case01", true);       GlobalVariableSet("_Op_Case02", false);
            GlobalVariableSet("_Op_Case03", false);      GlobalVariableSet("_Op_Case11", true);
            GlobalVariableSet("_Op_Case12", false);      GlobalVariableSet("_Op_Case13", false);
            GlobalVariableSet("_Op_Case21", true);       GlobalVariableSet("_Op_Case22", false);
            GlobalVariableSet("_Op_Case23", false);      GlobalVariableSet("_Op_Case24", false);
            GlobalVariableSet("_Op_Case25", false);      GlobalVariableSet("_Op_Case26", false);
#endif

//  if (GlobalVariableCheck("Op_OHL")) Op_OHL = GlobalVariableGet("Op_OHL");
  if (GlobalVariableCheck("Op_Show")) Op_Show = GlobalVariableGet("Op_Show");
  if (GlobalVariableCheck("Op_DDw")) Op_DDw = GlobalVariableGet("Op_DDw");
//  if (GlobalVariableCheck("Op_HiLo")) Op_HiLo = GlobalVariableGet("Op_HiLo");
  if (GlobalVariableCheck("frameX")) frameX = GlobalVariableGet("frameX");
  if (GlobalVariableCheck("frameY")) frameY = GlobalVariableGet("frameY");

#ifdef v_opfx_0
  ArrayResize(ExtOpenBuffer, nBars);      ArrayResize(ExtCloseBuffer, nBars);       HA_Buffers(1);
  p_Ver_str = "p-Ver_"+StringSubstr(Symbol(),0,1)+StringSubstr(Symbol(),3,1)+IntegerToString(StringLen(Symbol()));
  int p_version=GlobalVariableGet(p_Ver_str);      if (! GlobalVariableCheck(p_Ver_str) || f_Params(0) > p_version) f_Params(1);
  if (Hour() == H1 && ! Minute() && Seconds() < 17) { Alert("***** Heure NON PERMISE ! -> REDEMARRER *****");     Sleep(7000); }
  t_night = ((! Hour() || (Hour() < H1 && (H1 < H3 || Hour() > H3))) && (H1 < H3 || DayOfWeek()));       // 6
  tr_allow = TerminalInfoInteger(TERMINAL_TRADE_ALLOWED) && ! t_night;
  tck_vstr = "tck_"+StringSubstr(Symbol(),0,1)+StringSubstr(Symbol(),3,1)+IntegerToString(StringLen(Symbol()));   //+"_"+IntegerToString(Period());
  bull_str = "bullish_"+StringSubstr(Symbol(),0,1)+StringSubstr(Symbol(),3,1)+IntegerToString(StringLen(Symbol()));
  if (GlobalVariableCheck(tck_vstr)) ticket = GlobalVariableGet(tck_vstr);
  if (GlobalVariableCheck(bull_str)) bull_ = GlobalVariableGet(bull_str);           bool t_tick=(ticket > 7);
  if ((GlobalVariableCheck(tck_vstr) && (tr_allow || t_tick)) || (GlobalVariableCheck("Ticket0") && !tr_allow)) {
      if (! t_tick) ticket = tr_allow ? GlobalVariableGet(tck_vstr) : GlobalVariableGet("Ticket0");
      if (tr_allow || t_tick) { if (ticket <= 7) {
#else
  if (GlobalVariableCheck("Bullish")) bull_ = GlobalVariableGet("Bullish");
  if ((GlobalVariableCheck(tck_vstr) && tr_allow) || (GlobalVariableCheck("Ticket0") && !tr_allow)) {
      ticket = tr_allow ? GlobalVariableGet(tck_vstr) : GlobalVariableGet("Ticket0");
      if (tr_allow) { if (ticket <= 7) {
#endif
         if (mOrderSelect(mOrdersTotal(magic_nb)==1?0:2,SELECT_BY_POS)) ticket = OrderTicket();
         Print("*** -> (1) Ticket LOADED! ",ticket," - ... ***");#ifdef v_opfx_0    GlobalVariableSet(tck_vstr, ticket);#endif }
      if (OrderSelect(floor(ticket), SELECT_BY_TICKET) && !OrderCloseTime()) {
         endbull = ! OrderType();
         Print("*** -> (1) Ticket LOADED! ",ticket," - ",endbull? "Buy": "Sell"," - ",tr_allow," ***"); }
      else { Print("*** -> (1a) Ticket NOT LOADED! ",ticket," ***");     ticket = 0; } }
     else   endbull = bull_; }
  else Print("*** -> (1b) Ticket NOT LOADED! ",ticket," ***");

  BrokerDigitAdjust(Symbol());   pass1 = true;  pass1b = true;    NR = 0;
  CreateButton(0,0,"<>",1,frameX-18,frameY+1,0);
  CreateButton(0,0,"Show-EA",0,frameX,frameY,0);

  tmfr = Period();
  stmfr = tmfr==PERIOD_M1? "M1": tmfr==PERIOD_M5? "M5": tmfr==PERIOD_M15? "M15": tmfr==PERIOD_M30? "M30": 
      tmfr==PERIOD_H1? "H1": tmfr==PERIOD_H4? "H4": tmfr==PERIOD_D1? "D1": tmfr==PERIOD_W1? "W1": "MN1";
#ifdef v_opfx

  if (GlobalVariableCheck("_Op_HiLo")) Op_HiLo = GlobalVariableGet("_Op_HiLo");
  if (GlobalVariableCheck("_RateOC1")) rate1c = GlobalVariableGet("_RateOC1");
  if (! rate1c) { if (GlobalVariableCheck("_RateOC2")) rate2c = GlobalVariableGet("_RateOC2");
  if (! rate2c) { if (GlobalVariableCheck("_RateOC3")) rate3c = GlobalVariableGet("_RateOC3");
  if (! rate3c) if (GlobalVariableCheck("_RateOC4")) rate4c = GlobalVariableGet("_RateOC4"); } }
#endif
#ifdef v_opfx_0

  EA_cht_str = "EA_cht_"+StringSubstr(Symbol(),0,1)+StringSubstr(Symbol(),3,1)+IntegerToString(StringLen(Symbol()));
  EA_Ch2_str = "EA_Ch2_"+StringSubstr(Symbol(),0,1)+StringSubstr(Symbol(),3,1)+IntegerToString(StringLen(Symbol()));
  EA_Ch3_str = "EA_Ch3_"+StringSubstr(Symbol(),0,1)+StringSubstr(Symbol(),3,1)+IntegerToString(StringLen(Symbol()));
  t_ATS_str = "t-ATS_"+StringSubstr(Symbol(),0,1)+StringSubstr(Symbol(),3,1)+IntegerToString(StringLen(Symbol()));
  tmfr0_str = "tmfr0_"+StringSubstr(Symbol(),0,1)+StringSubstr(Symbol(),3,1)+IntegerToString(StringLen(Symbol()));      //+"_"+IntegerToString(Period());
  tmfr1_str = "tmfr1_"+StringSubstr(Symbol(),0,1)+StringSubstr(Symbol(),3,1)+IntegerToString(StringLen(Symbol()));      //+"_"+IntegerToString(Period());
  tmfr2_str = "tmfr2_"+StringSubstr(Symbol(),0,1)+StringSubstr(Symbol(),3,1)+IntegerToString(StringLen(Symbol()));      //+"_"+IntegerToString(Period());
  l_rct_str = "l_rct_"+StringSubstr(Symbol(),0,1)+StringSubstr(Symbol(),3,1)+IntegerToString(StringLen(Symbol()));      //+"_"+IntegerToString(Period());
  i_Cht_str = "t-Cht_"+StringSubstr(Symbol(),0,1)+StringSubstr(Symbol(),3,1)+IntegerToString(StringLen(Symbol()));      //+"_"+IntegerToString(Period());
  Chart_str = "Chart_"+StringSubstr(Symbol(),0,1)+StringSubstr(Symbol(),3,1)+IntegerToString(StringLen(Symbol()));      //+"_"+IntegerToString(Period());
  t1_Chart_str = "t1_Chrt_"+StringSubstr(Symbol(),0,1)+StringSubstr(Symbol(),3,1)+IntegerToString(StringLen(Symbol())); //+"_"+IntegerToString(Period());
  t2_Chart_str = "t2_Chrt_"+StringSubstr(Symbol(),0,1)+StringSubstr(Symbol(),3,1)+IntegerToString(StringLen(Symbol())); //+"_"+IntegerToString(Period());
  t1_Bull_str = "t1_Bull_"+StringSubstr(Symbol(),0,1)+StringSubstr(Symbol(),3,1)+IntegerToString(StringLen(Symbol()));  //+"_"+IntegerToString(Period());
  t2_Bull_str = "t2_Bull_"+StringSubstr(Symbol(),0,1)+StringSubstr(Symbol(),3,1)+IntegerToString(StringLen(Symbol()));  //+"_"+IntegerToString(Period());
  t3_Bull_str = "t3_Bull_"+StringSubstr(Symbol(),0,1)+StringSubstr(Symbol(),3,1)+IntegerToString(StringLen(Symbol()));  //+"_"+IntegerToString(Period());
  t4_Bull_str = "t4_Bull_"+StringSubstr(Symbol(),0,1)+StringSubstr(Symbol(),3,1)+IntegerToString(StringLen(Symbol()));  //+"_"+IntegerToString(Period());
  if (GlobalVariableCheck(l_rct_str)) last_rct_ = GlobalVariableGet(l_rct_str);
  if (GlobalVariableCheck(tmfr0_str)) tmfr = GlobalVariableGet(tmfr0_str);
  if (GlobalVariableCheck(tmfr1_str)) tmfr_ = GlobalVariableGet(tmfr1_str);
  if (GlobalVariableCheck(tmfr2_str)) tmfr_b = GlobalVariableGet(tmfr2_str);
  if (GlobalVariableCheck(Chart_str)) Chart_M5 = GlobalVariableGet(Chart_str);
  if (GlobalVariableCheck(t1_Chart_str)) tim_Chart_M5 = GlobalVariableGet(t1_Chart_str);
  if (GlobalVariableCheck(t2_Chart_str)) tim_Chart_M5b = GlobalVariableGet(t2_Chart_str);
  if (GlobalVariableCheck(t1_Bull_str)) t5a_Bullish = GlobalVariableGet(t1_Bull_str);
  if (GlobalVariableCheck(t2_Bull_str)) t5b_Bullish = GlobalVariableGet(t2_Bull_str);
  if (GlobalVariableCheck(t3_Bull_str)) t5a_Bull_b = GlobalVariableGet(t3_Bull_str);
  if (GlobalVariableCheck(t4_Bull_str)) t5b_Bull_b = GlobalVariableGet(t4_Bull_str);
  if (! Chart_M5 || ! chk_chartm5(0)) Chart_M5 = chart_find();    // (Period() == PERIOD_H1 || Period() == PERIOD_M30) && 
  else Alert("** Initialisation OK avec : " + Symbol() + " / " + IntegerToString(Period()) + " (Chart_M5=" + IntegerToString(Chart_M5) + " - " +
      IntegerToString(ChartPeriod(Chart_M5))+" / "+IntegerToString(ChartPeriod(Chart_M5+1))+" / "+IntegerToString(ChartPeriod(Chart_M5-1))+") **");
  if (Hour()>=HOp && tmfr != Period()) { ChartSetSymbolPeriod(0, NULL, ENUM_TIMEFRAMES(tmfr));      Sleep(50);
      copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+" "+Symbol()+": ** Initial. OK1 "+IntegerToString(ChartPeriod(Chart_M5))+" - "+IntegerToString(Chart_M5)+" **");
      if (ENUM_TIMEFRAMES(tmfr) >= PERIOD_M30) { ChartSetInteger(0, CHART_SCALE, 0, 5);
//         Alert("** Initial. OK "+IntegerToString(ChartPeriod(Chart_M5))+" - "+IntegerToString(Chart_M5)+" **");
         ChartSetSymbolPeriod(Chart_M5, NULL, PERIOD_M5);      ChartSetInteger(Chart_M5, CHART_SCALE, 0, 4);
         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+" "+Symbol()+": ** Initial. OK2 "+IntegerToString(ChartPeriod(Chart_M5))+" - "+IntegerToString(Chart_M5)+" **"); }
      else { ChartSetInteger(0, CHART_SCALE, 0, 4);      ChartSetInteger(Chart_M5, CHART_SCALE, 0, 5);
         if (tmfr == PERIOD_M1) ChartSetSymbolPeriod(Chart_M5, NULL, PERIOD_M5);       // v M1
         if (tmfr == PERIOD_M5) ChartSetSymbolPeriod(Chart_M5, NULL, ENUM_TIMEFRAMES(tmfr_));
         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+" "+Symbol()+": ** Initial. OK3 "+IntegerToString(ChartPeriod(Chart_M5))+" - "+IntegerToString(Chart_M5)+" **"); } }

  if (GlobalVariableCheck("t_ngt_3")) t_ngt0 = GlobalVariableGet("t_ngt_3");
  if (GlobalVariableCheck("t_ngt_2") && Symbol() == "CHINAA50") t_ngt0 = GlobalVariableGet("t_ngt_2");
  GlobalVariableSet(EA_Ch2_str, ChartID());     GlobalVariableSet(EA_cht_str, Time[0]);      GlobalVariableSet(EA_Ch3_str, TimeCurrent());
  double vScale=(WindowPriceMax()-WindowPriceMin())/(!WindowPriceMax()?1.154:WindowPriceMax())/1.154/(1.154-1.061);
  nb_ticks = 0;         nb_tcks_N = 0;          if (WM == WindowPriceMax()) ObjectsPositions(vScale);
#ifdef v_dump_1
  int nLines=0, handle=FileOpen("EA-write-file_List v-TmFr.csv", FILE_CSV|FILE_READ, ';'), v_bar=WindowFirstVisibleBar();
  string line;    if (handle != INVALID_HANDLE) { while(true) { line = "";    line = FileReadString(handle);
         if (FileIsLineEnding(handle) && StringLen(line)) nLines ++;    if (FileIsEnding(handle)) break; }  nLines ++;
      FileClose(handle);      Print("***** File contains "+nLines+" line"+(nLines > 1? "s": "")+" *****"); }
   else Alert("*** (1) File EA-write-file_List v-TmFr.csv not found, the last error is ", GetLastError() + " ***");
  ArrayResize(line_read, nLines, 1);                  int row=0, col=0;
  if (nLines) { copy_file_(5, ";");       CSV_FILE_READ();          FileDelete("EA-write-file_List v-TmFr.csv", 0); }
  while(row < nLines) { if (line_read[row-1][col+2] != line_read[row][col+2] || (! StrToInteger(line_read[row][col+3]) && line_read[row-1][col+3] != Period()))
//if (! StrToInteger(line_read[row][col+3]) && line_read[row-1][col+3] != Period()) Alert("***** "+line_read[row-1][col+3]+" - "+Period()+" *****");
      if (StrToInteger(line_read[row][col+2]) && (StrToInteger(line_read[row-1][col+3])!=StrToInteger(line_read[row][col+3]) || !StrToInteger(line_read[row-1][col+2])))
         CreateVLine(line_read[row][col+2], line_read[row+1][col+3] != ""? line_read[row+1][col+3]: Period());
      while(v_bar > iBarShift(NULL, 0, line_read[row][col+2], false)) { CreateObText(StrToInteger(line_read[row-1][col+3])? 
            StrToInteger(line_read[row-1][col+3]): -1, WindowPriceMax()+ 50*vScale*Point, v_bar, 0, "_");         v_bar --; }       row ++; }
  while(v_bar >= 0) { CreateObText(Period(), WindowPriceMax()+ 50*vScale*Point, v_bar, 0, "_");             v_bar --; }
  row = 0;     col = 0;    string temp;      while(row < nLines) {
  if (line_read[row][col+1] != NULL && line_read[row][col+2] > Time[0] - nBars * 3600)
      temp += (temp != NULL? "\r\n": "") + line_read[row][col] + ";" + line_read[row][col+1] + ";" + line_read[row][col+2] + ";" + line_read[row][col+3];
   row ++; }               if (nLines) copy_file_(5, temp);
#endif#endif
#ifdef scrShot2web
 smode="unknown";
 if (UseCustomPeriod) {
  if (CustomPeriodMode == 1) smode = DoubleToStr(CustomPeriod,2)+" days (chart tf:"+TFtoStr(Period())+")";
  if (CustomPeriodMode == 2) smode = DoubleToStr(CustomPeriod,2)+" hours (chart tf:"+TFtoStr(Period())+")";
  if (CustomPeriodMode == 3) smode = DoubleToStr(CustomPeriod,2)+" minutes (chart tf:"+TFtoStr(Period())+")";
  if (CustomPeriodMode == 4) smode = DoubleToStr(CustomPeriod,2)+" bars (chart tf:"+TFtoStr(Period())+")";
 }
 else if (! UseCustomPeriod) smode = "new bar on tf:"+TFtoStr(timeframe);
 Comment("ScreenShot2webspace EA v1.1, © 2014, fxdaytrader, http://ForexBaron.net -> action will take place every "+smode);
#endif
  return; }

void OnTick() { if (ea_show) { ObjectsDelete(0, ""#ifdef v_opfx_0, 0, 0#endif);
     if (GlobalVariableCheck("frameX")) frameX = GlobalVariableGet("frameX");
     CreateButton(0,0,"<>",1,frameX-18,frameY+1,0);     CreateButton(0,0,"Show-EA",0,frameX,frameY,0); }

#ifndef v_opfx
  if (GlobalVariableCheck("Op_HiLo")) Op_HiLo = GlobalVariableGet("Op_HiLo");
  if (GlobalVariableCheck("RateOC1")) rate1c = GlobalVariableGet("RateOC1");
  if (! rate1c) { if (GlobalVariableCheck("RateOC2")) rate2c = GlobalVariableGet("RateOC2");
  if (! rate2c) { if (GlobalVariableCheck("RateOC3")) rate3c = GlobalVariableGet("RateOC3");
  if (! rate3c) if (GlobalVariableCheck("RateOC4")) rate4c = GlobalVariableGet("RateOC4"); } }
#else
  if (prevMinute != Minute()) { r_coptime = copy_time("");
      prevMinute = Minute();        prevSecondTick = GetTickCount(); }

  if (TimeCurrent() % (PERIOD_H1*60) < 3 && Period()==PERIOD_H1 && DCC_Check()) { tmfr = PERIOD_M30;
      ChartSetSymbolPeriod(0, NULL, PERIOD_M30);         GlobalVariableSet(tmfr0_str, tmfr);
      copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+" "+Symbol()+": ***** PASSAGE EN M30 ! ("+str_DCC+") *****");
      Alert("***** PASSAGE EN M30 ! ("+str_DCC+") *****");        tmf_Diff = true; }

  if (! DayOfWeek() || (DayOfWeek()==1 && H1 < H3 && Hour() < H1-1) && Period() > PERIOD_M15) return;    // 5
#endif
#ifdef v_opfx_0 #ifdef supertrend
  if (((! (Minute() % 5) && Seconds() < 20) || (! ((Minute() + 1) % 5) && (Minute() + 1) * 60 - TimeCurrent() < 20 &&
   (Minute() + 1) * 60 > TimeCurrent())) && (! t_suptr || sectrend > Seconds())) { t_suptr = true;       sectrend = Seconds();
Alert("******* DrawArrow_HA() Minute() - " + Minute() + " - " + Seconds() + " *******");
      if (iCustom(NULL, 0, "SuperTrend_.ex4", 10, 4.0, 0, 0) != 2147483647) DrawArrow_HA(iCustom(NULL, 0, "SuperTrend_.ex4", 10, 4.0, 0, 0), 0, 159, -1);
      if (iCustom(NULL, 0, "SuperTrend_.ex4", 10, 4.0, 1, 0) != 2147483647) DrawArrow_HA(iCustom(NULL, 0, "SuperTrend_.ex4", 10, 4.0, 1, 0), 0, 159, -1);
      if (iCustom(NULL, 0, "super-trend_.ex4", 10, 4.5, 0, 0) != 2147483647) DrawArrow_HA((sup_trend=iCustom(NULL, 0, "super-trend_.ex4", 10, 4.5, 0, 0)), 0, 159, 1);
      if (iCustom(NULL, 0, "super-trend_.ex4", 10, 4.5, 1, 0) != 2147483647) DrawArrow_HA((sup_trend=iCustom(NULL, 0, "super-trend_.ex4", 10, 4.5, 1, 0)), 0, 159, 0);
      if (iCustom(NULL, 0, "super-trend_.ex4", 10, 4.5, 0, 0) == 2147483647 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.5, 1, 0) == 2147483647)
         if (sup_trend < Bid) DrawArrow_HA(sup_trend, 0, 159, 1);       else  DrawArrow_HA(sup_trend, 0, 159, 0); }
  if (Minute() % 5 > 1) t_suptr = false;#endif

  bool EA_cht_W;                       //if (Hour() < 5 && DayOfWeek() == 1) return;
  if (prevMinut2 != Minute() && Seconds() > 2 && GlobalVariableCheck(EA_cht_str)) {
      GlobalVariableSet(EA_Ch2_str, ChartID());
      if (! MQLInfoInteger(MQL_DLLS_ALLOWED)) GlobalVariableSet(EA_cht_str, 20);
      else { EA_cht_W = GlobalVariableGet(EA_cht_str);
         if (EA_cht_W) { GlobalVariableSet(EA_cht_str, 0);
            GlobalVariableSet(EA_Ch3_str, TimeCurrent());      prevMinut2 = Minute(); }
         if (GlobalVariableCheck("t_ngt_3")) t_ngt0 = GlobalVariableGet("t_ngt_3"); } }

  string str, temp;
  if (pass1b && GlobalVariableCheck("Enable_EA") && GlobalVariableGet("Enable_EA")) GlobalVariableSet("Enable_EA", 0.0);
  if (! MQLInfoInteger(MQL_DLLS_ALLOWED) && (! GlobalVariableCheck("Enable_DLL") || GlobalVariableGet("Enable_DLL") == 0.0)) {
      str = TimeToStr(Time[0], TIME_MINUTES);         Sleep(100);                // ResetLastError();
      GlobalVariableSet(EA_cht_str, 20);        GlobalVariableSet("Enable_DLL", 1.0);        GlobalVariableSet("Enable_DLL_mgn", Mg_N);
//      Enable_EA("", 0, 1);             FileMove("EA_Enabled.txt", FILE_COMMON, "EA_Not_Enabled.txt", FILE_COMMON);
      StringReplace(str, ":", "");     ChartSaveTemplate(0,"templates saved EA\\template_saved_"+StringSubstr(Symbol(),0,6)+" - "+str); }
/*      if (ChartApplyTemplate(0, "template_saved_"+StringSubstr(Symbol(), 0, 6))) { //GlobalVariableSet(EA_cht_str, 15.0);
         temp = "** EA -> ChartApplyTemplate OK: -> template_saved_" + StringSubstr(Symbol(), 0, 6) + " **";         Sleep(1000); }
      else temp = "***** EA -> ChartApplyTemplate failed error: "+GetLastError()+" - "+Symbol()+" - "+IntegerToString(ChartID())+" *****";
      Alert(temp);      copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp); } */
  if (! MQLInfoInteger(MQL_DLLS_ALLOWED) || (! MQLInfoInteger(MQL_TRADE_ALLOWED) && TerminalInfoInteger(TERMINAL_TRADE_ALLOWED))) {
      if (Enable_EA("temp EA "+Symbol()+".set", 1, 0)) temp = "***** "+Symbol()+" - Toggle Expert Advisor button ON *****";
      else     temp = "***** "+Symbol()+" - Toggle Expert Advisor button OFF *****";
      Alert(temp);      copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp);
      if (MQLInfoInteger(MQL_DLLS_ALLOWED)) return; }
  else if (Mg_N != round(magic_nb / 100000)) { if (Enable_EA("temp EA "+Symbol()+".set", 0, 0))
         temp = "***** "+Symbol()+" - Mg_N != round(magic_nb / 100000) -> OK *****";
      else     temp = "***** "+Symbol()+" - Error: Mg_N != round(magic_nb / 100000) *****";
      Alert(temp);      copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp);
      if (MQLInfoInteger(MQL_DLLS_ALLOWED)) return; }
  else if (GlobalVariableGet("Enable_DLL_mgn") == Mg_N && GlobalVariableGet("Enable_DLL") == 1.0) {
      GlobalVariableSet("Enable_DLL", 0.0);           GlobalVariableSet("Enable_DLL_mgn", 0.0); }
  if (MQLInfoInteger(MQL_DLLS_ALLOWED) && FileIsExist("EA_Not_Enabled.txt", 0)) FileMove("EA_Not_Enabled.txt", 0, "EA_Enabled.txt", 0);

  if (pass1b) chk_chartm5(1);     if (StringTrimLeft(ChartSymbol(Chart_M5)) == "" || ! int(Chart_M5)) {   //Sleep(1000);
      if (tim_Alt_M5 < Time[0]) if (! int(Chart_M5)) Alert("*** CHART M5 ABSENT ! "+Symbol()+" - "+IntegerToString(Chart_M5)+" ***");
         else Print("** PAS D'ACCES AU CHART M5 ! "+Symbol()+" - "+IntegerToString(Chart_M5)+" **");         tim_Alt_M5 = Time[0];
      if ((! int(Chart_M5) || ! chk_chartm5(2)) && (Period()==PERIOD_H1 || Period()==PERIOD_M30 || pass1b)) Chart_M5 = chart_find();
      if (pass1b) { datetime t_L_Objs7;      if (int(StringSubstr(TimeToStr((t_L_Objs7=tim_L_Objs7(Chart_M5)), TIME_MINUTES), 0, 2)) < 6)
            t_L_Objs7 = StrToTime(IntegerToString(Year())+"."+IntegerToString(Month())+"."+IntegerToString(Day())+" 00:00");
         if (! int(tim_Chart_M5) && (Period() == PERIOD_M5 || Period() == PERIOD_M15)) {
            tmfr_ = PERIOD_H1;         GlobalVariableSet(tmfr1_str, tmfr_);
            tim_Chart_M5 = Chart_M5 > 0? t_L_Objs7: TimeCurrent()-8*3600;     GlobalVariableSet(t1_Chart_str, tim_Chart_M5); }
         if (! int(tim_Chart_M5b) && Period() == PERIOD_M1) {
            tmfr_b = PERIOD_M5;        GlobalVariableSet(tmfr2_str, tmfr_b);
            tim_Chart_M5b = Chart_M5 > 0? t_L_Objs7: TimeCurrent()-8*3600;    GlobalVariableSet(t2_Chart_str, tim_Chart_M5b); } } }

  str = "-" + StringSubstr(EnumToString(magic_nb), 0, 3);
  if (!FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0) && !FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Sell.txt", 0))
      FileCopy("ATS-Ind_On-Off\\ATS-Ind5_Sell.txt", 0, "ATS-Ind_On-Off\\ATS-Ind5"+str+"_Sell.txt", 0);
  bool tst, tst2, t_night_, tr_allow_;          int t=0, t1=0, t2=0, err;            // 6
  if (Hour() < H1 && (H1 < H3 || Hour() > H3) && t_h6) { t_h6 = false;  t_ngt0 = false;   GlobalVariableSet("t_ngt_1", 0);    H3 = H3_; }
  else if (Hour() == H1 && (H1 < H3 || DayOfWeek() < 5)) { if (! time_allow) { time_allow = true;     nb_ticks = 0;     nb_tcks_N = 0; }
      t_M5_M15 = false;    t_M15_H1 = false;    if (H1 > H3 && GlobalVariableCheck("t_ngt_2") && str == "-CHN") t_ngt0 = GlobalVariableGet("t_ngt_2"); }
  if (H1 > H3 && (t_night_ != t_night || tr_allow_ != tr_allow)) { t_night_ = t_night;       tr_allow_ = tr_allow; }
  t_night = t_ngt0 || (((H1 < H3 && diff && Hour() == H3 && Minute() > diff) || ! Hour() || (DayOfWeek() == 5 && ((Hour() == 16 && 
      Minute() > 39) || Hour() > 16)) || (Hour() < H1 && (H1 < H3 || Hour() >= H3)) || (!t_h6 && !t_ngt0 && Hour() == H1 && ((H1 < H3 && ! Minute() && 
      Seconds() < 17) || (H1 > H3 && Hour() == H1 && (Minute() < 40 || (Minute() == 40 && Seconds() < 17)))))) && (H1 < H3 || DayOfWeek()));    // 6
/* Print("***** ",t_night," ",t_ngt0," ",((! Hour() || (Hour() < H1 && (H1 < H3 || Hour() >= H3)) || (!t_h6 && !t_ngt0 && Hour() == H1 && ((H1 < H3 && ! Minute() && Seconds() < 17) ||
      (H1 > H3 && (Minute() < 40 || (Minute() == 40 && Seconds() < 17)))))) && (H1 < H3 || DayOfWeek()))," ",
      (! Hour() || (Hour() < H1 && (H1 < H3 || Hour() >= H3)) || (!t_h6 && !t_ngt0 && Hour() == H1 && ((H1 < H3 && ! Minute() && Seconds() < 17) ||
      (H1 > H3 && (Minute() < 40 || (Minute() == 40 && Seconds() < 17))))))," ",
      (! Hour())," ",(Hour() < H1 && (H1 < H3 || Hour() >= H3))," ",(!t_h6 && !t_ngt0 && Hour() == H1 && ((H1 < H3 && ! Minute() && Seconds() < 17) ||
      (H1 > H3 && (Minute() < 40 || (Minute() == 40 && Seconds() < 17)))))," ",t_h6," ",t_ngt0," ",
      ((H1 < H3 && ! Minute() && Seconds() < 17) || (H1 > H3 && (Minute() < 40 || (Minute() == 40 && Seconds() < 17))))," ",
      (H1 < H3 && ! Minute() && Seconds() < 17)," ",(H1 > H3 && (Minute() < 40 || (Minute() == 40 && Seconds() < 17)))," "," *****"); //    f_End_EA(); */
  if (H1 > H3 && t_night != t_night_) Print("** Suivi de t_night et tr_allow (1) : "+Symbol()+" / "+IntegerToString(Period())+" - t_night = "+t_night+" - tr_allow = "+tr_allow+" **");
#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(1) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +     //      case 1:
Hour()+" | "+H1+" | "+H3+" | "+HOp+" | "+str+" | "+Seconds()+" | "+last_rct_+" | "+Time[0]+" | "+Period()+" | "+t_M5_M15+" | "+t_M15_H1+" | "+tmfr_+" | "+tmfr +" | "+t1+" | "+err+" | "+
t2+" | - | "+Chart_M5+" | "+(Chart_M5?"-":chk_chartm5(3))+" | "+tim_Chart_M5+" | "+bull_+" | "+t5a_Bullish+" | "+t5b_Bullish+" | "+FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0)+" | "+t_night; #endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
  if (((! Hour() && H1 < H3) || Hour() < HOp || (Hour() >= H1 && H1 > H3 && (str != "-CHN" || Seconds() > 4)) || (last_rct_==Time[0] && Period()>=PERIOD_M30)) &&
   ((Period() >= PERIOD_M15 || (str == "-HKG" && Period() >= PERIOD_M5)) && ! t_M5_M15 && ! t_M15_H1)) { tmfr_ = Period()==PERIOD_M30? Period(): PERIOD_H1;
      while(! (tst=ChartSetSymbolPeriod(0, NULL, str=="-HKG"?PERIOD_M1:PERIOD_M5)) && t1 < 17) { t1 ++;     Sleep(100); }     err = GetLastError();
      if (tst) { //while((! Chart_M5 || ! int(ChartPeriod(Chart_M5))) && t2 < 17) { t2 ++;     Chart_M5 = chart_find();   Sleep(100); }
         if (! chk_chartm5(3)) { temp = "*** ERROR Chart_M5 (3) "+IntegerToString(ChartPeriod(Chart_M5))+" - "+IntegerToString(Chart_M5)+" ***";
            Alert(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp); }
         Sleep(50);      ChartSetInteger(0, CHART_SCALE, 0, 3);             tmfr = str == "-HKG"? PERIOD_M1: PERIOD_M5;
         while(! ChartSetSymbolPeriod(Chart_M5, NULL, ENUM_TIMEFRAMES(tmfr_)) && t2 < 17) { t2 ++;    Sleep(100); }
         Sleep(50);            /* ChartSetInteger(Chart_M5, CHART_SCALE, 0, 5); */         int err2 = GetLastError();
         tim_Chart_M5 = TimeCurrent();       GlobalVariableSet(t1_Chart_str, tim_Chart_M5);
         t5a_Bullish = bull_;                t5b_Bullish = FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0);
         GlobalVariableSet(t1_Bull_str, t5a_Bullish);    GlobalVariableSet(t2_Bull_str, t5b_Bullish);
         GlobalVariableSet(tmfr1_str, tmfr_);            GlobalVariableSet(tmfr0_str, tmfr); }     if (last_rct_ < Time[0] && H1 > H3) t_night = true;
      if (tst) { temp = "** Passage en "+(str=="-HKG"?"M1":"M5")+" à "+IntegerToString(fmax(H1,H3))+" H ! (Period()="+IntegerToString(Period())+", t1="+
            IntegerToString(t1) + ", t2=" + IntegerToString(t2) + (t2==17 ? ", err2=" + IntegerToString(err2) : "") + ") *(1)*";
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 1:
Hour()+" | "+H1+" | "+H3+" | "+HOp+" | "+str+" | "+Seconds()+" | "+last_rct_+" | "+Time[0]+" | "+Period()+" | "+t_M5_M15+" | "+t_M15_H1+" | "+tmfr_+" | "+tmfr +" | "+t1+" | "+err+" | "+
t2+" | "+err2+" | "+Chart_M5+" | "+chk_chartm5(3)+" | "+tim_Chart_M5+" | "+bull_+" | "+t5a_Bullish+" | "+t5b_Bullish+" | "+FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0)+" | "+t_night);
copy_file_45(5, "1_;"+TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+";"+IntegerToString(TimeCurrent())+";"+IntegerToString(Period())); #endif
         Print(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp); }
      else { if (Period()>PERIOD_M1) Print("*** Erreur - Passage en M5 à "+IntegerToString(fmax(H1,H3))+" H ! (Period()=" + IntegerToString(Period()) +
         ", t1=" + IntegerToString(t1) + ", err1=" + IntegerToString(err) + ") ***");         Sleep(100); }
      if (last_rct_ == Time[0]) { temp = "***** last_rct_ (1) -> while(! (tst=ChartSetSymbolPeriod(0, && DrawArrow_OS(6, ****(2)*";
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 1:
Hour()+" | "+H1+" | "+H3+" | "+HOp+" | "+str+" | "+Seconds()+" | "+last_rct_+" | "+Time[0]+" | "+Period()+" | "+t_M5_M15+" | "+t_M15_H1+" | "+tmfr_+" | "+tmfr +" | "+t1+" | "+err+" | "+
t2+" | "+err2+" | "+Chart_M5+" | "+chk_chartm5(3)+" | "+tim_Chart_M5+" | "+bull_+" | "+t5a_Bullish+" | "+t5b_Bullish+" | "+FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0)+" | "+t_night);
copy_file_45(5, "2_;"+TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+";"+IntegerToString(TimeCurrent())+";"+IntegerToString(Period())); #endif
            Print(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp); } }
#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(3) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 3:
str+" | "+Hour()+" | "+HOp+" | "+Minute()+" | "+Period()+" | "+t1; #endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
  if (str == "-HKG" && Hour() == HOp && Minute() > 30 && Period() == PERIOD_M1) { t1 = 0;       GlobalVariableSet(tmfr0_str, PERIOD_M5);
      while(! (tst=ChartSetSymbolPeriod(0, NULL, PERIOD_M5)) && t1 < 17) { t1 ++;      Sleep(100); }
      if (tst) { temp = "** Passage en M5 à "+IntegerToString(HOp)+" H ! (Period()="+IntegerToString(Period())+", t1="+IntegerToString(t1)+") *(3)*";
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 3:
str+" | "+Hour()+" | "+HOp+" | "+Minute()+" | "+Period()+" | "+t1);     copy_file_45(5, "3_;"+TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+";"+IntegerToString(TimeCurrent())+";"+IntegerToString(Period()));#endif
         Print(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp); } }

//  while (StringTrimLeft(ChartSymbol(Chart_M5)) == "" && t < 11) { Sleep(200);    t ++; }
#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(4) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 4:
Hour()+" | "+HOp+" | "+Period()+" | "+TimeCurrent()+" | "+tim_Chart_M5+" | "+tmfr_+" | "+m3_RSI(PERIOD_M5, 2)+" | "+tst2+" | "+nb_ticks+" | "+nb_tcks_N+" | "+
Chart_M5+" | "+(Chart_M5?"-":chk_chartm5(4))+" | "+StringTrimLeft(ChartSymbol(Chart_M5))+" | "+bull_+" | "+t5a_Bullish+" | "+t5b_Bullish+" | "+FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0)+" | "+
t1+" | "+err+" | "+tmfr_+" | "+t2+" | "+(Chart_M5?"-":chk_chartm5(5))+" | "+t_M15_H1; #endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
  t = 0;    t1 = 0;     if ((str != "-HKG" && str != "-CHN") || Hour() > 8) while(! tst && t < 17) {
   if ((Hour()>=HOp && (Period()==PERIOD_M5 || Period()==PERIOD_M15) && TimeCurrent() % (PERIOD_M5*60) < 7 && tim_Chart_M5 > 0 && 
   TimeCurrent()-tim_Chart_M5 > tmfr_*60*8 && m3_RSI(PERIOD_M5, 2) > 40 && m3_RSI(PERIOD_M5, 2) < 60) ||
   (tst2 = (Period() == PERIOD_M15 && m3_RSI(0, 2) > 35 && m3_RSI(0, 2) < 65 &&
   nb_ticks > 2 && nb_ticks == nb_tcks_N + 1))) {     // ou tester la présence d'un rectangle ATS
      if (! Chart_M5 && ! chk_chartm5(4)) { temp = "*** ERROR Chart_M5 (4) "+IntegerToString(ChartPeriod(Chart_M5))+" - "+IntegerToString(Chart_M5)+" ***";
         Alert(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp); }
      if ((StringTrimLeft(ChartSymbol(Chart_M5)) != "" && ((t5b_Bullish == FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0) &&
      bull_ == t5a_Bullish) || (t5b_Bullish != FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0) && bull_ != t5b_Bullish))) || tst2) {
         while(! (tst=ChartSetSymbolPeriod(0, NULL, Hour()==HOp && !Minute()? PERIOD_H1: ENUM_TIMEFRAMES(tmfr_))) && t1 < 17) { t1 ++;    Sleep(100); }
         if (Hour() == HOp && ! Minute()) GlobalVariableSet(tmfr0_str, PERIOD_H1);
         err = GetLastError();      if (tst && tmfr_ > 0) { Sleep(50);        ChartSetInteger(0, CHART_SCALE, 0, 5);
//            while((! Chart_M5 || ! int(ChartPeriod(Chart_M5))) && t2 < 17) { t2 ++;    Chart_M5 = chart_find();   Sleep(100); }
            if (! chk_chartm5(5)) { temp = "*** ERROR Chart_M5 (5) "+IntegerToString(ChartPeriod(Chart_M5))+" - "+IntegerToString(Chart_M5)+" ***";
               Alert(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp); }
            t2 = 0;     while(! ChartSetSymbolPeriod(Chart_M5, NULL, PERIOD_M5) && t2 < 17) { t2 ++;      Sleep(100); }
            Sleep(50);            ChartSetInteger(Chart_M5, CHART_SCALE, 0, 4);          t_M15_H1 = true;
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 4:
Hour()+" | "+HOp+" | "+Period()+" | "+TimeCurrent()+" | "+tim_Chart_M5+" | "+tmfr_+" | "+m3_RSI(PERIOD_M5, 2)+" | "+tst2+" | "+nb_ticks+" | "+nb_tcks_N+" | "+
chk_chartm5(4)+" | "+Chart_M5+" | "+StringTrimLeft(ChartSymbol(Chart_M5))+" | "+bull_+" | "+t5a_Bullish+" | "+t5b_Bullish+" | "+FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0)+" | "+
t1+" | "+err+" | "+tmfr_+" | "+t2+" | "+chk_chartm5(5)+" | "+t_M15_H1);    copy_file_45(5, "4_;"+TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+";"+IntegerToString(TimeCurrent())+";"+IntegerToString(Period()));#endif
            temp = "** REPASSAGE EN M30 / H1 ! ("+IntegerToString(tmfr_)+", t5a_Bullish = "+IntegerToString(t5a_Bullish)+", t5b_Bullish = "+IntegerToString(t5b_Bullish)+
               ", t = "+IntegerToString(t)+", t1 = "+IntegerToString(t1)+", t2 = "+IntegerToString(t2)+(t2==17? ", err2 = "+IntegerToString(GetLastError()): "")+") *(4)*";
            Alert(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp);
            tim_Chart_M5 = 0;       GlobalVariableSet(t1_Chart_str, tim_Chart_M5);
            tmfr = tmfr_;           GlobalVariableSet(tmfr0_str, tmfr); }
         else { temp = "*** ERREUR - REPASSAGE EN M30 / H1 ! ("+Symbol()+" - " +(tmfr_?"":"*")+IntegerToString(tmfr_)+(tmfr_?"":"*")+ ", t1 = " +
               IntegerToString(t1) + ", t = " + IntegerToString(t) + ", err1 = " + IntegerToString(err) + ") ***";
            Alert(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp); } } }
   else if (Period()==PERIOD_M1 && TimeCurrent() % (PERIOD_M1*60) < 3 && tim_Chart_M5b > 0 && TimeCurrent()-tim_Chart_M5b > tmfr_b*60 * 4) {
#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(5) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 5:
Period()+" | "+TimeCurrent()+" | "+tim_Chart_M5b+" | "+tmfr_b+" | "+chk_chartm5(6)+" | "+Chart_M5+" | "+StringTrimLeft(ChartSymbol(Chart_M5))+" | "+
str+" | "+bull_+" | "+t5a_Bull_b+" | "+t5b_Bull_b+" | "+FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0)+" | "+t1+" | "+t2+" | "+chk_chartm5(7); #endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
      if (! chk_chartm5(6)) { temp = "*** ERROR Chart_M5 (6) "+IntegerToString(ChartPeriod(Chart_M5))+" - "+IntegerToString(Chart_M5)+" ***";
         Alert(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp); }
      if (StringTrimLeft(ChartSymbol(Chart_M5)) != "" && ((t5b_Bull_b == FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0) &&
      bull_ == t5a_Bull_b) || (t5b_Bull_b != FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0) && bull_ != t5b_Bull_b))) {
         while(! (tst=ChartSetSymbolPeriod(0, NULL, ENUM_TIMEFRAMES(tmfr_b))) && t1 < 17) { t1 ++;       Sleep(100); }     err = GetLastError();
         if (tst && tmfr_b > 0) { Sleep(50);       ChartSetInteger(0, CHART_SCALE, 0, 4);
//            while((! Chart_M5 || ! int(ChartPeriod(Chart_M5))) && t2 < 17) { t2 ++;    Chart_M5 = chart_find();   Sleep(100); }
            if (! chk_chartm5(7)) { temp = "*** ERROR Chart_M5 (7) "+IntegerToString(ChartPeriod(Chart_M5))+" - "+IntegerToString(Chart_M5)+" ***";
               Alert(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp); }
            t2 = 0;     while(! ChartSetSymbolPeriod(Chart_M5, NULL, ENUM_TIMEFRAMES(tmfr_)) && t2 < 17) { t2 ++;       Sleep(100); }
            Sleep(50);            ChartSetInteger(Chart_M5, CHART_SCALE, 0, 5);
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 5:
Period()+" | "+TimeCurrent()+" | "+tim_Chart_M5b+" | "+tmfr_b+" | "+chk_chartm5(6)+" | "+Chart_M5+" | "+StringTrimLeft(ChartSymbol(Chart_M5))+" | "+
str+" | "+bull_+" | "+t5a_Bull_b+" | "+t5b_Bull_b+" | "+FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0)+" | "+t1+" | "+t2+" | "+chk_chartm5(7));
copy_file_45(5, "5_;"+TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+";"+IntegerToString(TimeCurrent())+";"+IntegerToString(Period())); #endif
            temp = "** REPASSAGE EN M5 ! (" + IntegerToString(tmfr_b) + ", t5a_Bull_b = "+IntegerToString(t5a_Bull_b) + ", t5b_Bull_b = "+IntegerToString(t5b_Bull_b) +
               ", t1 = "+IntegerToString(t1) + ", t2 = "+IntegerToString(t2) + (t2==17 ? ", err2 = " + IntegerToString(GetLastError()) : "") + ") *(5)*";
            Alert(temp);            copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp);
            tim_Chart_M5b = 0;      GlobalVariableSet(t2_Chart_str, tim_Chart_M5b);
            tmfr = tmfr_b;          GlobalVariableSet(tmfr0_str, tmfr); }
         else { temp = "*** ERREUR - REPASSAGE EN M5 ! ("+Symbol()+" - " +(tmfr_b?"":"*")+IntegerToString(tmfr_b)+(tmfr_b?"":"*")+ ", t1 = " +
               IntegerToString(t1) + ", t = " + IntegerToString(t) + ", err1 = " + IntegerToString(err) + ") ***";
            Alert(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp); } } }
   else   tst = true;    if (! tst) Sleep(100);    t ++; }
#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(6) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 6:
tst2+" | "+Period()+" | "+m3_RSI(0, 2)+" | "+nb_ticks+" | "+nb_tcks_N; #endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
   if (tst2) { temp = "** Sortie de boucle M30 / H1 ! (" + IntegerToString(tmfr_) + ", t = " + IntegerToString(t) + ", t1 = "+IntegerToString(t1) +
         ", t2 = " + IntegerToString(t2) + (t2 == 17? ", err2 = " + IntegerToString(GetLastError()): "") + ") *(6)*";      tst2 = false;
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 6:
tst2+" | "+Period()+" | "+m3_RSI(0, 2)+" | "+nb_ticks+" | "+nb_tcks_N);  copy_file_45(5, "6_;"+TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+";"+IntegerToString(TimeCurrent())+";"+IntegerToString(Period()));#endif
      Alert(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp); }

  tr_allow = TerminalInfoInteger(TERMINAL_TRADE_ALLOWED) && ! t_night;
  if (H1 > H3 && tr_allow != tr_allow_) Print("** Suivi de t_night et tr_allow (2) : "+Symbol()+" / "+IntegerToString(Period())+" - t_night = "+t_night+" - tr_allow = "+tr_allow+" **");
#endif
  if (GlobalVariableCheck("Show_EA")) ea_show = GlobalVariableGet("Show_EA");
  if (GlobalVariableCheck("Op_Liq2")) Op_Liq2 = GlobalVariableGet("Op_Liq2");
//  if (GlobalVariableCheck("Op_Liq3")) Op_Liq3 = GlobalVariableGet("Op_Liq3");
  if (GlobalVariableCheck("Op_Liq4")) Op_Liq4 = GlobalVariableGet("Op_Liq4");

  bool strTot=(Point==0.01);        double myLot=0.01;
  int obj_total=ObjectsTotal(), i, j, k=0, k_, p=0, exp_1=0, exp_2=0#ifdef v_opfx, MrktVal, HighVal=0, DDwnVal=0, HiLoVal#endif;
  int obj_bar_cl, obj_bar_cl2, obj_bar_cl3, prv_pos=0, total=0, total0, hightotal=0, drawdown=0, ntot, obj_bar_liq[];      //, type
  int obj_bars[], obj_pos[], obj_pos0[], obj_reOps[][2], reOpn_brs[], reClo_brs[];           // obj_prClots[][2]
  string name,name_, obj_liqTypes[], obj_liqTyps2[], obj_liqTyp_1="", obj_liqTyp_2="";
  double drawdwnp,obj_Prices[],obj_prClots[],reOpn_prs[],reClo_prs[],obj_Levels[]#ifdef v_opfx, params[5]#endif#ifdef v_opfx_0,obj_LiqPrs[][2]#endif;
  datetime OTim1, OTim2, obj_Neutrals[];  bool t_neutral=false, t_liquid_b=false, t_liquid_s=false, t_neutral0, t_liquid_b0, t_liquid_s0;
  ArrayResize(obj_bars, obj_total);       ArrayResize(obj_pos, obj_total);       ArrayResize(obj_pos0, obj_total);
  ArrayResize(obj_reOps, obj_total);      ArrayResize(obj_Prices, obj_total);    ArrayResize(obj_prClots, obj_total);
  ArrayResize(obj_Levels, obj_total);     ArrayResize(reOpn_prs, obj_total);     ArrayResize(reClo_prs, obj_total);
  ArrayResize(reOpn_brs, obj_total);      ArrayResize(reClo_brs, obj_total);     ArrayResize(obj_Neutrals, obj_total);
  ArrayResize(obj_liqTypes, obj_total);   ArrayResize(obj_bar_liq, Bars);#ifdef v_opfx_0  ArrayResize(obj_LiqPrs, obj_total)#endif;
  string nam_B, nam_S, str1, str2, nam_B2, nam_S2, nam_B3, nam_S3, nam_B4, nam_S4;
#ifndef v_opfx
  bool bull, haBull, habull, pos_prem=true, lastliq, lastliq_=true;    //, tst
#else
  if (Op_Liq2) ArrayResize(obj_liqTyps2, obj_total);
  bool bull, haBull, pos_prem=true, tst2=false, lastliq, lastliq_=true;
//  if (GlobalVariableCheck("Bullish")) bull_ = GlobalVariableGet("Bullish");
#endif
//  if (GlobalVariableCheck(bull_str)) bull_ = GlobalVariableGet(bull_str);
  if (bull_==NULL && bull_!=false) Print("** TEST mode strict -> (bull_==NULL && bull_!=false) **");

#ifdef v_opfx_0
  if (GlobalVariableCheck(tck_vstr)) ticket = GlobalVariableGet(tck_vstr);      bool t_tick=(ticket > 7);
  if ((ticket <= 7 && (mOrdersTotal(magic_nb)==1 || mOrdersTotal(magic_nb)==3) && tr_allow) ||
  (! tr_allow && ! t_tick && GlobalVariableCheck("Ticket0") && (ticket=GlobalVariableGet("Ticket0")) > 0)) {
   if ((GlobalVariableCheck(tck_vstr) && (tr_allow || t_tick)) || (GlobalVariableCheck("Ticket0") && !tr_allow)) {
      if (! t_tick) ticket = tr_allow ? GlobalVariableGet(tck_vstr) : ticket;
      if (tr_allow || t_tick) { if (ticket <= 7) {
#else
  if ((ticket <= 7 && (mOrdersTotal(magic_nb)==1 || mOrdersTotal(magic_nb)==3) && tr_allow) ||
  (! tr_allow && GlobalVariableCheck("Ticket0") && (ticket=GlobalVariableGet("Ticket0")) > 0)) {
   if ((GlobalVariableCheck(tck_vstr) && tr_allow) || (GlobalVariableCheck("Ticket0") && !tr_allow)) {
      ticket = tr_allow ? GlobalVariableGet(tck_vstr) : ticket;
      if (tr_allow) { if (ticket <= 7) {
#endif
         if (mOrderSelect(mOrdersTotal(magic_nb)==1?0:2,SELECT_BY_POS)) ticket = OrderTicket();#ifdef v_opfx_0    if (prevMinute != Time[0]) {#endif
            Print("*** -> (2) Ticket LOADED! ",ticket," - ... ***");#ifdef v_opfx_0    GlobalVariableSet(tck_vstr, ticket); }#endif }
       if (OrderSelect(floor(ticket), SELECT_BY_TICKET) && !OrderCloseTime()) {
         endbull = ! OrderType();
         Print("*** -> (2) Ticket LOADED! ",ticket," - ",endbull? "Buy": "Sell"," - ",tr_allow," ***"); }
       else Print("*** -> (2a) Ticket NOT LOADED! ",ticket," ***"); }
      else   endbull = bull_; }
   else Print("*** -> (2b) Ticket NOT LOADED! ",ticket," ***"); }
//    confirmer manuellement avec une option par click      | v ou MessageBox()     (+ possiblilité d'inverser bull_)      ***
//  if (! OrdersTotal() && ticket) { Print("** --> Ticket CHANGED! (OnTick) ",ticket," -> 0 ***");      ticket = 0; }      ***
  next_vert = 0;     for (int pos = 0; pos < obj_total; pos ++) {
     OTim2 = 0;      name = ObjectName(pos);       //type = ObjectType(name);
     t_neutral0 = t_neutral;   t_liquid_b0 = t_liquid_b;   t_liquid_s0 = t_liquid_s;   //iTime(NULL,0,0)
#ifdef v_opfx_0
     if (StringFind(name, "ertical") > 0 && ObjectGet(name, OBJPROP_TIME1) > Time[0] && ObjectGet(name, OBJPROP_COLOR) == clrRed && 
         (! int(next_vert) || ObjectGet(name, OBJPROP_TIME1) < next_vert)) next_vert = ObjectGet(name, OBJPROP_TIME1);
     if (StringFind(name, "rect") > 0) { if (ObjectGet(name, OBJPROP_TIME2) == Time[0]) {  // ATS V2.0 Userrect1612950600
            name_ = name;     if (cpt_wav < 2) { PlaySound("0294.wav");       cpt_wav ++; } }
         if (ObjectGet(name_, OBJPROP_TIME2) < Time[1]) cpt_wav = 0; }   //*/
     if (StringFind(name, "rect") > 0) { last_rect = ObjectGet(name, OBJPROP_TIME2);      rect_str = name; }
#endif
     if ((t_neutral=(StringFind(name, "neutral") > 0)) ||
     (t_liquid_b=(StringFind(name, "liquid_buy") > 0)) || (t_liquid_s=(StringFind(name, "liquid_sell") > 0))) {
        if ((! t_neutral0 && t_neutral) || (! t_liquid_b0 && t_liquid_b) || (! t_liquid_s0 && t_liquid_s)) i = 0;
        OTim1 = ObjectGet(name,OBJPROP_TIME1);
        while (OTim1 > OTim2 && i < Bars) { OTim2 = iTime(NULL,0,Bars-(i+1));   i ++; }
// Time[0] = bougie en cours  |  Time[Bars-1] = bougie la plus ancienne du chart
        if (t_neutral) { obj_Neutrals[pos] = OTim1;      obj_bars[pos] = i;     obj_pos[p] = pos;     obj_pos0[p] = pos;
            obj_liqTypes[pos] = (ObjectType((nam_B=StringSubstr(name, 0, (StringSubstr(name,5,1)==2?13:8))+"liquid_buy"+StringSubstr
               (name, StringFind(name, "tral")+4))) > 0 ? "Buy" : (ObjectType((nam_S=StringSubstr(name,0,(StringSubstr(name,5,1)==2?13:8))+
                  "liquid_sell"+StringSubstr(name, StringFind(name, "tral")+4))) > 0 ? "Sell" : "Error"));
            obj_Prices[pos] = (iOpen(NULL,0,Bars-i) * (rate1c? 5.0: rate2c? 4.0: rate3c? 3.0: rate4c? 2.0: 1.0) +
                  iClose(NULL,0,Bars-i) * (rate1c? 1.0: rate2c? 2.0: rate3c? 3.0: rate4c? 4.0: 5.0)) / 6.0;
#ifndef v_opfx_0
            if (ObjectType((nam_B=StringSubstr(name, 0, (StringSubstr(name,5,1)==2?13:8))+"liquid_buy"+StringSubstr(name, 
#else
            if ((Liqu_x2=(ObjectType((nam_B=StringSubstr(name, 0, (StringSubstr(name,5,1)==2?13:8))+"liquid_buy"+StringSubstr(name, 
#endif
               StringFind(name, "tral")+4))) > 0 && ObjectType((nam_S=StringSubstr(name,0,(StringSubstr(name,5,1)==2?13:8))+
               "liquid_sell"+StringSubstr(name, StringFind(name, "tral")+4))) > 0)#ifdef v_opfx_0))#endif { str1 = obj_liqTypes[pos];     str2 = obj_liqTyp_1;
                  if (Op_HiLo) Print("*** -> 2 liquid lines | ",pos," - ",(Bars-i)," - ",obj_Prices[pos]," - ",StringToUpper(str1)," - ",
                     StringToUpper(str2)," - barre : ",TimeToStr(Time[Bars-i],TIME_DATE|TIME_MINUTES)," ***");
                  obj_liqTypes[pos] = Op_Liqu? Op_Liqu==1? obj_liqTyp_1: Op_Liqu==2? obj_liqTyp_1=="Sell"? "Buy": "Sell": //(obj_bars[pos]-obj_bars[pos-1]==1 ||
                  obj_bars[pos]-obj_bars[pos-1]<=2 && obj_liqTyp_1==obj_liqTyp_2? obj_liqTyp_1=="Sell"? "Buy": "Sell": obj_liqTyp_1: "Error-2";
/* Print("****** (1) ", obj_liqTypes[pos], " ", (Bars - i), " ", iClose(NULL,0,Bars-i), " ", Op_Liqu, " ", obj_bars[pos-1], " ", obj_bars[pos], " ", obj_liqTyp_1, " ", obj_liqTyp_2, " ******");
DrawArrow(iClose(NULL,0,Bars-i)+500*Point, Bars-i, 3, obj_liqTypes[pos]=="Buy", 0);
DrawArrow(iClose(NULL,0,Bars-i)+500*Point, Bars-i, 5, obj_liqTypes[pos]=="Buy", 0); //*/
                  if (Bars - i > 1) { tst = false;
                     haBull = (Op_Liqu && HA_Bull(1, iOpen(NULL,0,Bars-i-2), iClose(NULL,0,Bars-i-2), iHigh(NULL,0,Bars-i-2), iLow(NULL,0,Bars-i-2), Bars-i-2, NULL)
                        && Op_Liq3 && HA_Bull(1, iOpen(NULL,0,Bars-i-1), iClose(NULL,0,Bars-i-1), iHigh(NULL,0,Bars-i-1), iLow(NULL,0,Bars-i-1), Bars-i-1, NULL));
                     if (haBull && obj_liqTypes[pos] == "Sell") { obj_liqTypes[pos] = "Buy";      tst = true; }
                     else { haBull = (Op_Liqu && !HA_Bull(1, iOpen(NULL,0,Bars-i-2), iClose(NULL,0,Bars-i-2), iHigh(NULL,0,Bars-i-2), iLow(NULL,0,Bars-i-2), Bars-i-2, NULL)
                           && Op_Liq3 && !HA_Bull(1, iOpen(NULL,0,Bars-i-1), iClose(NULL,0,Bars-i-1), iHigh(NULL,0,Bars-i-1), iLow(NULL,0,Bars-i-1), Bars-i-1, NULL));
                        if (haBull && obj_liqTypes[pos] == "Buy") { obj_liqTypes[pos] = "Sell";      tst = true; } }
                     if (tst) { total0 -= fabs(iClose(NULL,0,Bars-i-2) - obj_Prices[pos]) * 2 + comm; }     //nb_pos ++; }
/* Print("****** (2) ", obj_liqTypes[pos], " ", (Bars - i), " ", iClose(NULL,0,Bars-i), " ", haBull, " ", tst, " ******");
DrawArrow_pf(iClose(NULL,0,Bars-i)+300*Point, Bars-i, 3, obj_liqTypes[pos]=="Buy", 0);
DrawArrow_pf(iClose(NULL,0,Bars-i)+300*Point, Bars-i, 5, obj_liqTypes[pos]=="Buy", 0); //*/
                      } }
            if (Op_Liq2) { str1 = obj_liqTyps2[pos] == NULL? obj_liqTypes[pos] == "Buy"? "Sell": obj_liqTypes[pos] == "Sell"? "Buy": "-": 
                              obj_liqTyps2[pos] == "Buy" ? "Sell" : obj_liqTyps2[pos] == "Sell" ? "Buy" : "-";
               j = 1;      while ((obj_liqTyps2[pos-j]==NULL? obj_liqTypes[pos-j]: obj_liqTyps2[pos-j]) == obj_liqTypes[pos]) j ++;   tst = false;
               if (obj_liqTypes[pos-j] == str1) { tst = true;        temp = ObjectName(pos-j);
                  nam_B2 = StringSubstr(temp, 0, (StringSubstr(temp,5,1)==2?13:8))+"liquid_buy"+StringSubstr(temp, StringFind(temp, "tral")+4);
                  nam_S2 = StringSubstr(temp, 0, (StringSubstr(temp,5,1)==2?13:8)) + "liquid_sell" + StringSubstr(temp, StringFind(temp, "tral") + 4); }
/*if (pos == 57) Print("*1* "+obj_liqTypes[pos]+" - "+obj_liqTypes[pos-1]+" - "+obj_liqTypes[pos-2]+" - "+obj_liqTypes[pos-3]+" - "+obj_liqTypes[pos-j]+" - "+
   IntegerToString(j)+" - "+IntegerToString(Bars-i)+" - "+nam_B2+" - "+nam_S2+" - "+temp+" - "+tst+" - "+DoubleToStr(iLow(NULL,0,Bars-i),5)+" - "+
   DoubleToStr(iHigh(NULL,0,Bars-i),5)+" - "+DoubleToStr(ObjectGet(nam_B2,OBJPROP_PRICE1),5)+" - "+DoubleToStr(ObjectGet(nam_S2,OBJPROP_PRICE1),5)+" ***");//*/
               j ++;       while ((obj_liqTyps2[pos-j]==NULL? obj_liqTypes[pos-j]: obj_liqTyps2[pos-j]) == obj_liqTypes[pos]) j ++;
               if (obj_liqTypes[pos-j] == str1) { tst = true;        temp = ObjectName(pos-j);
                  nam_B3 = StringSubstr(temp, 0, (StringSubstr(temp,5,1)==2?13:8))+"liquid_buy"+StringSubstr(temp, StringFind(temp, "tral")+4);
                  nam_S3 = StringSubstr(temp, 0, (StringSubstr(temp,5,1)==2?13:8)) + "liquid_sell" + StringSubstr(temp, StringFind(temp, "tral") + 4); }
/*if (pos == 57) Print("*2* "+obj_liqTypes[pos]+" - "+obj_liqTypes[pos-j]+" - "+obj_liqTypes[pos-j-1]+" - "+obj_liqTypes[pos-j-2]+" - "+obj_liqTypes[pos-j-3]+" - "+
   IntegerToString(j)+" - "+nam_B3+" - "+nam_S3+" - "+temp+" - "+tst+" - "+DoubleToStr(ObjectGet(nam_B3,OBJPROP_PRICE1),5)+" - "+DoubleToStr(ObjectGet(nam_S3,OBJPROP_PRICE1),5)+" ***");//*/
               j ++;       while ((obj_liqTyps2[pos-j]==NULL? obj_liqTypes[pos-j]: obj_liqTyps2[pos-j]) == obj_liqTypes[pos]) j ++;                 /* voir en option ***
-> avec deux autres options Op_Instit et Op_LiqRange : - Op_Instit pour identifier les liquidity lines proches d'un instit avec une nam_B/S3 proche d'une nam_B/S4, ce qui fera 
   déclancher l'ordre plus proche de l'instit (~ -3 pips) plutôt que dès l'apparition de l'expansion line (ou point) -> voir "Capture d'écran 2021-01-14 à 18.53.59 : 23.20.26.png"
   - Op_LiqRange pour inverser tous les ordersend après une inversion de type Op_Liq2 sur obj_liqTypes[pos], en utilisant un flag_Range plutôt qu'une inversion de la liquidity line ;
   ainsi tous les trades inversés après la liquidity line concernée correspondront à du trading de Range, délimité par la liquidity line supérieure et la liquidity line inférieure
   -> fin du Range sur sortie d'une des deux bornes avec un stop à -10 pips ou après la prochaine liquidity line non inversée par Op_Liq2
   - pour le backtest je peux aussi voir le timeframe inférieur (-1 ou -2) pour voir à quel moment / niveau plus précis est apparue la liquidity line concernée */
               if (obj_liqTypes[pos-j] == str1) { tst = true;        temp = ObjectName(pos-j);
                  nam_B4 = StringSubstr(temp, 0, (StringSubstr(temp,5,1)==2?13:8))+"liquid_buy"+StringSubstr(temp, StringFind(temp, "tral")+4);
                  nam_S4 = StringSubstr(temp, 0, (StringSubstr(temp,5,1)==2?13:8)) + "liquid_sell" + StringSubstr(temp, StringFind(temp, "tral") + 4); } }
/*if (pos == 57) Print("*3* "+obj_liqTypes[pos]+" - "+obj_liqTypes[pos-j]+" - "+obj_liqTypes[pos-j-1]+" - "+obj_liqTypes[pos-j-2]+" - "+obj_liqTypes[pos-j-3]+" - "+
   IntegerToString(j)+" - "+nam_B4+" - "+nam_S4+" - "+temp+" - "+tst+" - "+DoubleToStr(ObjectGet(nam_B4,OBJPROP_PRICE1),5)+" - "+DoubleToStr(ObjectGet(nam_S4,OBJPROP_PRICE1),5)+" ***"); }//*/
/*            if (Op_Liq2 && (fabs(obj_liqTyp_1=="Buy"? iLow(NULL,0,Bars-i): iHigh(NULL,0,Bars-i) - ObjectGet((obj_liqTypes[pos-1]=="Buy"?nam_B2:nam_S2),OBJPROP_PRICE1)) < 100*Point
               || fabs(obj_liqTyp_1=="Buy"? iLow(NULL,0,Bars-i): iHigh(NULL,0,Bars-i) - ObjectGet((obj_liqTypes[pos-2]=="Buy"?nam_B3:nam_S3),OBJPROP_PRICE1)) < 100*Point) &&
               ((obj_liqTyp_1 == "Buy" && iLow(NULL,0,Bars-i) < obj_Prices[pos-1]) || (obj_liqTyp_1 == "Sell" && iHigh(NULL,0,Bars-i) > obj_Prices[pos-1]))) { */
#ifdef v_opfx
            int lq_spr = 100 * Period() / 60;
#endif
            if ((Op_Liq2 && ((fabs((obj_liqTyp_1=="Buy"? iLow(NULL,0,Bars-i): iHigh(NULL,0,Bars-i)) - ObjectGet((obj_liqTypes[pos-1]=="Buy"?nam_B2:nam_S2),OBJPROP_PRICE1)) < #ifdef v_opfx
            lq_spr * Point #else 100*Point #endif &&
               ObjectGet((obj_liqTypes[pos-1]=="Buy"?nam_B2:nam_S2),OBJPROP_TIME2) - ObjectGet((obj_liqTypes[pos-1]=="Buy"?nam_B2:nam_S2),OBJPROP_TIME1) > Period() * 120 &&  // <- ||
               fabs(ObjectGet((obj_liqTypes[pos-1]=="Buy"?nam_B2:nam_S2),OBJPROP_PRICE1) - ObjectGet(ObjectName(pos-1),OBJPROP_PRICE1)) >#ifndef v_opfx 100 #else lq_spr #endif* Point) ||
//               fabs(ObjectGet((obj_liqTypes[pos]=="Buy"?nam_B:nam_S),OBJPROP_PRICE1) - ObjectGet(name, OBJPROP_PRICE1)) > 100 * Point) ||                 // voir en option **
               (fabs((obj_liqTyp_1=="Buy"? iLow(NULL,0,Bars-i): iHigh(NULL,0,Bars-i)) - ObjectGet((obj_liqTypes[pos-2]=="Buy"?nam_B3:nam_S3),OBJPROP_PRICE1)) < #ifdef v_opfx
            lq_spr * Point #else 100*Point #endif &&
               ObjectGet((obj_liqTypes[pos-2]=="Buy"?nam_B3:nam_S3),OBJPROP_TIME2) - ObjectGet((obj_liqTypes[pos-2]=="Buy"?nam_B3:nam_S3),OBJPROP_TIME1) > Period() * 120 &&  // <- ||
               fabs(ObjectGet((obj_liqTypes[pos-2]=="Buy"?nam_B3:nam_S3),OBJPROP_PRICE1) - ObjectGet(ObjectName(pos-2),OBJPROP_PRICE1)) >#ifndef v_opfx 100 #else lq_spr #endif* Point)) &&
//               fabs(ObjectGet((obj_liqTypes[pos-1]=="Buy"?nam_B2:nam_S2),OBJPROP_PRICE1) - ObjectGet(ObjectName(pos-1),OBJPROP_PRICE1)) > 100 * Point)) &&   // voir en option **
               ((obj_liqTyp_1 == "Buy" && iLow(NULL,0,Bars-i) < obj_Prices[pos-1]) || (obj_liqTyp_1 == "Sell" && iHigh(NULL,0,Bars-i) > obj_Prices[pos-1]))) && tst) {
                  obj_liqTyps2[pos] = obj_liqTypes[pos];    obj_liqTypes[pos] = obj_liqTyp_1;         if (Bars-i > 1) { tst = false;
                  haBull = Op_Liq4 && HA_Bull(1, iOpen(NULL,0,Bars-i-2), iClose(NULL,0,Bars-i-2), iHigh(NULL,0,Bars-i-2), iLow(NULL,0,Bars-i-2), Bars-i-2, NULL)
                     && HA_Bull(1, iOpen(NULL,0,Bars-i-1), iClose(NULL,0,Bars-i-1), iHigh(NULL,0,Bars-i-1), iLow(NULL,0,Bars-i-1), Bars-i-1, NULL) &&
                     obj_liqTyp_1=="Sell" && iHigh(NULL,0,Bars-i-2) - ObjectGet((obj_liqTypes[pos-1]=="Buy"?nam_B2:nam_S2),OBJPROP_PRICE1) > 70 * Point; // <- voir pos-2..?nam_B3:nam_S3
                  if (haBull && obj_liqTypes[pos] == "Sell") { obj_liqTypes[pos] = "Buy";      tst = true; }
                  else { haBull = Op_Liq4 && !HA_Bull(1, iOpen(NULL,0,Bars-i-2), iClose(NULL,0,Bars-i-2), iHigh(NULL,0,Bars-i-2), iLow(NULL,0,Bars-i-2), Bars-i-2, NULL)
                        && !HA_Bull(1, iOpen(NULL,0,Bars-i-1), iClose(NULL,0,Bars-i-1), iHigh(NULL,0,Bars-i-1), iLow(NULL,0,Bars-i-1), Bars-i-1, NULL) &&
                        obj_liqTyp_1=="Buy" && iLow(NULL,0,Bars-i-2) - ObjectGet((obj_liqTypes[pos-1]=="Buy"?nam_B2:nam_S2),OBJPROP_PRICE1) < -70 * Point;  // <- voir pos-2..?nam_B3:nam_S3
                     if (haBull && obj_liqTypes[pos] == "Buy") { obj_liqTypes[pos] = "Sell";      tst = true; } }
                  if (tst) { total0 -= fabs(iClose(NULL,0,Bars-i-2) - obj_Prices[pos]) * 2 + comm; }     //nb_pos ++; }
                  else  obj_bar_liq[pos] = Bars - i; } }
            if (obj_liqTyp_1 == obj_liqTyp_2 && obj_liqTyp_1 != "") { k ++;     for (j=1; j<=k; j++) obj_pos[p-j] = pos; }
            else   k = 0;                    // groupe activé ou pas, possible meilleur résultat sans mais avec fort drawdown -> *(1)*
#ifdef v_opfx_0
            obj_LiqPrs[pos][0] = ObjectGet((obj_liqTypes[pos]=="Buy"?nam_B:nam_S),OBJPROP_PRICE1);
#endif
            obj_Levels[pos] = (ObjectGet((obj_liqTypes[pos]=="Buy"?nam_B:nam_S),OBJPROP_PRICE1)+ObjectGet(name,OBJPROP_PRICE1))/2.0;
            obj_liqTyp_2 = obj_liqTyp_1;     obj_liqTyp_1 = obj_liqTypes[pos];      p ++; }
/*        total += (prv_pos ? (obj_liqTypes[pos] == "Buy" && obj_liqTypes[prv_pos] == "Sell" ? 1 :      // sans les commissions
            (obj_liqTypes[prv_pos] == "Buy" && obj_liqTypes[pos] == "Sell" ? -1 : 0)) * (obj_Prices[prv_pos]-obj_Prices[pos])/Point : 0);
        Print (pos, " object ("+IntegerToString(type)+") ", name, " description= "+ObjectDescription(name)+" * "+
            TimeToStr(OTim1,TIME_DATE|TIME_SECONDS)+"-"+TimeToStr(OTim2,TIME_DATE|TIME_SECONDS)+"-"+DoubleToStr(iOpen(NULL,0,Bars-i),5)+
            "-("+IntegerToString(i)+")-"+(ObjectType(StringSubstr(name,0,(StringSubstr(name,5,1)==2?13:8))+"liquid_buy"+StringSubstr(name, 
            StringFind(name, "tral")+4)) > 0 ? "Buy" : (ObjectType(StringSubstr(name,0,(StringSubstr(name,5,1)==2?13:8))+"liquid_sell"+
            StringSubstr(name, StringFind(name, "tral")+4)) > 0 ? "Sell" : t_neutral?"Error":"liquid"))+"-"+ObjectGet(name,OBJPROP_PRICE1)+"-"+
            TimeToString(ObjectGet(name,OBJPROP_TIME2),TIME_DATE|TIME_SECONDS)+"-"+ObjectGet(name,OBJPROP_PRICE2)+"-"+
            DoubleToStr(obj_Prices[pos],5)+"-"+(ObjectType(StringSubstr(name, 0, (StringSubstr(name,5,1)==2?13:8))+"liquid_buy"+
            StringSubstr(name, StringFind(name, "tral")+4)) > 0 ? DoubleToStr((obj_Prices[pos]-ObjectGet(name,OBJPROP_PRICE1))/Point,0) :
            (ObjectType(StringSubstr(name, 0, (StringSubstr(name,5,1)==2?13:8))+"liquid_sell"+StringSubstr(name, StringFind(name, "tral")+4))>0 ?
            DoubleToStr((ObjectGet(name,OBJPROP_PRICE1)-obj_Prices[pos])/Point,0) : 0))+" | "+IntegerToString(prv_pos)+" - "+
            DoubleToStr(obj_Prices[prv_pos], 5)+" - "+IntegerToString((prv_pos ? (obj_liqTypes[pos] == "Buy" && obj_liqTypes[prv_pos] == "Sell"? 1: 
            (obj_liqTypes[prv_pos] == "Buy" && obj_liqTypes[pos] == "Sell" ? -1 : 0)) * (obj_Prices[prv_pos]-obj_Prices[pos])/Point : 0))+
            " - "+IntegerToString(total)+" *");
            if ((obj_liqTypes[pos] == "Buy" && obj_liqTypes[prv_pos] != "Buy") ||
               (obj_liqTypes[pos] == "Sell" && obj_liqTypes[prv_pos] != "Sell")) prv_pos = pos;     //*/
     }  }   k = 0;      #ifndef v_opfx_0 p = 0;#endif      total = total0;      // prv_pos = 0;            // <- remettre si | est remis
#ifdef v_opfx_0
  if (last_rct_ < last_rect) { last_rct_ = last_rect;    copy_file_(0, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES|TIME_SECONDS) + "." +
      IntegerToString(getCurrentMs()%1000)+" ** - RECTANGLE : "+IntegerToString(Period())+" - "+TimeToStr(ObjectGet(rect_str, OBJPROP_TIME1), 
      TIME_DATE|TIME_MINUTES)+" - "+TimeToStr(last_rect, TIME_DATE|TIME_MINUTES)+" - "+TimeToStr(Time[0], TIME_DATE|TIME_MINUTES)+" **");
      GlobalVariableSet(l_rct_str, last_rct_); }
  temp = ObjectName(obj_pos0[p-1]);
  nam_B = StringSubstr(temp, 0, (StringSubstr(temp,5,1)==2?13:8)) + "liquid_buy" + StringSubstr(temp, StringFind(temp, "tral") + 4);
  nam_S = StringSubstr(temp, 0, (StringSubstr(temp,5,1)==2?13:8)) + "liquid_sell" + StringSubstr(temp, StringFind(temp, "tral") + 4);
  last_liq_pr = ObjectGet((obj_liqTypes[obj_pos0[p-1]]=="Buy"?nam_B:nam_S),OBJPROP_PRICE1);
  last_liq_t1 = ObjectGet((obj_liqTypes[obj_pos0[p-1]]=="Buy"?nam_B:nam_S),OBJPROP_TIME1);
  last_liq_t2 = ObjectGet((obj_liqTypes[obj_pos0[p-1]]=="Buy"?nam_B:nam_S),OBJPROP_TIME2);
  if ((last_liq_pr==0 || last_liq_t2==0) && (TimeCurrent() - Time[0] < 3 || StringSubstr(temp, 0, 3) == "ATS"))
      Print("*** Erreur sur last_liq_pr ou last_liq_t2. " + DoubleToStr(last_liq_pr,Digits()) + " " + DoubleToStr(ObjectGet(temp,OBJPROP_PRICE1),Digits()) +
         " " + TimeToStr(last_liq_t1, TIME_DATE|TIME_SECONDS) + " " + TimeToStr(last_liq_t2, TIME_DATE|TIME_SECONDS) + " \"" +
         temp + "\" \"" + nam_B + "\" \"" + nam_S + "\" ***");
  last_liq_p2 = ObjectGet((obj_liqTypes[obj_pos0[p-2]]=="Buy"?nam_B:nam_S),OBJPROP_PRICE1);
  last_liq_p3 = ObjectGet((obj_liqTypes[obj_pos0[p-3]]=="Buy"?nam_B:nam_S),OBJPROP_PRICE1);
  last_ntr_p2 = ObjectGet(ObjectName(obj_pos0[p-2]), OBJPROP_PRICE1);
  last_ntr_p3 = ObjectGet(ObjectName(obj_pos0[p-3]), OBJPROP_PRICE1);
  last_liq_t12 = ObjectGet((obj_liqTypes[obj_pos0[p-2]]=="Buy"?nam_B:nam_S),OBJPROP_TIME1);
  last_liq_t13 = ObjectGet((obj_liqTypes[obj_pos0[p-3]]=="Buy"?nam_B:nam_S),OBJPROP_TIME1);
  last_liq_t22 = ObjectGet((obj_liqTypes[obj_pos0[p-2]]=="Buy"?nam_B:nam_S),OBJPROP_TIME2);
  last_liq_t23 = ObjectGet((obj_liqTypes[obj_pos0[p-3]]=="Buy"?nam_B:nam_S),OBJPROP_TIME2);
#endif
  last_ntr_pr = ObjectGet(temp, OBJPROP_PRICE1);      lastliq = tst && lastliq_;       p = 0;
  bool op_case01=GlobalVariableGet("Op_Case01");      // à replacer ailleurs

//  CreateLabel(1.0907,153,0,"   "+DoubleToStr((iClose(NULL,0,153)-iOpen(NULL,0,Bars-i+1))/Point,0)+
//      " "+DoubleToStr(((obj_liqTypes[pos]=="Buy" ? -1 : 1) * (iClose(NULL,0,Bars-i+1) - iOpen(NULL,0,Bars-i+1)))/Point,0),0,1);
  int pX=80, pY=45, pos_bar_cl;    bool tst1#ifndef v_opfx_0, tst2#endif;     //double vScale=(WindowPriceMax()-WindowPriceMin())/(1.154-1.061);
  double vScale=(WindowPriceMax()-WindowPriceMin())/(!WindowPriceMax()?1.154:WindowPriceMax())/1.154/(1.154-1.061);
  for (pos=0; pos<obj_total; pos++) if (obj_liqTypes[pos] == "Error") { exp_1 ++;
         CreateLabel0(obj_Levels[pos],Bars-obj_bars[pos],"- NO LIQUID LINE - "+IntegerToString(pos)+" *",0,0,0); }   // && Op_HiLo
      else if (obj_liqTypes[pos] == "Error-2") { exp_2 ++;
         CreateLabel0(obj_Levels[pos],Bars-obj_bars[pos],"- 2 LIQUID LINES - "+IntegerToString(pos)+" *",0,0,0); }   // && Op_HiLo
      else if (obj_liqTypes[pos] == "Buy" || obj_liqTypes[pos] == "Sell") {
      obj_reOps[pos][1] = 0;     name = ObjectName(pos);    k_ = k;
      bool t_clo=false;    for (i=obj_bars[pos]+1; i<obj_bars[obj_pos[p+1]] && ! t_clo; i ++) { obj_prClots[pos] = iClose(NULL,0,Bars-i);
         if (iCustom(NULL, PERIOD_H1, "New folder\\ADX.ex4", 0, Bars-i) > 45 || op_case01)
//         haBull = HA_Bull(iOpen(NULL,0,Bars-i+2), iClose(NULL,0,Bars-i+2), iOpen(NULL,0,Bars-i+1), iClose(NULL,0,Bars-i+1), 
//            iHigh(NULL,0,Bars-i+1), iLow(NULL,0,Bars-i+1), iOpen(NULL,0,Bars-i), iClose(NULL,0,Bars-i), iHigh(NULL,0,Bars-i), iLow(NULL,0,Bars-i));
#ifndef v_opfx
            t_clo = f_mqh_code(0, pos, prv_pos, i, obj_liqTypes[pos], obj_prClots[pos], 0, 0);                                                     // * MQH *
#else
         if (iHigh(NULL,0,Bars-i)==iLow(NULL,0,Bars-i)) { Print("*** Error High - Low! (1) "+TimeToStr(iTime(NULL,0,Bars-i),TIME_DATE|TIME_MINUTES)+" ***");   continue; }  //Period()<=5 && 
         else if (! obj_bar_liq[pos] || Bars - i > obj_bar_liq[pos] + 2) {
            haBull = HA_Bull(1, iOpen(NULL,0,Bars-i), iClose(NULL,0,Bars-i), iHigh(NULL,0,Bars-i), iLow(NULL,0,Bars-i), Bars-i, NULL);
            if ((ha_Prev || !ha_Buff || !((haBull && obj_liqTypes[pos]=="Buy") || (!haBull && obj_liqTypes[pos]=="Sell"))) && (obj_bars[pos+1] > i || !Op_2xBl))
               t_clo = f_mqh_code_EA(0,pos,prv_pos,i,obj_liqTypes[pos],obj_prClots[pos],0,0,params,HighVal,MrktVal,HiLoVal,DDwnVal); }                         // * MQH *
#endif
         if (ea_show && t_clo) { //&& (!prv_pos || (obj_liqTypes[pos]=="Buy" && obj_liqTypes[prv_pos]=="Sell") || (obj_liqTypes[prv_pos]=="Buy" && obj_liqTypes[pos]=="Sell"))) {
            DrawArrow(obj_prClots[pos], Bars-i, 3, 0, 1);         DrawArrow(obj_prClots[pos], Bars-i, 5, 0, 1); }       // 1er niveau de sortie en bleu
         if (ea_show && !(iHigh(NULL,0,Bars-i) - iLow(NULL,0,Bars-i))) CreateLabel0(iOpen(NULL,0,Bars-i),Bars-i,"- HIGH() = LOW() - "+DoubleToStr(iOpen(NULL,0,  // && Op_HiLo
            Bars-i),4)+" - "+DoubleToStr(iHigh(NULL,0,Bars-i),4)+" - "+DoubleToStr(iLow(NULL,0,Bars-i),4)+" - "+DoubleToStr(iClose(NULL,0,Bars-i),4)+" *",0,0,0); }
//      obj_prClots[pos][0] = (!prv_pos || (obj_liqTypes[pos]=="Buy" && obj_liqTypes[prv_pos]=="Sell") || (obj_liqTypes[prv_pos]=="Buy" && obj_liqTypes[pos]=="Sell"));
      if (!prv_pos || (obj_liqTypes[pos]=="Buy" && obj_liqTypes[prv_pos]=="Sell") || (obj_liqTypes[prv_pos]=="Buy" && obj_liqTypes[pos]=="Sell")) obj_bar_cl = Bars-i+(t_clo?1:0);
      if (! ((obj_liqTypes[pos]=="Buy" && obj_liqTypes[prv_pos]=="Sell") || (obj_liqTypes[prv_pos]=="Buy" && obj_liqTypes[pos]=="Sell"))) { obj_bar_cl3 = obj_bar_cl2;
             obj_bar_cl2 = Bars-i+(t_clo?1:0); }
      if (! t_clo) obj_prClots[pos] = obj_Prices[obj_pos[p+1]];         // -> (1 || *(1)*             // FXChoice -> levier = 1:200
      total += (prv_pos ? (obj_liqTypes[pos] == "Buy" && obj_liqTypes[prv_pos] == "Sell" ? 1 :        // commission = $0.06 = 0.6 pips
//         (obj_liqTypes[prv_pos] == "Buy" && obj_liqTypes[pos] == "Sell" ? -1 : 0)) * (obj_Prices[prv_pos]-obj_Prices[pos])/Point - 6 : 0);
         (obj_liqTypes[prv_pos] == "Buy" && obj_liqTypes[pos] == "Sell" ? -1 : 0)) * (obj_Prices[prv_pos]-obj_prClots[prv_pos]) / Point -
         ((obj_liqTypes[pos]=="Buy" && obj_liqTypes[prv_pos]=="Sell") || (obj_liqTypes[prv_pos]=="Buy" && obj_liqTypes[pos]=="Sell") ? 1 : 0) * comm : 0);
//      string stotal = DoubleToStr((obj_Prices[prv_pos]-obj_prClots[prv_pos]),5)+" "+IntegerToString(total0)+" "+IntegerToString(total);
      if ((obj_liqTypes[pos]=="Buy" && obj_liqTypes[prv_pos]=="Sell") || (obj_liqTypes[prv_pos]=="Buy" && obj_liqTypes[pos]=="Sell")) {
         if (bull == NULL) bull = (obj_liqTypes[prv_pos] == "Buy");
         DrawArrow(((bull=(obj_liqTypes[pos]=="Buy")) ? obj_Levels[prv_pos]+100*vScale*Point : obj_Levels[prv_pos]+250*vScale*Point), Bars-obj_bars[prv_pos], 0, bull, 0);
         if (ea_show) { DrawArrow(obj_Prices[prv_pos], Bars-obj_bars[prv_pos], 3, !bull, 0);     DrawArrow(obj_Prices[prv_pos], Bars-obj_bars[prv_pos], 5, !bull, 0);
//         DrawArrow(iOpen(NULL,0,Bars-obj_bars[prv_pos]), Bars-obj_bars[prv_pos], 1, !bull, 0);
           CreateLabel(obj_Levels[prv_pos],Bars-obj_bars[prv_pos],pos,!bull,"   px: "+DoubleToStr(obj_Prices[prv_pos],5)+" "+DoubleToStr(obj_prClots[prv_pos],5),0,0);
           CreateLabel(obj_Levels[pos],Bars-obj_bars[pos],pos,bull,"   total: "+DoubleToStr(total,0)+" (pipettes)",1,0); }/*
         CreateLabel(obj_Levels[pos],Bars-obj_bars[pos],pos,bull,"   -> "+stotal,2,0);*/ }
      else {      // dans ce bloc la logique d'apparition des flèches est différente par rapport au précédent (-> prv_pos)
         temp = (total ? "intermédiaire" : "départ");
         if (ea_show) { DrawArrow(obj_Prices[pos], Bars-obj_bars[pos], 3, pos_prem?!bull:bull, 0);    DrawArrow(obj_Prices[pos], Bars-obj_bars[pos], 5, pos_prem?!bull:bull, 0); }
         if (obj_bar_cl >= Bars-obj_bars[pos] && pos_bar_cl > obj_bar_cl2 && (! obj_bar_cl3 || obj_bar_cl3 > obj_bar_cl2)
            && obj_prClots[pos])                            // revoir peut-être le cas iClose()
            total += (total ? (obj_liqTypes[pos] == "Buy" ? -1 : (obj_liqTypes[pos] == "Sell" ? 1 : 0)) * ((pos_bar_cl>=Bars-obj_bars[pos]? (!obj_bar_cl3 || obj_bar_cl3>Bars-obj_bars[pos]? 
               obj_Prices[pos]: iClose(NULL,0,obj_bar_cl3)): iClose(NULL,0,obj_bar_cl3>pos_bar_cl?pos_bar_cl:obj_bar_cl3)) - obj_prClots[pos]) / Point - (pos_bar_cl>Bars-obj_bars[pos]? comm: 0): 0);
         if (ea_show && obj_bar_cl >= Bars-obj_bars[pos] && pos_bar_cl > obj_bar_cl2 && (! obj_bar_cl3 || obj_bar_cl3 > obj_bar_cl2)) // v surveiller les flèches intermédiaires après sortie OS 4 **
//         if (obj_bar_cl > Bars-obj_bars[pos] && pos_bar_cl > obj_bar_cl2 && pos_bar_cl > Bars-obj_bars[pos] && pos_bar_cl < Bars-obj_bars[obj_pos0[p]] && (! obj_bar_cl3 || obj_bar_cl3 > obj_bar_cl2))
            DrawArrowInt(obj_Levels[pos]+(bull ? 100*vScale*Point : 250*vScale*Point), Bars-obj_bars[pos], 0, pos_prem?!bull:bull);
         total0 = (total ? 0 : (obj_liqTypes[pos] == "Buy" ? -1 : (obj_liqTypes[pos] == "Sell" ? 1 : 0)) * (obj_Prices[pos] - obj_prClots[pos]) / Point - comm);     if (ea_show && Op_Show) 
         if (ea_show) CreateLabel(obj_Levels[pos],Bars-obj_bars[pos],pos,!bull,"  total: "+DoubleToStr(total? total: total0,0)+" ("+temp+") "+IntegerToString(Bars-obj_bars[pos])+" "+IntegerToString(obj_bar_cl),1,2);
/*      total0 = total;      // avant la ligne < if (obj_bar_cl >= Bars-obj_bars[pos]) > et < total += (total ? ...>
      stotal = DoubleToStr(obj_Prices[pos],5)+" "+DoubleToStr(obj_prClots[pos],5)+" "+DoubleToStr(Point,5);     // avant < CreateLabel(obj_Levels[pos],...>
      string stotal2 = DoubleToStr((obj_Prices[pos] - obj_prClots[pos]),5)+" "+IntegerToString(total0)+" "+IntegerToString(total);   // idem
         CreateLabel(obj_Levels[pos],Bars-obj_bars[pos],pos,!bull,"   -> "+stotal,2,2);      CreateLabel(obj_Levels[pos],Bars-obj_bars[pos],pos,!bull,"   -> "+stotal2,3,2); */ }
//      Print (pos, " (1) object ", ObjectName(pos), " | ", (ObjectType(StringSubstr(name,0,(StringSubstr(name,5,1)==2?13:8))+"liquid_buy"+StringSubstr(name,StringFind(name,"tral")+4)) 
//         > 0 ? "Buy " : (ObjectType(StringSubstr(name,0,(StringSubstr(name,5,1)==2?13:8))+"liquid_sell"+StringSubstr(name, StringFind(name, "tral")+4)) > 0 ? "Sell" : "Err ")), " ",
//         prv_pos, " - ", obj_Prices[prv_pos], " - ", obj_prClots[prv_pos][1], " - ", obj_Prices[pos], " - ", pos, " - ", obj_pos[p+1], " - ", p, " - total : ", total, " *");
      if ((obj_liqTypes[pos]=="Buy" && obj_liqTypes[prv_pos]=="Sell") || (obj_liqTypes[prv_pos]=="Buy" && obj_liqTypes[pos]=="Sell")) pos_prem = false;
      if (hightotal < total) hightotal = total;          else if (drawdown > total - hightotal) { drawdown = total - hightotal;
            if (hightotal) drawdwnp = (drawdown*1.0 / hightotal*1.0) * 100.0; }
      if (t_clo) { //CreateLabel0(iOpen(NULL,0,Bars-obj_bars[obj_pos0[p+1]]),Bars-obj_bars[obj_pos0[p+1]],"- test reOps - "+IntegerToString(pos)+" *",0,0,0);     // -> (0 && *(1)*
         if (ea_show && !((obj_liqTypes[obj_pos0[p+1]]=="Buy" && obj_liqTypes[obj_pos0[p]]=="Sell") || (obj_liqTypes[obj_pos0[p]]=="Buy" && obj_liqTypes[obj_pos0[p+1]]=="Sell")) && Op_Show) 
            CreateLabel0(iOpen(NULL,0,Bars-obj_bars[obj_pos0[p+1]]),Bars-obj_bars[obj_pos0[p+1]],"- test reOps - "+IntegerToString(pos)+"*"+IntegerToString(obj_pos0[p])+
               "*"+IntegerToString(obj_pos0[p+1])+"*"+IntegerToString(obj_pos[p])+"-"+IntegerToString(obj_pos[p+1])+" *",0,0,0);
         bool t_opn=false;     while (i < obj_bars[obj_pos0[p+1]]) { reOpn_prs[k] = 0.0;   reClo_prs[k] = 0.0;             //int t_clo2=0,t_clo3=0;
          t_clo=false;   for (i=i; i<obj_bars[obj_pos0[p+1]] && !t_clo; i ++) { reOpn_prs[k] = iClose(NULL,0,Bars-i);      //(iOpen(NULL,0,Bars-i) * 5.0 + ...) / 6.0
//            haBull = HA_Bull(iOpen(NULL,0,Bars-i+2), iClose(NULL,0,Bars-i+2), iOpen(NULL,0,Bars-i+1), iClose(NULL,0,Bars-i+1), 
//               iHigh(NULL,0,Bars-i+1), iLow(NULL,0,Bars-i+1), iOpen(NULL,0,Bars-i), iClose(NULL,0,Bars-i), iHigh(NULL,0,Bars-i), iLow(NULL,0,Bars-i));
#ifndef v_opfx
            t_clo = f_mqh_code(1, pos, prv_pos, i, obj_liqTypes[pos], 0, reOpn_prs[k], 0); }          // boucle des reOps Label_Arrow_Test(Type= 1,      // * MQH *
#else
            if (iHigh(NULL,0,Bars-i)==iLow(NULL,0,Bars-i)) { Print("*** Error High - Low! (2) "+TimeToStr(iTime(NULL,0,Bars-i),TIME_DATE|TIME_MINUTES)+" ***");   continue; }  //Period()<=5 && 
            else { haBull = HA_Bull(1, iOpen(NULL,0,Bars-i), iClose(NULL,0,Bars-i), iHigh(NULL,0,Bars-i), iLow(NULL,0,Bars-i), Bars-i, NULL);
               if (ha_Prev || !ha_Buff || (haBull && obj_liqTypes[pos]=="Buy") || (!haBull && obj_liqTypes[pos]=="Sell"))
                  t_clo = f_mqh_code_EA(1,pos,prv_pos,i,obj_liqTypes[pos],0,reOpn_prs[k],0,params,HighVal,MrktVal,HiLoVal,DDwnVal);                            // * MQH *
               if (ha_Prev && ha_Buff) { haBull = HA_Bull(1, iOpen(NULL,0,Bars-i-1), iClose(NULL,0,Bars-i-1), iHigh(NULL,0,Bars-i-1), iLow(NULL,0,Bars-i-1), Bars-i-1, NULL);
                  if ((haBull && obj_liqTypes[pos]=="Buy") || (!haBull && obj_liqTypes[pos]=="Sell")) { t_clo = false;
                     total -= (prv_pos ? fabs(iClose(NULL,0,Bars-i-1) - iClose(NULL,0,Bars-i)) / Point + comm : 0); } } } }      // boucle des reOps Label_Arrow_Test(Type= 1,
#endif
          if (t_clo) { //if (t_clo2 < 13) { t_clo2 ++;   Label_Arrow_Test(1,pos,p,i,k,reOpn_prs[k],!bull,pX,pY,total,obj_pos0,obj_pos);   pY += 34; }
            if (ea_show) { DrawArrowInt(iClose(NULL,0,Bars-i+1), Bars-i+1, 3, true);         DrawArrowInt(iClose(NULL,0,Bars-i+1), Bars-i+1, 5, true); }
            t_clo = false;   t_opn = true;                                                   // boucle de recherche des reCls Label_Arrow_Test(Type= 2,
            for (i=i; i<(obj_bars[obj_pos0[p+1]]>j? obj_bars[obj_pos0[p+1]]: obj_bars[obj_pos[p+1]]) && ! t_clo; i ++) {
               reClo_prs[k] = iClose(NULL,0,Bars-i);        reClo_brs[k] = i;
//               haBull = HA_Bull(iOpen(NULL,0,Bars-i+2), iClose(NULL,0,Bars-i+2), iOpen(NULL,0,Bars-i+1), iClose(NULL,0,Bars-i+1), 
//                  iHigh(NULL,0,Bars-i+1), iLow(NULL,0,Bars-i+1), iOpen(NULL,0,Bars-i), iClose(NULL,0,Bars-i), iHigh(NULL,0,Bars-i), iLow(NULL,0,Bars-i));
#ifndef v_opfx
               t_clo = f_mqh_code(2, pos, prv_pos, i, obj_liqTypes[pos], 0, 0, reClo_prs[k]); }                                                    // * MQH *
#else
               if (iHigh(NULL,0,Bars-i)==iLow(NULL,0,Bars-i)) { Print("*** Error High - Low! (3) "+TimeToStr(iTime(NULL,0,Bars-i),TIME_DATE|TIME_MINUTES)+" ***");   continue; }  //Period()<=5 && 
               else { haBull = HA_Bull(1, iOpen(NULL,0,Bars-i), iClose(NULL,0,Bars-i), iHigh(NULL,0,Bars-i), iLow(NULL,0,Bars-i), Bars-i, NULL);
                  if (ha_Prev || !ha_Buff || !((haBull && obj_liqTypes[pos]=="Buy") || (!haBull && obj_liqTypes[pos]=="Sell")))
                     t_clo = f_mqh_code_EA(2,pos,prv_pos,i,obj_liqTypes[pos],0,0,reClo_prs[k],params,HighVal,MrktVal,HiLoVal,DDwnVal);                         // * MQH *
                  if (ha_Prev && ha_Buff) { haBull = HA_Bull(1, iOpen(NULL,0,Bars-i-1), iClose(NULL,0,Bars-i-1), iHigh(NULL,0,Bars-i-1), iLow(NULL,0,Bars-i-1), Bars-i-1, NULL);
                     if ((haBull && obj_liqTypes[pos]=="Buy") || (!haBull && obj_liqTypes[pos]=="Sell")) { t_clo = false;
                        total -= (prv_pos ? fabs(iClose(NULL,0,Bars-i-1) - iClose(NULL,0,Bars-i)) / Point + comm : 0); } } } }
#endif
            if (ea_show && t_clo) { //&& t_clo3 < 13) { t_clo3 ++;    Label_Arrow_Test(2,pos,p,i,k,reClo_prs[k],bull,pX,pY,total,obj_pos0,obj_pos);     pY += 34; }
               DrawArrowInt(iClose(NULL,0,Bars-i+1), Bars-i+1, 3, false);        DrawArrowInt(iClose(NULL,0,Bars-i+1), Bars-i+1, 5, false); }
            if (! t_clo) reClo_prs[k] = obj_Prices[obj_bars[obj_pos0[p+1]]>j? obj_pos0[p+1]: obj_pos[p+1]];
            pos_bar_cl = Bars-i+(t_clo?1:0); }        k ++; }                                                  // fin de boucle While **
         obj_reOps[pos][0] = obj_reOps[obj_pos[p-1]==obj_pos[p]?obj_pos[p-2]:obj_pos[p-1]][1];
         obj_reOps[pos][1] = k - 1;    if (! obj_reOps[pos][0] && prv_pos) obj_reOps[pos][0] = k_ - 1;
         if (t_opn) { tst1 = (obj_liqTypes[pos] == "Buy");// && (! prv_pos || obj_liqTypes[prv_pos] == "Sell"));     // -> (0 && *(1)*
            tst2 = (obj_liqTypes[pos] == "Sell");  //(! prv_pos || obj_liqTypes[prv_pos] == "Buy") && 
            for (int l=obj_reOps[pos][0]+(obj_reOps[pos][0]?1:0); l<=obj_reOps[pos][1]; l ++) if (reClo_prs[l]) {   // ou  && reClo_prs[l]
               total += (tst1 ? -1 : (tst2 ? 1 : 0)) * (reOpn_prs[l] - reClo_prs[l]) / Point - (tst1 || tst2 ? 1 : 0) * comm;       if (ea_show && Op_Show) 
               CreateLabel(reClo_prs[l],Bars-reClo_brs[l],pos,!bull,"   px:"+DoubleToStr(reClo_prs[l],5)+" tot: "+DoubleToStr(total,0)+" - "+IntegerToString(pos)+" - "+IntegerToString(l),0,1);/*
      total0 = total;      // avant la ligne < total += (tst1 ? ...> et < total += (prv_pos ? ...>
      stotal = DoubleToStr(reOpn_prs[l],5)+" "+DoubleToStr(reClo_prs[l],5)+" "+DoubleToStr(Point,5);     // avant < CreateLabel(reClo_prs[l],...>
      string stotal2 = DoubleToStr((reOpn_prs[l] - reClo_prs[l]),5)+" "+IntegerToString(total0)+" "+IntegerToString(total);   // idem
         CreateLabel(reClo_prs[l],Bars-reClo_brs[l],pos,!bull,"   -> "+stotal,1,1);
         CreateLabel(reClo_prs[l],Bars-reClo_brs[l],pos,!bull,"   -> "+stotal2,2,1);
//if (l < obj_reOps[pos][0] + 1)
               CreateLabel(reClo_prs[l],Bars-reClo_brs[l],pos,!bull,"   px:"+/*DoubleToStr(reClo_prs[l],5)+" tot: "+DoubleToStr(total,0)+* /" - "+IntegerToString(pos)+"-"+
         IntegerToString(obj_pos0[p])+"-"+IntegerToString(obj_pos0[p+1])+"-"+IntegerToString(obj_pos[p])+"-"+IntegerToString(obj_pos[p+1])+" - "+
         IntegerToString(obj_pos0[p-1])+"-"+IntegerToString(obj_pos[p-1])+" - "+IntegerToString(obj_pos0[p-5])+"-"+IntegerToString(obj_pos[p-5])+" - "+
         IntegerToString(obj_pos0[p-4])+"-"+IntegerToString(obj_pos[p-4])+" - "+IntegerToString(l)+" - "+IntegerToString(Bars-reClo_brs[l]),0,1);/*
               Print (pos, " (2) object ", ObjectName(pos), " | ", prv_pos, " - ", obj_Prices[prv_pos], " - ", obj_prClots[prv_pos][1], " - ", obj_Prices[pos], " - total : ", total, " *");*/ } }
            if (total - hightotal < drawdown / 4 * 3 && Op_DDw) Print ("(1) ", pos," object "," | ",prv_pos," - ",obj_Prices[prv_pos]," - total : ",total," - hightotal : ",
               hightotal," - drawdown : ",drawdown," - ",drawdwnp?DoubleToStr(drawdwnp,1):"-.-"," % - ",obj_reOps[pos][0]," - ",obj_reOps[pos][1]," - t_clo/bleu : ",
               TimeToStr(Time[obj_bar_cl],TIME_DATE|TIME_MINUTES)," *");
            if (hightotal < total) hightotal = total;          else if (drawdown > total - hightotal) { drawdown = total - hightotal;
                  if (hightotal) drawdwnp = (drawdown*1.0 / hightotal*1.0) * 100.0; } }
//      Print (pos, " object ", ObjectName(pos), " | ", prv_pos, " - ", obj_Prices[prv_pos], " - total : ", total, " *");
      obj_liqTyp_2 = obj_liqTyp_1;     obj_liqTyp_1 = obj_liqTypes[pos];
      if ((obj_liqTypes[pos] == "Buy" && obj_liqTypes[prv_pos] != "Buy") ||
         (obj_liqTypes[pos] == "Sell" && obj_liqTypes[prv_pos] != "Sell")) prv_pos = pos;    p ++; }

/* - partie finale ---------------------------------------------------------------------------------------------------------------- */
#ifdef v_opfx_0
   if (Minute()) { test0 = -1;       test1 = -1;       test2 = -1; }
   if (! (Minute() % PERIOD_M5) && Seconds() < 7 && DayOfWeek() == 5 && H1 > H3 && Hour() == H1 && test0 < Seconds()) { test0 = Seconds();
      Print("** -> TEST(0) DrawArrow_OS n ",bull_," ",bull," ",t_night," ",ticket," ",TimeToStr(Time[0],TIME_MINUTES)," ",OS5_tick," ",TimeToStr(tim_Chart_M5,TIME_MINUTES)," **"); }
   if (!(((Hour()>1 || (Hour() && Minute()>2)) && (Hour()<H3 || Minute()<59)) || (Bid>0 && Ask>Bid && (Ask-Bid)*Point < 8)) &&
      (Period() > PERIOD_M15 || DayOfWeek() == 5) && ! time_allow) return;    // 23
   if (Hour() >= H1 && ! (Minute() % (PERIOD_M5 * 60)) && Seconds() < 7 && test1 < Seconds()) { test1 = Seconds();
      Print("** -> TEST(1) DrawArrow_OS n ",bull_," ",bull," ",t_night," ",ticket," ",TimeToStr(Time[0],TIME_MINUTES)," / ",fl_Trade," ",(!(((Hour()>1 || (Hour() && 
         Minute()>2)) && (Hour()<23 || Minute()<59)) || (Bid>0 && Ask>Bid && (Ask-Bid)*Point < 8)) && (Period() > PERIOD_M15 || DayOfWeek() == 5) && ! time_allow)," ",!(((Hour()>1 ||
         (Hour() && Minute()>2)) && (Hour()<23 || Minute()<59)) || (Bid>0 && Ask>Bid && (Ask-Bid)*Point < 8))," ",((Period() > PERIOD_M15 || DayOfWeek() == 5) && ! time_allow)," ",
         (Period() > PERIOD_M15 || DayOfWeek() == 5)," ",t_rsi515," ",OS5_tick," ",Hour()," ",TimeToStr(tim_Chart_M5,TIME_MINUTES)," ",TimeToStr(tim_M15,TIME_MINUTES) +" **"); }
#endif
   double tmp, tmp2, this_Order_Price;     datetime this_Order_Time;       St_Trd2 = FileIsExist("St-Trd_On.txt", FILE_COMMON);
   if (prevMinute != Time[0]) { t3 = 0;    prevMinute = Time[0]; }
   if (! total2) total2 = total;       if (! total3 && ! total3_) { total3 = total;    AccBalance = AccountBalance(); }
   obj_reOps[pos][1] = 0;     pos --;     //pos = prv_pos;     prv_pos = prv_pos0;     name = ObjectName(pos);    k_ = k;
   obj_Prices[pos] = (iOpen(NULL,0,Bars-obj_bars[obj_pos[p-1]]) * (rate1c? 5.0: rate2c? 4.0: rate3c? 3.0: rate4c? 2.0: 1.0) + 
         iClose(NULL,0,Bars-obj_bars[obj_pos[p-1]]) * (rate1c? 1.0: rate2c? 2.0: rate3c? 3.0: rate4c? 4.0: 5.0)) / 6.0;
   if (obj_liqTypes[pos] == "Error") CreateLabel0(obj_Levels[pos],Bars-obj_bars[pos],"- NO LIQUID LINE - "+IntegerToString(pos)+" *",0,0,0);    // && Op_HiLo
   if (obj_liqTypes[pos] == "Error-2") CreateLabel0(obj_Levels[pos],Bars-obj_bars[pos],"- 2 LIQUID LINES - "+IntegerToString(pos)+" *",0,0,0);  // && Op_HiLo
   t_clo = false;    j = 0;   while(! Time[j]) j ++;     //bool op_case0;    // op_case0 juste provisoire, à revoir *
   for (i=obj_bars[obj_pos[p-1]]+1; i <= Bars && ! t_clo; i ++) { obj_prClots[pos] = iClose(NULL,0,Bars-i);
/*Print("*** ",i," - ",p," - ",(Bars-i)," - ",pos," - ",obj_pos[p-2]," - ",obj_pos[p-1]," - ",obj_pos[p]," - ",obj_liqTypes[prv_pos]," - ",
   iOpen(NULL,0,Bars-i)," - ",iHigh(NULL,0,Bars-i)," - ",iLow(NULL,0,Bars-i)," - ",iClose(NULL,0,Bars-i)," - ",obj_prClots[pos]," - ",
((obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (obj_prClots[pos]-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) > 0.3 &&
         ((obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (iClose(NULL,0,Bars-i) - iOpen(NULL,0,Bars-i+1)) > 20 * Point ||
         ((obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (iClose(NULL,0,Bars-i+1) - iOpen(NULL,0,Bars-i+1))) > 20 * Point)),
         " - ",((obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (iClose(NULL,0,Bars-i) - iOpen(NULL,0,Bars-i+1)) > 20 * Point ||
            ((obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (iClose(NULL,0,Bars-i+1) - iOpen(NULL,0,Bars-i+1))) > 20 * Point),
         " - ",(obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (obj_prClots[pos]-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)),
         " - ",(obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (iClose(NULL,0,Bars-i) - iOpen(NULL,0,Bars-i+1)),
         " - ",((obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (iClose(NULL,0,Bars-i+1) - iOpen(NULL,0,Bars-i+1)))," ***"); */
//      haBull = HA_Bull(iOpen(NULL,0,Bars-i+2), iClose(NULL,0,Bars-i+2), iOpen(NULL,0,Bars-i+1), iClose(NULL,0,Bars-i+1), 
//         iHigh(NULL,0,Bars-i+1), iLow(NULL,0,Bars-i+1), iOpen(NULL,0,Bars-i), iClose(NULL,0,Bars-i), iHigh(NULL,0,Bars-i), iLow(NULL,0,Bars-i));
      if ((op_case0=(iCustom(NULL,PERIOD_H1,"New folder\\ADX.ex4",0,0)>45 || ADX_time>0 || St_Trd || St_Trd2 || 
            (H1 < H3 && (! DayOfWeek() || (DayOfWeek()==1 && Hour()<H2))) || (DayOfWeek()==5 && Hour()>21)))) {
         if ((! ((H1<H3 && (!DayOfWeek() || (DayOfWeek()==1 && Hour()<H2))) || (DayOfWeek()==5 && Hour()>21)) || t_clo) && t3 < 3) { t3 ++;     // 8
            Print("** -> op_case0 (1): "+IntegerToString(iCustom(NULL,PERIOD_H1,"New folder\\ADX.ex4",0,0))+" - "+IntegerToString(ADX_time)+" - "+St_Trd+" - "+St_Trd2+" - "+t_clo_+" - "+t_clo+" **"); }
#ifndef v_opfx
         t_clo =#ifdef v_opfx_0 Period() > PERIOD_M5 && 
                #endif f_mqh_code(3, pos, prv_pos, i, obj_liqTypes[prv_pos], obj_prClots[pos], 0, 0); }                                                  // * MQH *
#else
      if (iHigh(NULL,0,Bars-i)==iLow(NULL,0,Bars-i)) { Print("*** Error High - Low! (4) "+TimeToStr(iTime(NULL,0,Bars-i),TIME_DATE|TIME_MINUTES)+" ***");   continue; }  //Period()<=5 && 
      else if (! obj_bar_liq[pos] || Bars - i > obj_bar_liq[pos] + 2) {
         haBull = HA_Bull(1, iOpen(NULL,0,Bars-i), iClose(NULL,0,Bars-i), iHigh(NULL,0,Bars-i), iLow(NULL,0,Bars-i), Bars-i, NULL);
         if (ha_Prev || !ha_Buff || !((haBull && obj_liqTypes[pos]=="Buy") || (!haBull && obj_liqTypes[pos]=="Sell")))
            t_clo = f_mqh_code_EA(3,pos,prv_pos,i,obj_liqTypes[prv_pos],obj_prClots[pos],0,0,params,HighVal,MrktVal,HiLoVal,DDwnVal); } }                      // * MQH *
#endif
      if (ea_show && t_clo) { //&& (!prv_pos || (obj_liqTypes[prv_pos]=="Buy" && obj_liqTypes[prv_pos]=="Sell") || (obj_liqTypes[prv_pos]=="Buy" && obj_liqTypes[prv_pos]=="Sell"))) {
         DrawArrow_pf(obj_prClots[pos], Bars-i, 3, !bull, 1);         DrawArrow_pf(obj_prClots[pos], Bars-i, 5, !bull, 1); }       // 1er niveau de sortie en bleu
      if (t_clo && ticket) { blue_time = Time[Bars-i+j];    ADX_time = Time[Bars-i+j]; }     else ADX_time = 0;         if (t_clo && ticket && i == Bars-j) { //t_blue = false;
         if (t_blue) Print("** -> DrawArrow_OS *1 ",bull_," ",bull," ",t_clo_," ",t_clo," ",ticket," ",Bid," ",Ask," ",i," ",j," ",Bars," ",(Bars-j-i)," ",TimeToStr(Time[Bars-j-i],
            TIME_MINUTES)," ",TimeToStr(Time[j],TIME_MINUTES)," | ",pos," ",obj_prClots[pos]," ",vScale," **");   t_blue = false;      blue_time2 = Time[j]; }
#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(22) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 22:
t_clo_+" | "+t_clo+" | "+i+" | "+Bars+" | "+j+" | "+ticket+" | "+blue_time2+" | "+Time[Bars-j-i]+" | "+OS1_tick+" | "+time_allow+" | "+blue_time3+" | "+Time[0]+" | "+total2+" | "+total3+" | "+total3_+" | "+op_case01+" | "+op_case0;#endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
      if ((t_clo_ || t_clo) && i == Bars-j-1 && ticket && blue_time2 == Time[Bars-j-i]#ifdef v_opfx_0 && OS1_tick && time_allow) { OS1_tick = false;#else) {#endif   //t_clo_ = false;      t_clo = false;
         if (blue_time3 != Time[0]) { DrawArrow_pf(bull? Bid: Ask, j, 2, !bull, 1);        DrawArrow_pf(bull? Bid: Ask, j, 6, !bull, 1);      total2_ = total2;
            Print("** -> op_case0 (2): "+IntegerToString(blue_time)+" - "+IntegerToString(blue_time2)+" - "+IntegerToString(ADX_time)+" - "+St_Trd+" - "+St_Trd2+" - "+t_clo_+" - "+t_clo+" **");
//            total2 += (prv_pos ? (obj_liqTypes[prv_pos] == "Buy" ? -1 : (obj_liqTypes[prv_pos] == "Sell" ? 1 : 0)) * (obj_Prices[pos] - obj_prClots[pos]) / Point -
//               (obj_liqTypes[prv_pos] == "Buy" || obj_liqTypes[prv_pos] == "Sell" ? 1 : 0) * comm : 0);
            total2 += total3 - total3_;            blue_time3 = Time[0]; }                            // total2 à revoir dans cette partie  ***
         if (op_case01 || op_case0) {
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 22:
t_clo_+" | "+t_clo+" | "+i+" | "+Bars+" | "+j+" | "+ticket+" | "+blue_time2+" | "+Time[Bars-j-i]+" | "+OS1_tick+" | "+time_allow+" | "+blue_time3+" | "+Time[0]+" | "+total2+" | "+total3+" | "+total3_+" | "+op_case01+" | "+op_case0);#endif
            Print("** -> DrawArrow_OS 1* ",bull_," ",bull," ",t_clo_," ",t_clo," ",ticket," ",Bid," ",Ask," ",i," ",j," ",Bars," ",(Bars-j-i)," ",TimeToStr(Time[Bars-j-i],TIME_MINUTES)," ",
               TimeToStr(Time[j],TIME_MINUTES)," | ",pos," ",obj_prClots[pos]," ",vScale," | ",(tmp=AccountBalance())," *(22)*");      //t_clo_ = false;      t_clo = false;    t_blue = true;
            DrawArrow_OS(1, obj_prClots[pos]+(bull? 300*vScale*Point: 675*vScale*Point), Bars-i, 0, bull, ticket);      // 150*vScale*Point: 625*vScale
            Print("** --> total = ",total,", total2 = ",total2," (",DoubleToStr(obj_Prices[pos],5)," - ",DoubleToStr(obj_prClots[pos],5)," - ",TimeToStr(Time[Bars-obj_bars[obj_pos[p-1]]],
               TIME_MINUTES)," - ",TimeToStr(Time[Bars-i],TIME_MINUTES)," - ",DoubleToStr(Bid,5)," - ",DoubleToStr(Ask,5),"), total2_ = ",total2_," (",(total2-total2_),") ...");
            Print("** --> suite total3 = ",total3," (",OrderProfit()," - ",OrderSwap()," - ",OrderCommission()," - ",DoubleToStr(OrderOpenPrice(),5)," - ",DoubleToStr(OrderClosePrice(),5),
               " - ",TimeToStr(OrderOpenTime(),TIME_MINUTES)," - ",TimeToStr(OrderCloseTime(),TIME_MINUTES),", p_Coef: ",p_Coef,", ",(OrderProfit()*p_Coef)," ",(OrderSwap()*p_Coef)," ",
               (OrderCommission()*p_Coef),") ...");                    Print("** --> suite total3_ = ",total3_," (",(total3-total3_)," - ",(AccountBalance()-tmp),") | ",
            tmp," - ",AccountBalance()," - ",AccBalance," -",(AccountBalance()-AccBalance)>-0.015?" ok":"> BALANCE"," | (",ntot,") ",pos," - ",DoubleToStr(obj_Prices[pos],5)," - ",
               DoubleToStr(obj_prClots[pos],5)," | ticket = ",ticket," **");#ifdef v_opfx
#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(23) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 23:
op_Liq_+" | "+p+" | "+obj_pos0[p-1]+" | "+obj_bars[obj_pos0[p-1]]+" | "+Bars+" | "+bull+" | "+Bid+" | "+op_Liq_pr+" | "+bull+" | "+Ask+" | "+op_Liq_pr+" | "+op_Liq_sp+" | "+lastliq+" | "+OS6_tick+" | "+time_allow+" | "+lastliq_;#endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
         if (((op_Liq_ && obj_bars[obj_pos0[p-1]] > Bars-2 && ((bull && Bid > op_Liq_pr) || (! bull && Ask < op_Liq_pr) || op_Liq_sp < 100 * Point)) ||
         (lastliq && obj_bars[obj_pos0[p-1]] == Bars-2)) && OS6_tick && time_allow) { OS6_tick = false;        lastliq = false;        lastliq_ = false;
            DrawArrow_OS(6, obj_prClots[pos]+(bull? 150*vScale*Point: 625*vScale*Point), Bars-i, 0, bull, 0);           PlaySound("1673.wav");
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 23:
op_Liq_+" | "+p+" | "+obj_pos0[p-1]+" | "+obj_bars[obj_pos0[p-1]]+" | "+Bars+" | "+bull+" | "+Bid+" | "+op_Liq_pr+" | "+bull+" | "+Ask+" | "+op_Liq_pr+" | "+op_Liq_sp+" | "+lastliq+" | "+OS6_tick+" | "+time_allow+" | "+lastliq_);#endif
            Print("** -> DrawArrow_OS 6 ",bull_," ",bull," ",t_clo_," ",t_clo," ",ticket," ",Bid," ",Ask," ",i," ",j," ",Bars," ",(Bars-j-i)," ",TimeToStr(Time[Bars-j-i],TIME_MINUTES),
               " ",TimeToStr(Time[j],TIME_MINUTES)," | ",pos," ",obj_prClots[pos]," ",vScale," | ",(tmp=AccountBalance())," *(23)*");
            Print("** --> total = ",total,", total2 = ",total2," (",DoubleToStr(tmp,5)," - ",DoubleToStr(iClose(NULL,0,0),5)," - ",TimeToStr(Time[Bars-obj_bars[obj_pos[p-
               (Bars!=obj_bars[obj_pos[p-1]]?1:2)]]],TIME_MINUTES)," - ",TimeToStr(Time[Bars-i+1],TIME_MINUTES)," | ",DoubleToStr(Bid,5)," - ",DoubleToStr(Ask,5),"), total2_ = ",
               total2_," (",(total2-total2_),") ...");
            Print("** --> suite total3 = ",total3," (",OrderProfit()," - ",OrderSwap()," - ",OrderCommission()," - ",DoubleToStr(OrderOpenPrice(),5)," - ",DoubleToStr(OrderClosePrice(),5),
               " - ",TimeToStr(OrderOpenTime(),TIME_MINUTES)," - ",TimeToStr(OrderCloseTime(),TIME_MINUTES),", p_Coef: ",p_Coef,", ",(OrderProfit()*p_Coef)," ",(OrderSwap()*p_Coef)," ",
               (OrderCommission()*p_Coef),") ...");                    Print("** --> suite total3_ = ",total3_," (",(total3-total3_)," ",(AccountBalance()-tmp2),") | ",
               tmp2," - ",AccountBalance()," - ",AccBalance," -",(AccountBalance()-AccBalance)>-0.015?" ok":"> BALANCE"," | ticket = ",ticket," ...");
            Print("** --> suite (",ntot,") ",pos," - ",DoubleToStr(obj_Prices[pos],5)," - ",DoubleToStr(obj_prClots[pos],5)," - ",prv_pos," - ",
               DoubleToStr(obj_Prices[prv_pos],5)," - ",DoubleToStr(obj_prClots[prv_pos],5)," **"); }
         if (obj_bars[obj_pos0[p-1]] == Bars-3) lastliq_ = true;#endif }
         t_clo_ = false;      t_clo = false;    t_blue = true; }     // <- déplacés à cause de op_case0 *
      else if (i==Bars-j-1 && t_clo_ && ticket && blue_time2 == Time[Bars-j-i]) 
         Print("** -> DrawArrow_OS 1 Error: ",t_clo_," ",t_clo," ",ticket," ",Bid," ",Ask," ",i," ",(Bars-i)," | ",pos," ",obj_prClots[pos]," ***");
      else if (i == Bars-j-1 && blue_time2 == Time[Bars-j-i]) t_blue = true;
      t_clo_ = (i == Bars-j-1 && t_clo_ ? t_clo_ : (i == Bars-j && t_clo));
      if (ea_show && !(iHigh(NULL,0,Bars-i) - iLow(NULL,0,Bars-i))) CreateLabel0_pf(iOpen(NULL,0,Bars-i),Bars-i,"- HIGH() = LOW() - "+DoubleToStr(iOpen(NULL,0,  // && Op_HiLo
      Bars-i),4)+" - "+DoubleToStr(iHigh(NULL,0,Bars-i),4)+" - "+DoubleToStr(iLow(NULL,0,Bars-i),4)+" - "+DoubleToStr(iClose(NULL,0,Bars-i),4)+" *",0,0,0); }
   if ((obj_liqTypes[prv_pos]=="Buy" && obj_liqTyp_2 == "Sell") || (obj_liqTyp_2 == "Buy" && obj_liqTypes[prv_pos]=="Sell")) obj_bar_cl = Bars-i+(t_clo?1:0);
   if (! t_clo) { i --;       obj_prClots[pos] = (iOpen(NULL,0,Bars-i) * (rate1c? 5.0: rate2c? 4.0: rate3c? 3.0: rate4c? 2.0: 1.0) +
         iClose(NULL,0,Bars-i) * (rate1c? 1.0: rate2c? 2.0: rate3c? 3.0: rate4c? 4.0: 5.0)) / 6.0; }        ntot = 1;
   total += (prv_pos ? (obj_liqTypes[prv_pos] == "Buy" ? -1 : (obj_liqTypes[prv_pos] == "Sell" ? 1 : 0)) *     // && obj_Prices[pos]>0 && obj_prClots[pos]>0
         (obj_Prices[pos] - obj_prClots[pos]) / Point - (obj_liqTypes[prv_pos] == "Buy" || obj_liqTypes[prv_pos] == "Sell" ? 1 : 0) * comm : 0);
   if (((t_clo_ || t_clo) && i == Bars-j && ticket && blue_time2 == Time[Bars-j-i+1]) || pass1) Print("** --> (1a) total = ",total,", total2 = ",total2,
         ", total2_ = ",total2_,", total3 = ",total3,", total3_ = ",total3_,", ticket = ",ticket," **");
//Print("*** ",i," - ",p," - ",(Bars-i)," - ",pos," - ",obj_pos[p-2]," - ",obj_pos[p-1]," - ",obj_pos[p]," - ",obj_liqTypes[prv_pos]," - ",obj_Prices[pos]," - ",obj_prClots[pos]," - ",total," ***");
   if (! ((obj_liqTypes[prv_pos]=="Buy" && obj_liqTyp_2=="Sell") || (obj_liqTyp_2=="Buy" && obj_liqTypes[prv_pos]=="Sell"))) { temp = "final";
      // dans ce bloc la logique d'apparition des flèches est différente par rapport au précédent (-> prv_pos)
      if (ea_show) { DrawArrow_pf(obj_Prices[pos], Bars-obj_bars[obj_pos[p-1]], 3, bull, 0);    DrawArrow_pf(obj_Prices[pos], Bars-obj_bars[obj_pos[p-1]], 5, bull, 0); }
#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(24) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 24:
obj_bar_cl+" | "+Bars+" | "+obj_pos[p-1]+" | "+obj_bars[obj_pos[p-1]]+" | "+ntot+" | "+total+" | "+Hour()+" | "+H1+" | "+H3+" | "+Minute()+" | "+H2+" | "+ticket+" | "+FileIsExist("ATS-Int_On.txt", FILE_COMMON)+" | "+OS2_tick+" | "+time_allow+" | "+total2_+" | "+total2;#endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
      if (obj_bar_cl >= Bars-obj_bars[obj_pos[p-1]]) { ntot = 2;
         total += (obj_liqTypes[prv_pos] == "Buy" ? -1 : (obj_liqTypes[prv_pos] == "Sell" ? 1 : 0)) * (obj_Prices[pos] - obj_prClots[pos]) / Point - comm;
         if (pass1) Print("** --> (1b) total = ",total,", total2 = ",total2,", total2_ = ",total2_,", total3 = ",total3,", total3_ = ",total3_,", ticket = ",ticket," **");
#ifndef v_opfx_0
         if (obj_bars[obj_pos[p-1]] >= Bars-1 && (! ticket || FileIsExist("ATS-Int_On.txt", FILE_COMMON))) { total2_ = total2;
#else
         if ((Hour() != H1 || ((H1 < H3 || Minute() >= 2) && H1 < H2)) && obj_bars[obj_pos[p-1]] >= Bars-1 && (! ticket || FileIsExist("ATS-Int_On.txt", FILE_COMMON)) &&
            OS2_tick && time_allow) { OS2_tick = false;           total2_ = total2;
#endif
            DrawArrow_pf(bull? Ask: Bid, Bars-obj_bars[obj_pos[p-1]], 2, bull, 0);     DrawArrow_pf(bull? Ask: Bid, Bars-obj_bars[obj_pos[p-1]], 6, bull, 0);
            total2 += (obj_liqTypes[prv_pos] == "Buy" ? -1 : (obj_liqTypes[prv_pos] == "Sell" ? 1 : 0)) * (obj_Prices[pos] - obj_prClots[pos]) / Point - comm;
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 24:
obj_bar_cl+" | "+Bars+" | "+obj_pos[p-1]+" | "+obj_bars[obj_pos[p-1]]+" | "+ntot+" | "+total+" | "+Hour()+" | "+H1+" | "+H3+" | "+Minute()+" | "+H2+" | "+ticket+" | "+FileIsExist("ATS-Int_On.txt", FILE_COMMON)+" | "+OS2_tick+" | "+time_allow+" | "+total2_+" | "+total2);#endif
            Print("** -> DrawArrow_OS 2 ",bull_," ",bull," ",ticket," ",Bid," ",Ask," ",p," ",obj_pos[p-1]," ",obj_bars[obj_pos[p-1]]," | ",pos," ",obj_Prices[pos]," ",vScale," *(24)*");
            DrawArrow_OS(2, obj_Prices[pos]+(bull? 400*vScale*Point: 675*vScale*Point), Bars-obj_bars[obj_pos[p-1]], 0, bull, 0);   // 250*vScale*Point: 625*vScale
            Print("** --> total = ",total,", total2 = ",total2," (",obj_Prices[pos]," - ",obj_prClots[pos],"), total2_ = ",total2_,", total3 = ",total3," (",OrderProfit()," - ",
               OrderSwap()," - ",OrderCommission()," - ",DoubleToStr(OrderOpenPrice(),5)," - ",DoubleToStr(OrderClosePrice(),5),"), total3_ = ",total3_,", ticket = ",ticket," **"); } }
      if (ea_show && Op_Show) { name = ObjectName(prv_pos);
         nam_B = StringSubstr(name, 0, (StringSubstr(name,5,1)==2?13:8))+"liquid_buy"+StringSubstr(name, StringFind(name, "tral")+4);
         nam_S = StringSubstr(name, 0, (StringSubstr(name,5,1)==2?13:8))+"liquid_sell"+StringSubstr(name, StringFind(name, "tral")+4);
         obj_Levels[prv_pos] = (ObjectGet((obj_liqTypes[prv_pos]=="Buy"?nam_B:nam_S),OBJPROP_PRICE1)+ObjectGet(name,OBJPROP_PRICE1))/2.0;
         CreateLabel_pf(obj_Levels[prv_pos],Bars-obj_bars[obj_pos[p-1]],obj_pos[p-1],bull,"  total: "+DoubleToStr(total,0)+" ("+temp+") "+
               IntegerToString(Bars-obj_bars[obj_pos[p-1]])+" "+IntegerToString(obj_bar_cl),1,2); } }
   if (hightotal < total) hightotal = total;          else if (drawdown > total - hightotal) { drawdown = total - hightotal;
         if (hightotal) drawdwnp = (drawdown*1.0 / hightotal*1.0) * 100.0; }
#ifndef v_opfx_0
   if (t_clo) { //CreateLabel0_pf(iOpen(NULL,0,Bars-obj_bars[obj_pos0[p+1]]),Bars-obj_bars[obj_pos0[p+1]],"- test reOps - "+IntegerToString(pos)+" *",0,0,0);     // -> (0 && *(1)*
#else
   if (t_clo || (haCoef == 5 && ticket <= 7 && tim_flt >= Time[0] - Period()*60 * 7)) {
#endif
      if (ea_show && ! ((obj_liqTypes[prv_pos]=="Buy" && obj_liqTyp_2=="Sell") || (obj_liqTyp_2=="Buy" && obj_liqTypes[prv_pos]=="Sell")) && Op_Show) 
         CreateLabel0_pf(iOpen(NULL,0,Bars-obj_bars[obj_pos0[p]]),Bars-obj_bars[obj_pos0[p]],"- test reOps - "+IntegerToString(prv_pos)+"*"+
            IntegerToString(obj_pos0[p-1])+"*"+IntegerToString(obj_pos0[p])+"*"+IntegerToString(obj_pos[p-1])+"-"+IntegerToString(obj_pos[p])+" *",0,0,0);
      t_opn=false;      while (i <= (obj_pos0[p]?obj_bars[obj_pos0[p]]:Bars)) { reOpn_prs[k] = 0.0;   reClo_prs[k] = 0.0;
       t_clo=false;     for (i=i; i <= (obj_pos0[p]?obj_bars[obj_pos0[p]]:Bars) && ! t_clo; i ++) { reOpn_prs[k] = iClose(NULL,0,Bars-i);   reOpn_brs[k] = i;
//         haBull = HA_Bull(iOpen(NULL,0,Bars-i+2), iClose(NULL,0,Bars-i+2), iOpen(NULL,0,Bars-i+1), iClose(NULL,0,Bars-i+1), 
//            iHigh(NULL,0,Bars-i+1), iLow(NULL,0,Bars-i+1), iOpen(NULL,0,Bars-i), iClose(NULL,0,Bars-i), iHigh(NULL,0,Bars-i), iLow(NULL,0,Bars-i));
#ifndef v_opfx
         t_clo =#ifdef mkt_stocks (Period() != PERIOD_M1 || magic_nb != 50100600) && 
                #endif f_mqh_code(4, pos, prv_pos, i, obj_liqTypes[prv_pos], 0, reOpn_prs[k], 0); }      // boucle des reOps Label_Arrow_Test(Type= 1,      // * MQH *
#else
         if (iHigh(NULL,0,Bars-i)==iLow(NULL,0,Bars-i)) { Print("*** Error High - Low! (5) "+TimeToStr(iTime(NULL,0,Bars-i),TIME_DATE|TIME_MINUTES)+" ***");   continue; }  //Period()<=5 && 
         else { haBull = HA_Bull(1, iOpen(NULL,0,Bars-i), iClose(NULL,0,Bars-i), iHigh(NULL,0,Bars-i), iLow(NULL,0,Bars-i), Bars-i, NULL);
            if (ha_Prev || !ha_Buff || (haBull && obj_liqTypes[pos]=="Buy") || (!haBull && obj_liqTypes[pos]=="Sell"))              // boucle des reOps Label_Arrow_Test(Type= 1,
               t_clo = f_mqh_code_EA(4,pos,prv_pos,i,obj_liqTypes[prv_pos],0,reOpn_prs[k],0,params,HighVal,MrktVal,HiLoVal,DDwnVal); } }                       // * MQH *
#endif
       if (t_clo) { //if (t_clo2 < 13) { t_clo2 ++;   Label_Arrow_Test(1,prv_pos,p,i,k,reOpn_prs[k],!bull,pX,pY,total,obj_pos0,obj_pos);   pY += 34; }
         if (ea_show) { DrawArrowInt_pf(iClose(NULL,0,Bars-i+1), Bars-i+1, 3, true);         DrawArrowInt_pf(iClose(NULL,0,Bars-i+1), Bars-i+1, 5, true); }
/*         if (i >= Bars-1 && ! ticket) { DrawArrowInt_pf(bull? Bid: Ask, Bars-i+1, 2, true);        DrawArrowInt_pf(bull? Bid: Ask, Bars-i+1, 6, true);
            Print("** -> DrawArrow_OS 3 ",bull_," ",bull," ",ticket," ",Bid," ",Ask," ",i," ",(Bars-i+1)," | ",pos," ",iClose(NULL,0,Bars-i+1)," ",vScale," **");
            DrawArrow_OS(3, iClose(NULL,0,Bars-i+1)+(bull? 250*vScale*Point: 625*vScale*Point), Bars-i+1, 0, bull, 0); }   */
         orge_time = Time[Bars-i+j];                      if (i == Bars-j+1) { //t_orge = false;
            if (t_orge) Print("** -> DrawArrow_OS *3 ",bull_," ",bull," ",t_clo," ",ticket," ",Bid," ",Ask," ",i," ",j," ",Bars," ",(Bars-j-i+1)," ",TimeToStr(Time[Bars-j-i+1],
               TIME_MINUTES)," ",TimeToStr(Time[j],TIME_MINUTES)," | ",pos," ",obj_prClots[pos]," ",vScale," **");   t_orge = false;   orge_time2 = Time[j]; }
#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(25) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 25:
t_opn+" | "+p+" | "+obj_pos0[p]+" | "+obj_bars[obj_pos0[p]]+" | "+Bars+" | "+t_clo+" | "+orge_time+" | "+Time[Bars-i+j]+" | "+i+" | "+Bars+" | "+t_orge+" | "+orge_time2+" | "+Time[j]+" | "+j+" | "+ticket+" | "+Time[Bars-j-i+1]+" | "+OS3_tick+" | "+time_allow;#endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
         if (i == Bars-j && ! ticket && orge_time2 == Time[Bars-j-i+1]#ifdef v_opfx_0 && OS3_tick && time_allow) { OS3_tick = false;#else) {#endif
            DrawArrowInt_pf(bull? Ask: Bid, j, 2, true);           DrawArrowInt_pf(bull? Ask: Bid, j, 6, true);
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 25:
t_opn+" | "+p+" | "+obj_pos0[p]+" | "+obj_bars[obj_pos0[p]]+" | "+Bars+" | "+t_clo+" | "+orge_time+" | "+Time[Bars-i+j]+" | "+i+" | "+Bars+" | "+t_orge+" | "+orge_time2+" | "+Time[j]+" | "+j+" | "+ticket+" | "+Time[Bars-j-i+1]+" | "+OS3_tick+" | "+time_allow);#endif
            Print("** -> DrawArrow_OS 3* ",bull_," ",bull," ",t_clo," ",ticket," ",Bid," ",Ask," ",i," ",j," ",Bars," ",(Bars-j-i+1)," ",TimeToStr(Time[Bars-j-i+1],
               TIME_MINUTES)," ",TimeToStr(Time[j],TIME_MINUTES)," | ",pos," ",obj_prClots[pos]," ",vScale," *(25)*");      t_clo = false;    t_orge = true;
            if (! DrawArrow_OS(3, iClose(NULL,0,Bars-i+1)+(bull? 400*vScale*Point: 675*vScale*Point), j+1, 0, bull, 0))    // 250*vScale*Point: 625*vScale
                  Print("*** DrawArrow_OS 3 Error: ",GetLastError()," ***");
            else Print("** --> total = ",total,", total2 = ",total2,", total2_ = ",total2_,", total3 = ",total3,", total3_ = ",total3_,", ticket = ",ticket," **"); }
         else if (i == Bars-j && orge_time2 == Time[Bars-j-i+1]) t_orge = true;
         t_clo = false;   t_opn = true;                                                      // boucle de recherche des reCls Label_Arrow_Test(Type= 2,
         for (i=i; i <= Bars && ! t_clo; i ++) { reClo_prs[k] = iClose(NULL,0,Bars-i);       reClo_brs[k] = i;
//            haBull = HA_Bull(iOpen(NULL,0,Bars-i+2), iClose(NULL,0,Bars-i+2), iOpen(NULL,0,Bars-i+1), iClose(NULL,0,Bars-i+1), 
//               iHigh(NULL,0,Bars-i+1), iLow(NULL,0,Bars-i+1), iOpen(NULL,0,Bars-i), iClose(NULL,0,Bars-i), iHigh(NULL,0,Bars-i), iLow(NULL,0,Bars-i));
#ifndef v_opfx
            t_clo = f_mqh_code(5, pos, prv_pos, i, obj_liqTypes[prv_pos], 0, 0, reClo_prs[k]); }                                                   // * MQH *
#else
            if (iHigh(NULL,0,Bars-i)==iLow(NULL,0,Bars-i)) { Print("*** Error High - Low! (6) "+TimeToStr(iTime(NULL,0,Bars-i),TIME_DATE|TIME_MINUTES)+" ***");   continue; }  //Period()<=5 && 
            else { haBull = HA_Bull(1, iOpen(NULL,0,Bars-i), iClose(NULL,0,Bars-i), iHigh(NULL,0,Bars-i), iLow(NULL,0,Bars-i), Bars-i, NULL);
               if (ha_Prev || !ha_Buff || !((haBull && obj_liqTypes[pos]=="Buy") || (!haBull && obj_liqTypes[pos]=="Sell")))
                  t_clo = f_mqh_code_EA(5,pos,prv_pos,i,obj_liqTypes[prv_pos],0,0,reClo_prs[k],params,HighVal,MrktVal,HiLoVal,DDwnVal); } }                    // * MQH *
#endif
         if (ea_show && t_clo) { //&& t_clo3 < 13) { t_clo3 ++;    Label_Arrow_Test(2,prv_pos,p,i,k,reClo_prs[k],bull,pX,pY,total,obj_pos0,obj_pos);     pY += 34; }
            DrawArrowInt_pf(iClose(NULL,0,Bars-i+1), Bars-i+1, 3, false);        DrawArrowInt_pf(iClose(NULL,0,Bars-i+1), Bars-i+1, 5, false); }
/*         if (t_clo && i == Bars-1 && ticket) { DrawArrowInt_pf(bull? Bid: Ask, Bars-i+1, 2, false);      DrawArrowInt_pf(bull? Bid: Ask, Bars-i+1, 6, false);
            Print("** -> DrawArrow_OS 4 ",bull_," ",bull," ",ticket," ",Bid," ",Ask," ",i," ",(Bars-i+1)," | ",pos," ",iClose(NULL,0,Bars-i+1)," ",vScale," **");
            DrawArrow_OS(4, iClose(NULL,0,Bars-i+1)+(bull? 250*vScale*Point: 625*vScale*Point), Bars-i+1, 0, bull, 1); }   //ticket */
         if (t_clo) vilt_time = Time[Bars-i+j];                      if (t_clo && i == Bars-j+1) { //t_vilt = false;
            if (t_vilt) Print("** -> DrawArrow_OS *4 ",bull_," ",bull," ",t_clo," ",ticket," ",Bid," ",Ask," ",i," ",j," ",Bars," ",(Bars-j-i+1)," ",TimeToStr(Time[Bars-j-i+1],
               TIME_MINUTES)," ",TimeToStr(Time[j],TIME_MINUTES)," | ",pos," ",obj_prClots[pos]," ",vScale," **");   t_vilt = false;   vilt_time2 = Time[j]; }
#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(26) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 26:
op_case01+" | "+t_clo+" | "+i+" | "+Bars+" | "+j+" | "+ticket+" | "+vilt_time2+" | "+Time[Bars-j-i+1]+" | "+OS4_tick+" | "+time_allow+" | "+vilt_time3+" | "+Time[0]+" | "+total2_+" | "+total2;#endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
         if (op_case01 && t_clo && i == Bars-j && ticket && vilt_time2 == Time[Bars-j-i+1]#ifdef v_opfx_0 && OS4_tick && time_allow) { OS4_tick = false;#else) {#endif
            if (vilt_time3 != Time[0]) { DrawArrowInt_pf(bull? Bid: Ask, j, 2, false);        DrawArrowInt_pf(bull? Bid: Ask, j, 6, false);      total2_ = total2;
               total2 += (obj_liqTypes[prv_pos] == "Buy" ? -1 : (obj_liqTypes[prv_pos] == "Sell" ? 1 : 0)) * (reOpn_prs[k] - reClo_prs[k]) / Point - 
                  (obj_liqTypes[prv_pos] == "Buy" || obj_liqTypes[prv_pos] == "Sell" ? 1 : 0) * comm;          vilt_time3 = Time[0]; }
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 26:
op_case01+" | "+t_clo+" | "+i+" | "+Bars+" | "+j+" | "+ticket+" | "+vilt_time2+" | "+Time[Bars-j-i+1]+" | "+OS4_tick+" | "+time_allow+" | "+vilt_time3+" | "+Time[0]+" | "+total2_+" | "+total2);#endif
            Print("** -> DrawArrow_OS 4* ",bull_," ",bull," ",t_clo," ",ticket," ",Bid," ",Ask," ",i," ",j," ",Bars," ",(Bars-j-i+1)," ",TimeToStr(Time[Bars-j-i+1],
               TIME_MINUTES)," ",TimeToStr(Time[j],TIME_MINUTES)," | ",pos," ",obj_prClots[pos]," ",vScale," | ",(tmp=AccountBalance())," *(26)*");   t_clo = false;   t_vilt = true;
            if (! DrawArrow_OS(4, iClose(NULL,0,Bars-i+1)+(bull? 300*vScale*Point: 675*vScale*Point), j+1, 0, bull, ticket))     // 150*vScale*Point: 625*vScale
                  Print("*** DrawArrow_OS 4 Error: ",GetLastError()," ***");
            else { Print("** --> total = ",total,", total2 = ",total2," (",DoubleToStr(reOpn_prs[k],5)," - ",DoubleToStr(reClo_prs[k],5)," - ",TimeToStr(Time[Bars-reOpn_brs[k]],
            TIME_MINUTES)," - ",TimeToStr(Time[Bars-reClo_brs[k]],TIME_MINUTES)," - ",DoubleToStr(Bid,5)," - ",DoubleToStr(Ask,5),"), total2_ = ",total2_," (",(total2-total2_),") ...");
            Print("** --> suite total3 = ",total3," (",OrderProfit()," - ",OrderSwap()," - ",OrderCommission()," - ",DoubleToStr(OrderOpenPrice(),5)," - ",DoubleToStr(OrderClosePrice(),5),
               " - ",TimeToStr(OrderOpenTime(),TIME_MINUTES)," - ",TimeToStr(OrderCloseTime(),TIME_MINUTES),", p_Coef: ",p_Coef,", ",(OrderProfit()*p_Coef)," ",(OrderSwap()*p_Coef)," ",
               (OrderCommission()*p_Coef),") ...");                    Print("** --> suite total3_ = ",total3_," (",(total3-total3_)," ",(AccountBalance()-tmp),") | ",
               tmp," - ",AccountBalance()," - ",AccBalance," -",(AccountBalance()-AccBalance)>-0.015?" ok":"> BALANCE"," | (",ntot,") ",pos," - ",DoubleToStr(obj_Prices[pos],5)," - ",
               DoubleToStr(obj_prClots[pos],5)," | ticket = ",ticket," **"); } }
         else if (i == Bars-j && vilt_time2 == Time[Bars-j-i+1]) t_vilt = true;
         if (! t_clo) reClo_prs[k] = (obj_liqTypes[prv_pos]=="Buy" ? Bid : Ask); }     k ++; }                      // fin de boucle While **
      obj_reOps[pos][0] = obj_reOps[obj_pos[p-2]][1];      obj_reOps[pos][1] = k - 1;
      if (! obj_reOps[pos][0] && prv_pos) obj_reOps[pos][0] = k_ - 1;
      if (t_opn) { tst1 = (obj_liqTypes[prv_pos] == "Buy");// && (! prv_pos || obj_liqTypes[prv_pos] == "Sell"));     // -> (0 && *(1)*
         tst2 = (obj_liqTypes[prv_pos] == "Sell");  //(! prv_pos || obj_liqTypes[prv_pos] == "Buy") && 
         for (l = obj_reOps[pos][0]+1; l <= obj_reOps[pos][1]; l ++) if (reClo_prs[l]) {   // ou  && reClo_prs[l]
            total += (tst1 ? -1 : (tst2 ? 1 : 0)) * (reOpn_prs[l] - reClo_prs[l]) / Point - (tst1 || tst2 ? 1 : 0) * comm;    ntot = 3;
            if (pass1) Print("** --> (1c) total = ",total,", total2 = ",total2,", total2_ = ",total2_,", total3 = ",total3,", total3_ = ",total3_,
                  ", ticket = ",ticket," **");                                                                       if (ea_show && Op_Show)
            CreateLabel_pf(reClo_prs[l],Bars-reClo_brs[l],pos,!bull,"   px:"+DoubleToStr(reClo_prs[l],5)+" tot: "+DoubleToStr(total,0)+" - "+IntegerToString(pos)+" - "+IntegerToString(l),0,1); } }
//         if (obj_reOps[pos][0]+1 <= obj_reOps[pos][1]) Print("** --> (2) total = ",total,", total2 = ",total2,", total3 = ",total3,", total3_ = ",total3_,", ticket = ",ticket," **"); }
      if (total - hightotal < drawdown / 4 * 3 && Op_DDw) Print ("(2) ", pos," object "," | ",prv_pos," - ",obj_Prices[prv_pos]," - total : ",total," - hightotal : ",
         hightotal," - drawdown : ",drawdown," - ",drawdwnp?DoubleToStr(drawdwnp,1):"-.-"," % - ",obj_reOps[pos][0]," - ",obj_reOps[pos][1]," - t_clo/bleu : ",
         TimeToStr(Time[obj_bar_cl],TIME_DATE|TIME_MINUTES)," *");
      if (hightotal < total) hightotal = total;          else if (drawdown > total - hightotal) { drawdown = total - hightotal;
            if (hightotal) drawdwnp = (drawdown*1.0 / hightotal*1.0) * 100.0; } }
//   Print (pos, " object ", ObjectName(pos), " | ", prv_pos, " - ", obj_Prices[prv_pos], " - total : ", total, " *");
/* -------------------------------------------------------------------------------------------------------------------------------- */

#ifdef v_opfx
bool SO_ATS=GlobalVariableGet("Send-Order_ATS"), 
   SO_BS=GlobalVariableGet("Send-Order_BS"), SO_1=GlobalVariableGet("Send-Order_1"), 
   SO_2=GlobalVariableGet("Send-Order_2"), SO_3=GlobalVariableGet("Send-Order_3"), 
   SO_4=GlobalVariableGet("Send-Order_4"), SO_5=GlobalVariableGet("Send-Order_5");

if (SO_ATS) { temp = "** -> DrawArrow_OS ATS "+(obj_bars[prv_pos] >= Bars-1)+" "+bull+" "+Bid+" "+Ask+" "+prv_pos+" "+
      obj_bars[prv_pos]+" "+(Bars-obj_bars[prv_pos])+" "+TimeToStr(Time[Bars-obj_bars[prv_pos]],TIME_MINUTES)+" | "+pos+" "+iClose(NULL,0,Bars-i+1)+" "+vScale+
      " - Op_Liq2-4 "+Op_Liq2+"-"+Op_Liq4+" **";      DrawArrow_OS_(0, temp); }
if (SO_1) { temp = "** -> DrawArrow_OS *1 "+bull+" "+t_clo+" "+Bid+" "+Ask+" "+i+" "+j+" "+Bars+" "+(Bars-i)+" "+
      TimeToStr(Time[Bars-i],TIME_MINUTES)+" | "+pos+" "+obj_prClots[pos]+" "+vScale+" - Op_Liq2-4 "+Op_Liq2+"-"+Op_Liq4+" **";
   DrawArrow_OS_(1, temp); }
if (SO_2) { temp = "** -> DrawArrow_OS *2 "+bull+" "+Bid+" "+Ask+" "+p+" "+obj_pos[p-1]+" "+
      obj_bars[obj_pos[p-1]]+" | "+pos+" "+obj_Prices[pos]+" "+vScale+" - Op_Liq2-4 "+Op_Liq2+"-"+Op_Liq4+" **";
   DrawArrow_OS_(2, temp); }
if (SO_3) { temp = "** -> DrawArrow_OS *3 "+bull+" "+t_clo+" "+Bid+" "+Ask+" "+i+" "+Bars+" "+(Bars-i+1)+" "+
      TimeToStr(Time[Bars-i+1],TIME_MINUTES)+" | "+pos+" "+obj_prClots[pos]+" "+vScale+" - Op_Liq2-4 "+Op_Liq2+"-"+Op_Liq4+" **";
   DrawArrow_OS_(3, temp); }
if (SO_4) { temp = "** -> DrawArrow_OS *4 "+bull+" "+t_clo+" "+Bid+" "+Ask+" "+i+" "+Bars+" "+(Bars-i+1)+" "+
      TimeToStr(Time[Bars-i+1],TIME_MINUTES)+" | "+pos+" "+obj_prClots[pos]+" "+vScale+" - Op_Liq2-4 "+Op_Liq2+"-"+Op_Liq4+" **";
   DrawArrow_OS_(4, temp); }
if (SO_5) { temp = "** -> DrawArrow_OS *5 "+(obj_bars[prv_pos] >= Bars-1)+" "+bull+" "+Bid+" "+Ask+" "+prv_pos+" "+
      obj_bars[prv_pos]+" "+(Bars-obj_bars[prv_pos])+" "+TimeToStr(Time[Bars-obj_bars[prv_pos]],TIME_MINUTES)+" | "+pos+" "+iClose(NULL,0,Bars-i+1)+" "+vScale+
      " - Op_Liq2-4 "+Op_Liq2+"-"+Op_Liq4+" **";      DrawArrow_OS_(5, temp); }

GlobalVariableSet("Send-Order_ATS", false);     GlobalVariableSet("Send-Order_1", false);
GlobalVariableSet("Send-Order_2", false);       GlobalVariableSet("Send-Order_3", false);
GlobalVariableSet("Send-Order_4", false);       GlobalVariableSet("Send-Order_5", false);
#endif
  if (WM != WindowPriceMax()) ObjectsPositions(vScale);
//  if (bull != bull_) Print("*** -> bull CHANGED! ",ticket," - ",bull_," - ",bull," ***");
  if (ObjectType("EA_Check-"+stmfr+"-1_0 "+IntegerToString(Time[0])) > 0 || ObjectType("EA_Check-"+stmfr+"-5_0 "+IntegerToString(Time[0])) > 0) {}
//      Print("** -> DrawArrow_chk EXISTS! EA_Check1_0 "+IntegerToString(Time[0])+" **");
#ifndef v_opfx_0
  else if (! DrawArrow_chk(WindowPriceMax()-50 * vScale*Point,0, 1)) Print("*** DrawArrow_chk Error (1): ",GetLastError()," ***");
  if (obj_bars[prv_pos] >= Bars-1 && (! ticket || (bull_ == NULL && bull_ != false) || ((bull && ! bull_) || (! bull && bull_)))) {
#else
  else if (! DrawArrow_chk(WindowPriceMax()-(t_night?130: 50) * vScale*Point, 0, t_night? 5: 1)) Print("*** DrawArrow_chk Error (1): ",GetLastError()," ***");
  if (Liqu_x2 && obj_bars[prv_pos] >= Bars-1 && time_allow) { if (liqu_x2_n < 3) Liqu_x2_tf(str);     liqu_x2_n ++; }
  tst1 = ! ticket || (bull_==NULL && bull_!=false) || (bull && ! bull_) || (! bull && bull_);
  tst2 = t_rsi515o || (tim_flt < TimeCurrent() - Period()*60 * 5 && tim_flt > TimeCurrent() - Period()*60 * 7 &&
   ((last_ntr_pr > Ask && ! bull) || (last_ntr_pr < Bid && bull)) && last_liq_t1 < TimeCurrent() - Period()*60 * 5 && last_liq_t1 > TimeCurrent() - Period()*60 * 7);
#ifdef v_dump_1   string f_tmp_ = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(27) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +   //      case 27:
OS5_tick+" | "+Bars+" | "+p+" | "+obj_pos[p-1]+" | "+obj_bars[obj_pos[p-1]]+" | "+obj_Prices[prv_pos]+" | "+obj_pos[p-2]+" | "+obj_bars[obj_pos[p-2]]+" | "+iOpen(NULL,0,Bars-obj_bars[obj_pos[p-2]])+" | "+
rate1c+" | "+rate2c+" | "+rate3c+" | "+rate4c+" | "+iClose(NULL,0,Bars-obj_bars[obj_pos[p-2]])+" | "+total2_; #endif
#ifdef v_dump_2   copy_file_45(4, f_tmp_); #endif
  if ((obj_bars[prv_pos] >= Bars-1 || ((tmf_Diff || tst2) && tst1)) && OS5_tick && time_allow && (tst1 || (tmf_Diff && ((! OrderType() && 
   obj_liqTypes[prv_pos] == "Sell") || ((OrderType() || ticket <= 7) && obj_liqTypes[prv_pos] == "Buy")))) && 
   (! t_rsi515 || H1 > H3 || (Hour() > 9 && Time[0] - OrderOpenTime() > 7200)) && (haCoef < 5 || tim_flt < TimeCurrent() - Period()*60 * 5) && ! no_OS5 &&
   ((last_ntr_pr > Ask && ! bull) || (last_ntr_pr < Bid && bull)) && last_ntr_pr) { // du à un faux signal sur XAUUSD le 04-06-2021 à 14h45 mk-time, la Liquid_Sell a disparu après
#endif
      if (ObjectType("EA_Check-"+stmfr+"-2_0 "+IntegerToString(Time[0])) > 0) {}
//         Print("** -> DrawArrow_chk EXISTS! EA_Check2_0 "+IntegerToString(Time[0])+" **");
      else if (! DrawArrow_chk(WindowPriceMax()-310*vScale*Point,0,#ifdef v_opfx_0 t_night?5:2#else 2#endif)) Print("*** DrawArrow_chk Error (2): ",GetLastError()," ***");   //iClose(NULL,0,0)
#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(7) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 7:
tst1+" | "+ticket+" | "+bull_+" | "+bull+" | "+tst2+" | "+t_rsi515o+" | "+tim_flt+" | "+TimeCurrent()+" | "+Period()+" | "+last_ntr_pr+" | "+Ask+" | "+Bid+" | "+last_liq_t1+" | "+
obj_bars[prv_pos]+" | "+Bars+" | "+tmf_Diff+" | "+OS5_tick+" | "+time_allow+" | "+OrderType()+" | "+obj_liqTypes[prv_pos]+" | "+ticket+" | "+t_rsi515+" | "+H1+" | "+H3+" | "+Hour()+" | "+
Time[0]+" | "+OrderOpenTime()+" | "+haCoef+" | "+tim_flt+" | "+no_OS5+" | "+Ask+" | "+Bid+" | "+H2+" | "+m3_RSI(0, 2)+" | "+t1+" | "+t_M5_M15+" | "+tim_M15+" | "+liqu_x2_n; #endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
     #ifdef v_opfx_0 if (Hour() > H2 - 2 && m3_RSI(0, 2) > 40 && m3_RSI(0, 2) < 60 && Period() == PERIOD_M5 && ! tst2 && (H1 < H3 || Hour() > H2 + 2)) { t1 = 0;        // Hour() != H1
         while(! (tst=ChartSetSymbolPeriod(0, NULL, PERIOD_M15)) && t1 < 17) { t1 ++;        Sleep(100); }
         if (tst) { t_M5_M15 = true;           GlobalVariableSet(tmfr0_str, PERIOD_M15);     tim_M15 = Time[0];         liqu_x2_n = 0;       tmf_Diff = true;
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 7:
tst1+" | "+ticket+" | "+bull_+" | "+bull+" | "+tst2+" | "+t_rsi515o+" | "+tim_flt+" | "+TimeCurrent()+" | "+Period()+" | "+last_ntr_pr+" | "+Ask+" | "+Bid+" | "+last_liq_t1+" | "+
obj_bars[prv_pos]+" | "+Bars+" | "+tmf_Diff+" | "+OS5_tick+" | "+time_allow+" | "+OrderType()+" | "+obj_liqTypes[prv_pos]+" | "+ticket+" | "+t_rsi515+" | "+H1+" | "+H3+" | "+Hour()+" | "+
Time[0]+" | "+OrderOpenTime()+" | "+haCoef+" | "+tim_flt+" | "+no_OS5+" | "+Ask+" | "+Bid+" | "+H2+" | "+m3_RSI(0, 2)+" | "+t1+" | "+t_M5_M15+" | "+tim_M15+" | "+liqu_x2_n);
copy_file_45(5, "7_;"+TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+";"+IntegerToString(TimeCurrent())+";"+IntegerToString(Period())); #endif
            temp = "** Passage en M15 (1) à "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" ! (Period()="+IntegerToString(Period())+", t1="+IntegerToString(t1)+") *(7)*";
            Print(temp);      copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp); } }        else { OS5_tick = false;
     #endif if (Bars != obj_bars[obj_pos[p-1]]) tmp = obj_Prices[prv_pos];    else tmp = (iOpen(NULL,0,Bars-obj_bars[obj_pos[p-2]]) * (rate1c? 5.0: rate2c? 4.0: 
         rate3c? 3.0: rate4c? 2.0: 1.0) + iClose(NULL,0,Bars-obj_bars[obj_pos[p-2]]) * (rate1c? 1.0: rate2c? 2.0: rate3c? 3.0: rate4c? 4.0: 5.0)) / 6.0;
      total2_ = total2;   /* total2 += (prv_pos? (obj_liqTypes[prv_pos]=="Sell"? 1: obj_liqTypes[prv_pos]=="Buy"? -1: 0): 0) * (tmp - (bull? Bid: Ask))/Point
         - (obj_liqTypes[prv_pos] == "Buy" || obj_liqTypes[prv_pos] == "Sell" ? 1 : 0) * comm;  */    // total2 à revoir dans cette partie    ***
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp_, 0, StringFind(f_tmp_, "\r")) #else f_tmp_ #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+ // case 27:
OS5_tick+" | "+Bars+" | "+p+" | "+obj_pos[p-1]+" | "+obj_bars[obj_pos[p-1]]+" | "+obj_Prices[prv_pos]+" | "+obj_pos[p-2]+" | "+obj_bars[obj_pos[p-2]]+" | "+iOpen(NULL,0,Bars-obj_bars[obj_pos[p-2]])+" | "+
rate1c+" | "+rate2c+" | "+rate3c+" | "+rate4c+" | "+iClose(NULL,0,Bars-obj_bars[obj_pos[p-2]])+" | "+total2_); #endif
      Print("** -> DrawArrow_OS 5 ",(obj_bars[prv_pos] >= Bars-1 && (!ticket || bull_==NULL || (bull && ! bull_) || (! bull && bull_)))," ",
         (obj_bars[prv_pos] >= Bars-1)," ",(!ticket || bull_==NULL || (bull && ! bull_) || (! bull && bull_)), " ", bull_, " ", bull, " ",
         ticket, " ", Bid, " ", Ask, " ", prv_pos, " ", obj_bars[prv_pos], " ", (Bars-obj_bars[prv_pos]), " ", TimeToStr(Time[Bars-obj_bars[prv_pos]],
         TIME_MINUTES)," | ",pos," ",iClose(NULL,0,Bars-i+1)," ",vScale," | ",(tmp2=AccountBalance())+ " | " +
/*   ((obj_bars[prv_pos] >= Bars-1 || tmf_Diff) && OS5_tick && time_allow && (!ticket || (bull_==NULL && bull_!=false) || ((bull && ! bull_) || (! bull && bull_)) ||
   (tmf_Diff && ((! OrderType() && obj_liqTypes[prv_pos] == "Sell") || ((OrderType() || (ticket <= 7 && ! MQLInfoInteger(MQL_TESTER)) ||
   ! ticket) && obj_liqTypes[prv_pos] == "Buy")))) && (! t_rsi515 || H1 > H3 || (Hour() > 9 && Time[0] - OrderOpenTime() > 7200)) && haCoef < 5 &&
   tim_flt < TimeCurrent() - Period()*60 * 2 && ((last_ntr_pr > Ask && ! bull) || (last_ntr_pr < Bid && bull)) && last_ntr_pr) + " | " + */
   ((obj_bars[prv_pos] >= Bars-1 || ((tmf_Diff || tst2) && tst1)) && time_allow && (tst1 || (tmf_Diff && ((! OrderType() &&     // && OS5_tick
   obj_liqTypes[prv_pos] == "Sell") || ((OrderType() || ticket <= 7) && obj_liqTypes[prv_pos] == "Buy")))) && 
   (! t_rsi515 || H1 > H3 || (Hour() > 9 && Time[0] - OrderOpenTime() > 7200)) && (haCoef < 5 || tim_flt < TimeCurrent() - Period()*60 * 5) && 
   ((last_ntr_pr > Ask && ! bull) || (last_ntr_pr < Bid && bull)) && last_ntr_pr) + " | " + tst1 + " | " + tst2 + " | " + no_OS5 + " | " +
   (obj_bars[prv_pos] >= Bars-1 || ((tmf_Diff || tst2) && tst1)) + " | " + OS5_tick + " | " + time_allow + " | " + (tst1 || (tmf_Diff && ((! OrderType() &&
   obj_liqTypes[prv_pos] == "Sell") || ((OrderType() || ticket <= 7) && obj_liqTypes[prv_pos] == "Buy")))) + " | " +
   (! t_rsi515 || H1 > H3 || (Hour() > 9 && Time[0] - OrderOpenTime() > 7200)) + " | " + (haCoef < 5 || tim_flt < TimeCurrent() - Period()*60 * 5) + " | " +
   ((last_ntr_pr > Ask && ! bull) || (last_ntr_pr < Bid && bull)) + " | " + last_ntr_pr," *(27)*"); //*/
      tmf_Diff_b = Bars - obj_bars[prv_pos];                                           // v Bars-obj_bars[prv_pos]
      if (! DrawArrow_OS(5, obj_Levels[prv_pos]+(bull? 400*vScale*Point: 300*vScale*Point), 0, 0, bull, 0))    //250*vScale*Point: 250*vScale
            Print("*** DrawArrow_OS 5 Error: ",GetLastError()," ***");
//Print("** --> total = ",total,", total2 = ",total2,", total2_ = ",total2_,", total3 = ",total3,", total3_ = ",total3_,", ticket = ",ticket," **");     // ?
      else { total2 += total3 - total3_;              // total2 n'a pas d'intérêt dans cette partie
         Print("** --> total = ",total,", total2 = ",total2," (",DoubleToStr(tmp,5)," - ",DoubleToStr(iClose(NULL,0,0),5)," - ",TimeToStr(Time[Bars-obj_bars[obj_pos[p-
            (Bars!=obj_bars[obj_pos[p-1]]?1:2)]]],TIME_MINUTES)," - ",TimeToStr(Time[Bars-i+1],TIME_MINUTES)," | ",DoubleToStr(Bid,5)," - ",DoubleToStr(Ask,5),"), total2_ = ",
            total2_," (",(total2-total2_),") ...");
         Print("** --> suite total3 = ",total3," (",OrderProfit()," - ",OrderSwap()," - ",OrderCommission()," - ",DoubleToStr(OrderOpenPrice(),5)," - ",DoubleToStr(OrderClosePrice(),5),
            " - ",TimeToStr(OrderOpenTime(),TIME_MINUTES)," - ",TimeToStr(OrderCloseTime(),TIME_MINUTES),", p_Coef: ",p_Coef,", ",(OrderProfit()*p_Coef)," ",(OrderSwap()*p_Coef)," ",
            (OrderCommission()*p_Coef),") ...");                    Print("** --> suite total3_ = ",total3_," (",(total3-total3_)," ",(AccountBalance()-tmp2),") | ",
            tmp2," - ",AccountBalance()," - ",AccBalance," -",(AccountBalance()-AccBalance)>-0.015?" ok":"> BALANCE"," | ticket = ",ticket," ...");
         Print("** --> suite (",ntot,") ",pos," - ",DoubleToStr(obj_Prices[pos],5)," - ",DoubleToStr(obj_prClots[pos],5)," - ",prv_pos," - ",
            DoubleToStr(obj_Prices[prv_pos],5)," - ",DoubleToStr(obj_prClots[prv_pos],5)," **"); }
      if (tst_5b && ! DrawArrow_end(bull? Ask: Bid, Bars-obj_bars[prv_pos], 2, bull, 0)) Print("*** DrawArrow_end Error(1): ",GetLastError()," ***");
      if (tst_5b && ! DrawArrow_end(bull? Ask: Bid, Bars-obj_bars[prv_pos], 6, bull, 0)) Print("*** DrawArrow_end Error(2): ",GetLastError()," ***");
      this_Order_Time = TimeCurrent();    this_Order_Price = bull? Ask: Bid;     t_blue = true;     t_vilt = true;     t_orge = true;     bull_ = bull;
      GlobalVariableSet("th_O_P", this_Order_Price);     GlobalVariableSet("th_O_T", this_Order_Time);      GlobalVariableSet("th_O_B", bull); }#ifdef v_opfx_0 }
  else if ((obj_bars[prv_pos] >= Bars-1 || tmf_Diff) && so_cpt < 2) { so_cpt ++;
      Print("*** DrawArrow_OS (*)5 "+(!ticket || (bull_==NULL && bull_!=false) || ((bull && ! bull_) || (! bull && bull_))) + " " + (bull_==NULL && bull_!=false) + " " +
         (bull && ! bull_)+" "+(! bull && bull_)+" - "+bull_+" "+bull+" " + t_rsi515 + " " + OS5_tick + " " + time_allow + " " + haCoef + " " + IntegerToString(ticket) + " " +
         TimeToStr(tim_flt, TIME_MINUTES) + " " + TimeToStr(Time[0], TIME_MINUTES) + " " + DoubleToStr(last_ntr_pr, Digits()) + " " + DoubleToStr(bull? Bid: Ask, Digits()) + 
         " " + (tmf_Diff && ((! OrderType() && obj_liqTypes[prv_pos]=="Sell") || ((OrderType() || ticket <= 7) &&
         obj_liqTypes[prv_pos]=="Buy"))) + " " + tmf_Diff + " " + OrderType() + " " + (!t_rsi515 || H1>H3 || (Hour()>9 && Time[0]-OrderOpenTime()
         > 7200)) + " " + (tim_flt < TimeCurrent() - Period()*60 * 2) + " " + ((last_ntr_pr > Ask && ! bull) || (last_ntr_pr < Bid && bull)) + " " + last_ntr_pr + " " + 
         obj_liqTypes[prv_pos] + " " + ticket + " | " +
/*   ((obj_bars[prv_pos] >= Bars-1 || tmf_Diff) && OS5_tick && time_allow && (!ticket || (bull_==NULL && bull_!=false) || ((bull && ! bull_) || (! bull && bull_)) ||
   (tmf_Diff && ((! OrderType() && obj_liqTypes[prv_pos] == "Sell") || ((OrderType() || (ticket <= 7 && ! MQLInfoInteger(MQL_TESTER)) ||
   ! ticket) && obj_liqTypes[prv_pos] == "Buy")))) && (! t_rsi515 || H1 > H3 || (Hour() > 9 && Time[0] - OrderOpenTime() > 7200)) && haCoef < 5 &&
   tim_flt < TimeCurrent() - Period()*60 * 2 && ((last_ntr_pr > Ask && ! bull) || (last_ntr_pr < Bid && bull)) && last_ntr_pr) + " | " + */
   ((obj_bars[prv_pos] >= Bars-1 || ((tmf_Diff || tst2) && tst1)) && OS5_tick && time_allow && (tst1 || (tmf_Diff && ((! OrderType() && 
   obj_liqTypes[prv_pos] == "Sell") || ((OrderType() || ticket <= 7) && obj_liqTypes[prv_pos] == "Buy")))) && 
   (! t_rsi515 || H1 > H3 || (Hour() > 9 && Time[0] - OrderOpenTime() > 7200)) && (haCoef < 5 || tim_flt < TimeCurrent() - Period()*60 * 5) && 
   ((last_ntr_pr > Ask && ! bull) || (last_ntr_pr < Bid && bull)) && last_ntr_pr) + " | " + tst1 + " | " + tst2 + " | " + no_OS5 + " | " +
   (obj_bars[prv_pos] >= Bars-1 || ((tmf_Diff || tst2) && tst1)) + " | " + OS5_tick + " | " + time_allow + " | " + (tst1 || (tmf_Diff && ((! OrderType() &&
   obj_liqTypes[prv_pos] == "Sell") || ((OrderType() || ticket <= 7) && obj_liqTypes[prv_pos] == "Buy")))) + " | " +
   (! t_rsi515 || H1 > H3 || (Hour() > 9 && Time[0] - OrderOpenTime() > 7200)) + " | " + (haCoef < 5 || tim_flt < TimeCurrent() - Period()*60 * 5) + " | " +
   ((last_ntr_pr > Ask && ! bull) || (last_ntr_pr < Bid && bull)) + " | " + last_ntr_pr + " ***"); }
  else if (obj_bars[prv_pos] < Bars-1 && ! tmf_Diff) so_cpt = 0;
#endif
//  total += (prv_pos ? (obj_liqTypes[prv_pos] == "Sell" ? 1 : obj_liqTypes[prv_pos] == "Buy" ? -1 : 0) : 0) * (obj_Prices[prv_pos] - iClose(NULL,0,0)) / Point;
  DrawArrow(((bull=(obj_liqTypes[prv_pos]=="Sell")) ? obj_Levels[prv_pos]+100*vScale*Point : obj_Levels[prv_pos]+250*vScale*Point), Bars-obj_bars[prv_pos], 0, bull,0);
  if (ea_show) { DrawArrow(obj_Prices[prv_pos], Bars-obj_bars[prv_pos], 3, !bull,0);     DrawArrow(obj_Prices[prv_pos], Bars-obj_bars[prv_pos], 5, !bull,0);
     CreateLabel(obj_Levels[prv_pos],Bars-obj_bars[prv_pos],pos,!bull,"   px: "+DoubleToStr(obj_Prices[prv_pos],5)+" "+DoubleToStr(obj_prClots[pos],5),0,0); }
  ObjectDelete(LabelNameEnd);          LabelNameEnd = NULL;
  CreateLabel_end(0,0,obj_total,!bull,"  total: "#ifdef v_opfx+"(opfx) "#endif+DoubleToStr(total/(strTot?100/myLot:1),2)+" ("+(ticket? endbull? "buy": "sell": "end")+")",0,0);
  if (exp_1 || exp_2) CreateLabel_end(0,0,exp_1+exp_2,NULL,"* exp_1: "+IntegerToString(exp_1)+" - exp_2: "+IntegerToString(exp_2)+" * ",1,0);
  if (hightotal < total) hightotal = total;           else if (drawdown > total - hightotal) { drawdown = total - hightotal;
         if (hightotal) drawdwnp = (drawdown*1.0 / hightotal*1.0) * 100.0; }
//  Print (pos, " (1) object LAST | ", (ObjectType(StringSubstr(name,0,(StringSubstr(name,5,1)==2?13:8))+"liquid_buy"+StringSubstr(name, StringFind(name, "tral")+4)) 
//      > 0 ? "Sell" : (ObjectType(StringSubstr(name,0,(StringSubstr(name,5,1)==2?13:8))+"liquid_sell"+StringSubstr(name, StringFind(name,"tral")+4))>0? "Buy ": "Err ")), " ",
//      prv_pos, " - ", obj_Prices[prv_pos], " - ", iClose(NULL,0,0), " - ", iClose(NULL,0,0), " - ", pos, " - ", obj_pos[p+1], " - ", p, " - total : ", total, " *");

#ifndef v_opfx_0
  int tmpHiLo, total_;     tst = false;      ObjectsDelete(0, "Chck2");       ObjectsDelete(0, "Stop");
  bool bullish;      total = 0;     for (i = Bars-nBars; i <= Bars; i ++) {      // <- attention Bars-300 **
#else
  int ind_total = ChartIndicatorsTotal(0,0);    bool t_ind300;    temp = NULL;   for (int ind = 0; ind < ind_total && (t_ind300=(temp==NULL)); ind ++)
      if (StringFind((name=ChartIndicatorName(0,0,ind)), "ATS") > 0) temp = StringSubstr(name, StringFind(name, "(")+1, 3);
  int tmpHiLo, total_;     tst = false;      //if (! t_ind300 && pass1) { ObjectsDelete(0, "Chck2", 1, 0);      ObjectsDelete(0, "Stop", 1, 0); }
  bool bullish;      total = 0;        tim_flt_ = tim_flt > 0 ? tim_flt : tim_flt_;
  for (i = Bars - (pass1 ? nBars : fmin(nBars, iBarShift(NULL,0, fmax(tim_flt,tim_flt_), false))); i <= Bars; i ++) {
#endif
      tmpHiLo = int (((iHigh(NULL,0,Bars-i+5)-iLow(NULL,0,Bars-i+5)) + (iHigh(NULL,0,Bars-i+1)-iLow(NULL,0,Bars-i+1)) + (iHigh(NULL,0,Bars-i+2)-
         iLow(NULL,0,Bars-i+2)) + (iHigh(NULL,0,Bars-i+3)-iLow(NULL,0,Bars-i+3)) + (iHigh(NULL,0,Bars-i+4)-iLow(NULL,0,Bars-i+4))) / Point / 5);
//      StDev = iStdDev(NULL, 0, 5, Bars-i+1, MODE_SMA, PRICE_TYPICAL, 0) / Point / Mltp;    // écartype **
      if ((iHigh(NULL,0,Bars-i) - iLow(NULL,0,Bars-i)) / Point > tmpHiLo * 2.2) {   //&&
//      iCustom(NULL, PERIOD_H1, "New folder\\ADX.ex4", 0, Bars-i) < 45) {         // && StDev < 2   **
//         CreateLabel((WindowPriceMax(0)+iHigh(NULL,0,Bars-i+5))/2-55*Point, Bars-i-1, 0, 1, DoubleToStr(StDev, 2), 0, 0);
//CreateLabel((WindowPriceMax(0)+iHigh(NULL,0,Bars-i+5))/2-55*Point, Bars-i-1, 0, 1, DoubleToStr(iCustom(NULL,PERIOD_H1,"New folder\\ADX.ex4",0,Bars-i),2),0,0);
         DrawArrow_chst((WindowPriceMax(0) + 2*iHigh(NULL,0,Bars-i+5)) / 3, Bars-i+5, 3);
         DrawArrow_chst((WindowPriceMax(0) + 2*iHigh(NULL,0,Bars-i+5)) / 3, Bars-i+4, 3);
         DrawArrow_chst((WindowPriceMax(0) + 2*iHigh(NULL,0,Bars-i+5)) / 3, Bars-i+3, 3);
         DrawArrow_chst((WindowPriceMax(0) + 2*iHigh(NULL,0,Bars-i+5)) / 3, Bars-i+2, 3);
         DrawArrow_chst((WindowPriceMax(0) + 2*iHigh(NULL,0,Bars-i+5)) / 3, Bars-i+1, 3);
         DrawArrow_chst((WindowPriceMax(0) + 2*iHigh(NULL,0,Bars-i+5)) / 3, Bars-i, 4);
         tst1 = false;               tst = (i >= Bars-1);
         bullish = (iClose(NULL,0,Bars-i) > (iHigh(NULL,0,Bars-i)+iLow(NULL,0,Bars-i)) / 2);
         for (p = 1; obj_pos0[p] && ! tst1; p ++) if (obj_bars[obj_pos0[p]] > i) { tst1 = true;
            total += (total_=(obj_liqTypes[obj_pos0[p]]=="Buy" && ! bullish) || (obj_liqTypes[obj_pos0[p]]=="Sell" && bullish)? 
               (((iHigh(NULL, 0, Bars-i)-iLow(NULL, 0, Bars-i))*(1.0-Profit_Back)*(bullish? 1: -1) +
               (bullish? iLow(NULL, 0, Bars-i): iHigh(NULL, 0, Bars-i))) * (bullish? 1: -1) +
               obj_Prices[obj_pos0[p]] * (bullish? -1: 1)) / Point: 0); }
//Print("*** "+DoubleToStr(total_/(strTot?100/myLot:1),2)+" - "+DoubleToStr(total/(strTot?100/myLot:1),2)+" | "+IntegerToString(Bars-i)+" - "+IntegerToString(p)+" ***"); }
         if (total_) CreateLabel_st((WindowPriceMax(0)+iHigh(NULL,0,Bars-i+5))/2, Bars-i-1, DoubleToStr(iHigh(NULL,0,Bars-i), 0)+" "+
            DoubleToStr(iLow(NULL, 0, Bars-i), 0)+" "+DoubleToStr((iHigh(NULL, 0, Bars-i)-iLow(NULL, 0, Bars-i))*(1.0-Profit_Back), 0)+
            " "+DoubleToStr(total_/(strTot?100/myLot:1),2), bullish, 0);
         if (! tst1) total += (((iHigh(NULL, 0, Bars-i)-iLow(NULL, 0, Bars-i))*(1.0-Profit_Back)*(bullish? 1: -1) +
               (bullish? iLow(NULL, 0, Bars-i): iHigh(NULL, 0, Bars-i))) * (bullish? 1: -1) +
               (bullish? Bid: Ask) * (bullish? -1: 1)) / Point; } }        //obj_liqTypes[obj_pos0[p]]
#ifndef v_opfx_0
  ObjectDelete(LabelNameEnd2);            LabelNameEnd2 = NULL;         if (tst) { haCoef = 5;     tim_flt = Time[0]; }
  CreateLabel_end(0,0,obj_total,!bull," -> correction : "+DoubleToStr(total/(strTot?100/myLot:1),strTot?2:0)+(strTot?" $":"")+" (StTrd)",0,1);
  if (fl_Trade && tst && ticket && (Hour() || Minute() > 12) && (Hour() < H3 || Minute() < 44))    // 23
      FollowTrade(Bid > (iHigh(NULL,0,0)+iLow(NULL,0,0)) / 2); //*/
  if (St_Trd && TimeCurrent() > Time[0] && TimeCurrent() - Time[0] <= 2) { St_Trd = false;   Profit_Top = 0.0;    Profit_Bottom = 500000.0; }

#else
//Alert("*****1* "+Fl_Trade+" "+fl_Trade+" "+tst+" "+LabelNameStp+" *****");
  ObjectDelete(LabelNameEnd2);            LabelNameEnd2 = NULL;            if (tst) { haCoef = 5;
      if (((last_ntr_pr > Ask && ! OrderType()) || (last_ntr_pr < Bid && OrderType())) && last_ntr_pr && OrderSelect(ticket, SELECT_BY_TICKET) &&
      ! tim_flt && (((iHigh(NULL,0,0) + iLow(NULL,0,0)) / 2 > Ask && ! OrderType()) || ((iHigh(NULL,0,0) + iLow(NULL,0,0)) / 2 < Bid && OrderType()))) {
         tmp = DoubleToStr(OrderStopLoss(), Digits);        while(StringSubstr(tmp, StringLen(tmp)-1) == "0") tmp = StringSubstr(tmp, 0, StringLen(tmp)-1);
         if (OrderModify(ticket,OrderOpenPrice(),fabs(OrderOpenPrice()-OrderStopLoss())*(OrderType()? 1.5: -1.5)+OrderOpenPrice(),OrderTakeProfit(),0, clrSkyBlue)) {} }
      tim_flt = Time[0];      fl_Trade = Fl_Trade;       ObjectSet(LabelNameStp, OBJPROP_ARROWCODE, fl_Trade ? 252: 253); }
  CreateLabel_end(0,0,obj_total,!bull," -> correction : "+DoubleToStr(total/(strTot?100/myLot:1),strTot?2:0)+(strTot?" $":"")+" (StTrd)",0,1);
  if (fl_Trade && tst && ticket && (Hour() || Minute() > 12) && (Hour() < H3 || Minute() < 44)) {  // 23
      FollowTrade(Bid > (iHigh(NULL,0,0)+iLow(NULL,0,0)) / 2); //*/
      if (cresult) { ticket = 0;       GlobalVariableSet(tck_vstr, 0);     cresult = false; } }
//if (cresult) Alert("***** Stop Suiveur Atteint (VM"+IntegerToString(Period())+") Trade Cloturé. ("+LabelNameStp+") *****");
//else  Alert("*****2* "+fl_Trade+" "+tst+" "+LabelNameStp+" *****");
  if (St_Trd && (! ticket || tim_flt < Time[0])) { St_Trd = false;
      Profit_Top = 0.0;       Profit_Bottom = 500000.0;        LabelNameSt2 = ""; }

  int dgts=Digits() > 3 ? Digits() : Bid > 10000 ? 2 : 3, K;      double douHiLo, rect_H;
  bool t_ngt1, t_Ntcks=(str=="-HKG" || str=="-CHN" || str=="-GLD");
  bull = ! bull;    // car inversé sur < DrawArrow(((bull=(obj_liqTypes[prv_pos]=="Sell")) ?... >, 45 lignes plus haut
  if (AccountEquity() > 0 && AccBalance_day - AccountEquity() > 0.2 * AccBalance_day) Close_All_Trades();
  if (curr_time < Time[0] && ((((H1 > H3 && Hour() == H2) || (H1 < H3 && Hour() == H1)) && ! Minute()) || ! AccBalance_day)) {
      AccBalance_day = AccountBalance();           if (GlobalVariableCheck("t_ngt_3")) GlobalVariableDel("t_ngt_3"); }
  if (curr_time < Time[0] && iHigh(NULL, 0, 1) > iLow(NULL, 0, 1)) { if (! pass1 || curr_time) /*
         if (! (Time[0] % (Period() * 120))) { ArrayResize(ExtOpenBuffer, nBars);    ArrayResize(ExtCloseBuffer, nBars);    HA_Buffers(1); }
         else */{ ha1Close = (iOpen(NULL, 0, 1) + iHigh(NULL, 0, 1) + iLow(NULL, 0, 1) + iClose(NULL, 0, 1)) / 4;
            ha1Open = (ExtOpenBuffer[ArraySize(ExtOpenBuffer)-2] + ExtCloseBuffer[ArraySize(ExtCloseBuffer)-2]) / 2;
            for(i = ArraySize(ExtOpenBuffer)-1; i >= 0; i --) {
               ExtCloseBuffer[ArraySize(ExtCloseBuffer) - i-1] = ExtCloseBuffer[ArraySize(ExtCloseBuffer) - i];
               ExtOpenBuffer[ArraySize(ExtOpenBuffer) - i-1] = ExtOpenBuffer[ArraySize(ExtOpenBuffer) - i]; }
            ExtCloseBuffer[ArraySize(ExtCloseBuffer) - 2] = ha1Close;
            ExtOpenBuffer[ArraySize(ExtOpenBuffer) - 2] = ha1Open; }
      habull = HA_Bull(3, iOpen(NULL, 0, 1), iClose(NULL, 0, 1), iHigh(NULL, 0, 1), iLow(NULL, 0, 1), 1, NULL);
      douHiLo = (((iHigh(NULL, 0, 5) - iLow(NULL, 0, 5)) + (iHigh(NULL, 0, 1) - iLow(NULL, 0, 1)) + (iHigh(NULL, 0, 2) -
         iLow(NULL, 0, 2)) + (iHigh(NULL, 0, 3) - iLow(NULL, 0, 3)) + (iHigh(NULL, 0, 4) - iLow(NULL, 0, 4))) / 5 +
         (fabs(iOpen(NULL,0,5) - iClose(NULL,0,5)) + fabs(iOpen(NULL,0,1) - iClose(NULL,0,1)) + fabs(iOpen(NULL,0,2) -
         iClose(NULL,0,2)) + fabs(iOpen(NULL,0,3)-iClose(NULL,0,3)) + fabs(iOpen(NULL,0,4)-iClose(NULL,0,4))) / 5) / 3 / haCoef;
      Alert ("***** "+str+" "+habull+" "+DoubleToStr(ha1Open, dgts)+" "+ha1Close+" "+DoubleToStr(haOpen, dgts)+" "+haClose+" "+
         DoubleToStr(haHigh, dgts)+" "+DoubleToStr(haLow, dgts)+" "+DoubleToStr(douHiLo, dgts)+" *****");      List_vTmFr();
      curr_time = Time[0];       t_TST1 = true;    t_TST2 = true;    OS6_tick = true;     OS9_tick = true;     no_OS5 = false;
      OS1_tick = true;     OS2_tick = true;     OS3_tick = true;     OS4_tick = true;     OS5_tick = true;     tmf_Diff = false;
      if (GlobalVariableCheck("t_ngt_1")) t_ngt1 = GlobalVariableGet("t_ngt_1");    if (t_ngt1 && (str=="-HKG" || str=="-CHN")) H3 = 10;
      if (t_Ntcks && Hour() < 6 && nb_ticks > 2 && nb_ticks == nb_tcks_N + 1) Print("** -> (2) nb_ticks > 2 && nb_ticks == nb_tcks_N + 1 : ",
         IntegerToString(nb_ticks) , " " , IntegerToString(nb_tcks_N) , " " , ticket , " " , t_night , " " , t_ngt1 , " " , TimeToStr(Time[0],TIME_MINUTES) , " **");
/*      for (i = 0; i < ArraySize(obj_LiqPrs); i ++) {  for (j = obj_bars[i]-1; j < nBars; j ++) {
            if ((obj_liqTypes[i] == "Buy" && iLow(NULL, 0, nBars-j-1) < obj_LiqPrs[i][0]) ||
            (obj_liqTypes[i] == "Sell" && iHigh(NULL, 0, nBars-j-1) > obj_LiqPrs[i][0])) { obj_LiqPrs[i][1] = 1;        break; } }
         if (obj_LiqPrs[i][1]==0) obj_LiqPrs[i][1] = ((obj_liqTypes[i]=="Buy" && Ask < obj_LiqPrs[i][0]) || (obj_liqTypes[i]=="Sell" && Bid > obj_LiqPrs[i][0])); } */
      double rHigh, rLow;     string Line_N;    if ((rect_H=set_Rectangles()) > 0.0) { for (i = 0; i < ArraySize(Rect_Hs) - 1; i ++) if (! Rect_Ks[i])
            for (j = 0; j < ArraySize(Rect_Hs) - 1; j ++) if ((fabs(Rect_Hs[i][0] - Rect_Hs[j][0]) < 1/Point()/100 ||      // Rect_Ks[j] && 
            fabs(Rect_Hs[i][1] - Rect_Hs[j][1]) < 1/Point()/100) && fmax(Rect_Hs[i][0], Rect_Hs[j][0]) - fmin(Rect_Hs[i][1], Rect_Hs[j][1]) > rect_H &&
            Rect_Ks[j] < rect_HG && Rect_Hs[i][1] > 0.0 && Rect_Hs[j][1] > 0.0) {
               rHigh = fmax(Rect_Hs[i][0], Rect_Hs[j][0]);     rLow = fmin(Rect_Hs[i][1], Rect_Hs[j][1]);
               if (rHigh > rLow && rLow > 0.0) rect_H = rHigh - rLow; }
         if (rHigh == 0.0 || rLow == 0.0) { j = NR-1;    while (Rect_Ks[j]) j --;   rHigh = Rect_Hs[j][0];      rLow = Rect_Hs[j][1]; }
         Line_N = LineCreate(bull_? rLow - rect_H / 4: rHigh + rect_H / 4);         K = ArrayMinimum(Rect_Ks, WHOLE_ARRAY, 0);
         Print("** -> Valeurs de Line_N : "+IntegerToString(rect_HG)+" "+DoubleToStr(rect_H, Digits())+" "+DoubleToStr(rLow, Digits())+" "+Line_N+" **");
#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(28) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 28:
bull_+" | "+Ask+" | "+rLow+" | "+rect_H+" | "+iHigh(NULL, 0, 0)+" | "+iHigh(NULL, 0, K)+" | "+Bid+" | "+rHigh+" | "+iLow(NULL, 0, 0)+" | "+iLow(NULL, 0, K)+" | "+K; #endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
         if (((bull_ && Ask > 0.0 && Ask < rLow - rect_H / 4 && (iHigh(NULL, 0, 0) > rLow || iHigh(NULL, 0, K) > rLow)) || (! bull_ && Bid > rHigh + rect_H / 4 &&
         ((iLow(NULL, 0, 0) > 0.0 && iLow(NULL, 0, 0) < rHigh) || (iLow(NULL, 0, K) > 0.0 && iLow(NULL, 0, K) < rHigh)))) && K < 3) { 
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 28:
bull_+" | "+Ask+" | "+rLow+" | "+rect_H+" | "+iHigh(NULL, 0, 0)+" | "+iHigh(NULL, 0, K)+" | "+Bid+" | "+rHigh+" | "+iLow(NULL, 0, 0)+" | "+iLow(NULL, 0, K)+" | "+K); #endif
            Print("** -> DrawArrow_OS 12 ", bull_, " ", bull, " ", t_night, " ", ticket, " ", TimeToStr(Time[0],TIME_MINUTES)," *(28)*");
            DrawArrow_OS(12, bull? Ask + 150*vScale*Point: Bid + 625*vScale*Point, 0, 0, bull, ticket); }
         if (((! bull_ && Ask > 0.0 && Ask < rLow - rect_H / 4 && (iHigh(NULL, 0, 0) > rLow || iHigh(NULL, 0, K) > rLow)) || (bull_ && Bid > rHigh + rect_H / 4 &&
         ((iLow(NULL, 0, 0) > 0.0 && iLow(NULL, 0, 0) < rHigh) || (iLow(NULL, 0, K) > 0.0 && iLow(NULL, 0, K) < rHigh)))) && K < 3) { fl_Trade = Fl_Trade;
            Print("** -> Suivi de fl_Trade (1) : "+IntegerToString(K)+" "+IntegerToString(rect_HG)+" "+DoubleToStr(rect_H, Digits())+" "+DoubleToStr(rLow, Digits())+" "+
               IntegerToString(Time[0]) + " " + fl_Trade + " **");                  tim_flt = Time[0];            haCoef = 5;
            if (OrderSelect(ticket, SELECT_BY_TICKET)) {
               tmp = DoubleToStr(OrderStopLoss(), Digits);     while(StringSubstr(tmp, StringLen(tmp)-1)=="0") tmp = StringSubstr(tmp, 0, StringLen(tmp)-1);
               if (OrderModify(ticket, OrderOpenPrice(), bull_ ? Bid - (Bid - fmin(iMA(NULL, 0, 5, 0, MODE_SMA, PRICE_CLOSE, 1), 
               iMA(NULL, 0, 5, 0, MODE_SMA, PRICE_CLOSE, 2))) * Profit_Back : Ask + (fmax(iMA(NULL, 0, 5, 0, MODE_SMA, PRICE_CLOSE, 1), 
               iMA(NULL, 0, 5, 0, MODE_SMA, PRICE_CLOSE, 2)) - Ask) * Profit_Back, OrderTakeProfit(), 0, clrAqua)) { ObjectSetInteger(0, Line_N, OBJPROP_COLOR, clrAqua); }
               else  ObjectSetInteger(0, Line_N, OBJPROP_COLOR, clrCornsilk); } } }
      else if (tim_flt > 0 && (Time[0] - tim_flt > 7200 || tmf_Diff)) { objRects_del(1, Line_N);   if (str != "-CHN") { fl_Trade = false;    haCoef = 1;    tim_flt = 0; }
         Print("** -> Suivi de fl_Trade (2) : "+IntegerToString(K)+" "+IntegerToString(rect_HG)+" "+DoubleToStr(rect_H, Digits())+" "+DoubleToStr(rLow, Digits())+" "+
            IntegerToString(Time[0]) + " " + fl_Trade + " **"); }          // ObjectDelete(Line_N);
#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(8) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 8:
nb_ticks+" | "+nb_tcks_N+" | "+m3_RSI(0, 2)+" | "+t_M5_M15+" | "+Period()+" | "+Hour()+" | "+t1+" | "+tim_M15+" | "+Time[0]+" | "+tmf_Diff; #endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
      if (nb_ticks > 2 && nb_ticks == nb_tcks_N + 1 && m3_RSI(0, 2) > 35 && m3_RSI(0, 2) < 65 && ((t_M5_M15 = (Period() == PERIOD_M5)) ||
      Period() == PERIOD_M15) && Hour() > H2 - 2) { t1 = 0;    GlobalVariableSet(tmfr0_str, PERIOD_M5? PERIOD_M15: PERIOD_M5);      nb_ticks = 0;    nb_tcks_N = 0;  // (H1 < H3 || 
         while(! (tst=ChartSetSymbolPeriod(0, NULL, PERIOD_M5? PERIOD_M15: PERIOD_M5)) && t1 < 17) { t1 ++;       Sleep(100); }       if (tst) { tim_M15 = Time[0];    tmf_Diff = true;
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 8:
nb_ticks+" | "+nb_tcks_N+" | "+m3_RSI(0, 2)+" | "+t_M5_M15+" | "+Period()+" | "+Hour()+" | "+t1+" | "+tim_M15+" | "+Time[0]+" | "+tmf_Diff);
copy_file_45(5, "8_;"+TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+";"+IntegerToString(TimeCurrent())+";"+IntegerToString(Period())); #endif
            temp = "** Passage en M15 (2) à "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" ! (Period()="+IntegerToString(Period())+", t1="+IntegerToString(t1)+") *(8)*";
            Print(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp); } }
      t_rsi51_ = t_rsi515;       t_rsi515 = (m3_RSI(PERIOD_M5, 3) > 38 && m3_RSI(PERIOD_M5, 3) < 62 && m3_RSI(PERIOD_M15, 3) > 38 && 
         m3_RSI(PERIOD_M15, 3) < 62 && (Period() == PERIOD_M5 || Period() == PERIOD_M15));
      if (t_rsi51_ && ! t_rsi515) t_rsi515o = true;             if (t_rsi515o && t_rsi515) t_rsi515o = false;
#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(9) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 9:
t_rsi51_+" | "+t_rsi515+" | "+t_rsi515o+" | "+tim_M15+" | "+Time[0]+" | "+Period()+" | "+m3_RSI(PERIOD_M5, 2)+" | "+t1+" | "+t_M5_M15+" | "+tmf_Diff; #endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
      if (tim_M15 > 0 && (Time[0] - tim_M15 > Period() * 60*8) && Period() == PERIOD_M15 &&
         ! (m3_RSI(PERIOD_M5, 2) > 40 && m3_RSI(PERIOD_M5, 2) < 60)) { t1 = 0;      GlobalVariableSet(tmfr0_str, PERIOD_M5);    // || ! fl_Trade
         while(! (tst=ChartSetSymbolPeriod(0, NULL, PERIOD_M5)) && t1 < 17) { t1 ++;      Sleep(100); }       if (tst) { tim_M15 = 0;    t_M5_M15 = false;    tmf_Diff = true;
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 9:
t_rsi51_+" | "+t_rsi515+" | "+t_rsi515o+" | "+tim_M15+" | "+Time[0]+" | "+Period()+" | "+m3_RSI(PERIOD_M5, 2)+" | "+t1+" | "+t_M5_M15+" | "+tmf_Diff);
copy_file_45(5, "9_;"+TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+";"+IntegerToString(TimeCurrent())+";"+IntegerToString(Period())); #endif
            temp = "** Passage en M5 (1) à "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" ! (Period()="+IntegerToString(Period())+", t1="+IntegerToString(t1)+") *(9)*";
            Print(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp); } }
#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(10) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 10:
trd_on+" | "+OrderSymbol()+" | "+ticket+" | "+bull2+" | "+OrderType()+" | "+OrderProfit()+" | "+OrderSwap()+" | "+OrderCommission()+" | "+AccBalance_day+" | "+lot+" | "+Bid+" | "+Ask+" | "+slip+" | "+OrderProfit();#endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
      if (! trd_on && mOrderSelect(mOrdersTotal(magic_nb)==1?0:2,SELECT_BY_POS) && OrderSymbol() == Symbol()) { ticket = OrderTicket();      bull2 = ! OrderType();
         if (OrderProfit() + OrderSwap() + OrderCommission() < -0.05 * AccBalance_day && OrderClose(ticket, lot, bull2? Bid: Ask, slip, OrderProfit() > 0? clrLimeGreen: clrMagenta)) {
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 10:
trd_on+" | "+OrderSymbol()+" | "+ticket+" | "+bull2+" | "+OrderType()+" | "+OrderProfit()+" | "+OrderSwap()+" | "+OrderCommission()+" | "+AccBalance_day+" | "+lot+" | "+Bid+" | "+Ask+" | "+slip+" | "+OrderProfit());
copy_file_45(5, "10;"+TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+";"+IntegerToString(TimeCurrent())+";"+IntegerToString(Period())); #endif
           temp = "***** Trade STOP LOSS Reached. This Trade Has Been Closed. ("+DoubleToStr(OrderProfit(),Digits())+" - "+Hour()+" - "+DoubleToStr(AccBalance_day,2)+") ****(10)*";
           Alert(temp);          copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp); } }
      else { bull2 = bull_;         if (! trd_on) { ticket = 0;      GlobalVariableSet(tck_vstr, 0); } }           trd_on = false; }
#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(11) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 11:
tim_M15+" | "+Time[0]+" | "+last_liq_t1+" | "+iBarShift(NULL,0,last_liq_t1,false)+" | "+m3_RSI(0, 2)+" | "+Period()+" | "+H1+" | "+H3+" | "+Hour()+" | "+H2+" | "+t1+" | "+t_M5_M15+" | "+tmf_Diff;#endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
  if (tim_M15 < Time[0] && (! iBarShift(NULL,0,last_liq_t1,false) && m3_RSI(0, 2) > 40 && m3_RSI(0, 2) < 60 && Period() == PERIOD_M5 &&
   ((H1 < H3 && Hour() > H2 - 2) || Hour() > H2 + 2))) { t1 = 0;           GlobalVariableSet(tmfr0_str, PERIOD_M15);
      while(! (tst=ChartSetSymbolPeriod(0, NULL, PERIOD_M15)) && t1 < 17) { t1 ++;     Sleep(100); }       if (tst) { tim_M15 = Time[0];   t_M5_M15 = true;   tmf_Diff = true;
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 11:
tim_M15+" | "+Time[0]+" | "+last_liq_t1+" | "+iBarShift(NULL,0,last_liq_t1,false)+" | "+m3_RSI(0, 2)+" | "+Period()+" | "+H1+" | "+H3+" | "+Hour()+" | "+H2+" | "+t1+" | "+t_M5_M15+" | "+tmf_Diff);
copy_file_45(5, "11;"+TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+";"+IntegerToString(TimeCurrent())+";"+IntegerToString(Period())); #endif
         temp = "** Passage en M15 (3) à "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" ! (Period()="+IntegerToString(Period())+", t1="+IntegerToString(t1)+") *(11)*";
         Print(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp); } }
#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(12) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 12:
m3_RSI(PERIOD_M5, 2)+" | "+m3_RSI(PERIOD_H1, 2)+" | "+Period()+" | "+t1+" | "+tim_M15+" | "+tmf_Diff; #endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
  if ((m3_RSI(PERIOD_M5, 2) < 32 || m3_RSI(PERIOD_M5, 2) > 68) && m3_RSI(PERIOD_H1, 2) > 28 &&
   m3_RSI(PERIOD_H1, 2) < 72 && Period() == PERIOD_M15) { t1 = 0;       GlobalVariableSet(tmfr0_str, PERIOD_M5);     // revoir si RSI H1 nécessaire
      while(! (tst=ChartSetSymbolPeriod(0, NULL, PERIOD_M5)) && t1 < 17) { t1 ++;         Sleep(100); }          if (tst) { tim_M15 = 0;       tmf_Diff = true;
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 12:
m3_RSI(PERIOD_M5, 2)+" | "+m3_RSI(PERIOD_H1, 2)+" | "+Period()+" | "+t1+" | "+tim_M15+" | "+tmf_Diff);
copy_file_45(5, "12;"+TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+";"+IntegerToString(TimeCurrent())+";"+IntegerToString(Period())); #endif
         temp = "** Passage en M5 (2) à "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" ! (Period()="+IntegerToString(Period())+", t1="+IntegerToString(t1)+") *(12)*";
         Print(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp); } }
  bool d_HiLo=((douHiLo > (Point() != 0.00001 && Point() != 0.001? str=="-HKG" || str=="-CHN"? 0.001: 0.0005: 0.00017) * Bid) && 
      (fabs(haOpen - haClose) > (Point() != 0.00001 && Point() != 0.001? str=="-HKG" || str=="-CHN" || str=="-BTC"? 0.001: 0.0005: 0.0003)*Bid) &&
      fabs(haOpen - haClose) >= douHiLo * 0.75);
#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(13) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 13:
Period()+" | "+last_liq_t1+" | "+iBarShift(NULL,0,last_liq_t1,false)+" | "+d_HiLo+" | "+last_liq_pr+" | "+Ask+" | "+Bid+" | "+douHiLo+" | "+bull2+" | "+tim_flt+" | "+TimeCurrent()+" | "+Period()+" | "+
ticket+" | "+t_night+" | "+OS9_tick+" | "+habull+" | "+FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Sell.txt", 0)+" | "+FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0)+" | "+bull_; #endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
  if ((Period() == PERIOD_M5 || Period() == PERIOD_M15) && ((iBarShift(NULL,0,last_liq_t1,false) >= 4 && d_HiLo) || 
  ((iBarShift(NULL,0,last_liq_t1,false) >= 5 && fmin(fabs(last_liq_pr-Ask), fabs(last_liq_pr-Bid)) >= douHiLo*0.8 && 
  d_HiLo) && ((last_liq_pr > Ask && ! bull2) || (last_liq_pr < Bid && bull2)) && last_liq_pr > 0)) && tim_flt < TimeCurrent() - Period()*60 * 3) {
      if (! ticket && ! t_night && OS9_tick && ((! habull && bull2 && FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Sell.txt", 0)) ||
      (habull && ! bull2 && FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0)))) {
         bull_ = FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0);
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 13:
Period()+" | "+last_liq_t1+" | "+iBarShift(NULL,0,last_liq_t1,false)+" | "+d_HiLo+" | "+last_liq_pr+" | "+Ask+" | "+Bid+" | "+douHiLo+" | "+bull2+" | "+tim_flt+" | "+TimeCurrent()+" | "+Period()+" | "+
ticket+" | "+t_night+" | "+OS9_tick+" | "+habull+" | "+FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Sell.txt", 0)+" | "+FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0)+" | "+bull_);
copy_file_45(5, "13;"+TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+";"+IntegerToString(TimeCurrent())+";"+IntegerToString(Period())); #endif
         temp = "** -> DrawArrow_OS 9 " + bull_ + " " + bull + " " + bull2 + " " + habull + " " + ticket + " " + t_night + " " + TimeToStr(Time[0],TIME_MINUTES) + " " +
            FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0)+" "+TimeToStr(last_liq_t1,TIME_MINUTES)+" "+TimeToStr(last_liq_t2,TIME_MINUTES)+" " +
            DoubleToStr(last_liq_pr, Digits())+" "+DoubleToStr(haOpen, Digits())+" "+DoubleToStr(haClose, Digits())+" "+DoubleToStr(douHiLo, Digits())+" " +
            DoubleToStr(0.0002*Bid, Digits()) + " *(13)*";
         Print(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp);
         DrawArrow_OS(9, (bull_? Ask: Bid)+(bull_? 150*vScale*Point: 625*vScale*Point), 0, 0, bull_, 0);    OS9_tick = false; }
/* else Alert("** -> DrawArrow_OS 9 TEST ",Symbol()," ",bull_," ",bull," ",habull," ",ticket," ",t_night," ",TimeToStr(Time[0],TIME_MINUTES)," ",
   FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0)," ",TimeToStr(last_liq_t1,TIME_MINUTES)," ",TimeToStr(last_liq_t2,TIME_MINUTES)," ",
   DoubleToStr(last_liq_pr, Digits())," ",DoubleToStr(haOpen, Digits())," ",DoubleToStr(haClose, Digits())," ",DoubleToStr(douHiLo, Digits())," ",
   DoubleToStr(0.0002*Bid, Digits())," **"); //*/
      if (ticket && ((! habull && bull2 && FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0)) ||
      (habull && ! bull2 && FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Sell.txt", 0)))) {
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 13:
Period()+" | "+last_liq_t1+" | "+iBarShift(NULL,0,last_liq_t1,false)+" | "+d_HiLo+" | "+last_liq_pr+" | "+Ask+" | "+Bid+" | "+douHiLo+" | "+bull2+" | "+tim_flt+" | "+TimeCurrent()+" | "+Period()+" | "+
ticket+" | "+t_night+" | "+OS9_tick+" | "+habull+" | "+FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Sell.txt", 0)+" | "+FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0)+" | "+bull_);
copy_file_45(5, "14;"+TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+";"+IntegerToString(TimeCurrent())+";"+IntegerToString(Period())); #endif
         temp = "** -> DrawArrow_OS 10 " + bull_ + " " + bull + " " + bull2 + " " + habull + " " + ticket + " " + t_night + " " + TimeToStr(Time[0],TIME_MINUTES) + " " +
            FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0)+" "+TimeToStr(last_liq_t1,TIME_MINUTES)+" "+TimeToStr(last_liq_t2,TIME_MINUTES)+" " +
            DoubleToStr(last_liq_pr, Digits())+" "+DoubleToStr(haOpen, Digits())+" "+DoubleToStr(haClose, Digits())+" "+DoubleToStr(douHiLo, Digits())+" " +
            DoubleToStr(0.0002*Bid, Digits()) + " *(14)*";
         Print(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp);
         DrawArrow_OS(10, obj_prClots[pos]+(bull2? 150*vScale*Point: 625*vScale*Point), 0, 0, bull2, ticket); }
else if (t_TST1) { temp = "** -> DrawArrow_OS 10 TEST "+Symbol()+" "+bull_+" "+bull+" "+bull2+" "+habull+" "+ticket+" "+t_night+" "+TimeToStr(Time[0],TIME_MINUTES) + " " +
   FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0)+" "+TimeToStr(last_liq_t1,TIME_MINUTES)+" "+TimeToStr(last_liq_t2,TIME_MINUTES)+" "+DoubleToStr(last_liq_pr, Digits())+" "+
   DoubleToStr(haOpen, Digits()) + " " + DoubleToStr(haClose, Digits()) + " " + DoubleToStr(douHiLo, Digits()) + " " + DoubleToStr(0.0002*Bid, Digits()) + " *(15)*";
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 13:
Period()+" | "+last_liq_t1+" | "+iBarShift(NULL,0,last_liq_t1,false)+" | "+d_HiLo+" | "+last_liq_pr+" | "+Ask+" | "+Bid+" | "+douHiLo+" | "+bull2+" | "+tim_flt+" | "+TimeCurrent()+" | "+Period()+" | "+
ticket+" | "+t_night+" | "+OS9_tick+" | "+habull+" | "+FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Sell.txt", 0)+" | "+FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0)+" | "+bull_);
copy_file_45(5, "15;"+TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+";"+IntegerToString(TimeCurrent())+";"+IntegerToString(Period())); #endif
      Alert(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp);         t_TST1 = false; } }
else if (t_TST2) { temp = "** -> DrawArrow_OS 10(b) TEST " + bull_ + " " + bull + " " + bull2 + " " + ticket + " " + t_night + " " + TimeToStr(Time[0],TIME_MINUTES) + " " +
   ((last_liq_pr > Ask && ! bull) || (last_liq_pr < Bid && bull)) + " " + (last_liq_pr > Ask && ! bull) + " " + (last_liq_pr < Bid && bull) + " " + (Time[0] % (Period() * 120)) +
   " " + TimeToStr(last_liq_t1,TIME_MINUTES) + " " + TimeToStr(last_liq_t2,TIME_MINUTES) + " " + DoubleToStr(last_liq_pr, Digits()) + " " + DoubleToStr(haOpen, Digits()) +
  " " + DoubleToStr(haClose, Digits()) + " " + DoubleToStr(douHiLo, Digits()) + " " + DoubleToStr(0.0002*Bid, Digits()) + " *(16)*";
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 13:
Period()+" | "+last_liq_t1+" | "+iBarShift(NULL,0,last_liq_t1,false)+" | "+d_HiLo+" | "+last_liq_pr+" | "+Ask+" | "+Bid+" | "+douHiLo+" | "+bull2+" | "+tim_flt+" | "+TimeCurrent()+" | "+Period()+" | "+
ticket+" | "+t_night+" | "+OS9_tick+" | "+habull+" | "+FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Sell.txt", 0)+" | "+FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0)+" | "+bull_);
copy_file_45(5, "16;"+TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+";"+IntegerToString(TimeCurrent())+";"+IntegerToString(Period())); #endif
      Print(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp);         t_TST2 = false; }
  if (t_Ntcks && nb_ticks > 2 && nb_ticks == nb_tcks_N + 1 && Hour() < 6) { if (str=="-HKG" || str=="-CHN") { t_ngt0 = true;        GlobalVariableSet("t_ngt_1", 1.0); }
   Print("** -> (3) nb_ticks > 2 && nb_ticks == nb_tcks_N + 1 : ",IntegerToString(nb_ticks)," ",IntegerToString(nb_tcks_N)," ",ticket," ",t_night," ",t_ngt1," ",TimeToStr(Time[0],TIME_MINUTES)," **"); }

  if (GlobalVariableCheck(t_ATS_str)) ATS_Time = GlobalVariableGet(t_ATS_str);
#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(29) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 29:
ATS_Time+" | "+TimeCurrent()+" | "+str+" | "+Period()+" | "+H2+" | "+StringSubstr(TimeToStr(ATS_Time, TIME_DATE), 8, 2)+" | "+Day()+" | "+ticket; #endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
  if (ATS_Time > 0 && (TimeCurrent() - ATS_Time) > PERIOD_H1*60 * 5 && (TimeCurrent() - ATS_Time) < PERIOD_H1*60 * 6 &&
   str == "-CHN" && (Period()==PERIOD_M5 || Period()==PERIOD_M15) && int (StringSubstr(TimeToStr(ATS_Time, TIME_MINUTES), 0, 2)) > H2 &&      // H1 > H3
   int (StringSubstr(TimeToStr(ATS_Time, TIME_DATE), 8, 2)) == Day() && ticket > 7) { t_night = true;  if (str=="-CHN") t_ngt0 = true;
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 29:
ATS_Time+" | "+TimeCurrent()+" | "+str+" | "+Period()+" | "+H2+" | "+StringSubstr(TimeToStr(ATS_Time, TIME_DATE), 8, 2)+" | "+Day()+" | "+ticket); #endif
      Print("** -> DrawArrow_OS 11 ", bull_, " ", bull, " ", t_night, " ", ticket, " ", TimeToStr(Time[0],TIME_MINUTES)," *(29)*");
      DrawArrow_OS(11, obj_prClots[pos]+(bull? 150*vScale*Point: 625*vScale*Point), 0, 0, bull, ticket); }
/* else if (str == "-CHN") Print("** -> DrawArrow_OS 11 ATTENTE "+TimeToStr(ATS_Time,TIME_MINUTES)+" "+(TimeCurrent() - ATS_Time)+" "+(ATS_Time > 0 && (TimeCurrent() - ATS_Time) > 
   PERIOD_H1*60 * 5 && (TimeCurrent() - ATS_Time) < PERIOD_H1*60 * 6 && str == "-CHN" && Period() == PERIOD_M5 && int (StringSubstr(TimeToStr(ATS_Time, TIME_MINUTES), 0, 2)) > H2 &&  // H1 > H3
   int (StringSubstr(TimeToStr(ATS_Time, TIME_DATE), 8, 2)) == Day() && ticket)+" "+((TimeCurrent() - ATS_Time) > PERIOD_H1*60 * 5 && (TimeCurrent() - ATS_Time) < PERIOD_H1*60 * 6)+
   " "+(str == "-CHN" && Period() == PERIOD_M5 && int (StringSubstr(TimeToStr(ATS_Time, TIME_MINUTES), 0, 2)) > H2)+" "+
   (int (StringSubstr(TimeToStr(ATS_Time, TIME_DATE), 8, 2)) == Day() && ticket)+" "+ticket+" "+" **"); //*/

#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(17) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 17:
OS6_tick+" | "+last_rct_+" | "+Time[0]+" | "+Period()+" | "+bull_+" | "+FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0); #endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
  if (OS6_tick && last_rct_==Time[0] && (Period()==PERIOD_H1 || Period()==PERIOD_M30)) { bull_ = FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0);
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 17:
OS6_tick+" | "+last_rct_+" | "+Time[0]+" | "+Period()+" | "+bull_+" | "+FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0));
copy_file_45(5, "17;"+TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+";"+IntegerToString(TimeCurrent())+";"+IntegerToString(Period())); #endif
      temp = "***** last_rct_ (2) -> while(! (tst=ChartSetSymbolPeriod(0, && DrawArrow_OS(6, ****(17)*";           OS6_tick = false;
      Print(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp);
      DrawArrow_OS(6, (bull_? Ask: Bid)+(bull_? 150*vScale*Point: 625*vScale*Point), 0, 0, bull_, 0);       GlobalVariableSet(bull_str, bull_); }
  if (Hour() == 3 && ! Minute() && Seconds() < 5 && test2 < Seconds()) { test2 = Seconds();
      Print("** -> TEST(2) DrawArrow_OS 7 ",bull_," ",bull," ",t_night," ",ticket," ",TimeToStr(Time[0],TIME_MINUTES)," ",OS5_tick," **"); }
//  if ((DayOfWeek() < 5 || H1 < H3) && t_night && Hour() == H1 && (str != "-CHN" || Seconds() > 4) && ticket <= 7) {
#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(30) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 30:
DayOfWeek()+" | "+H1+" | "+H3+" | "+t_night+" | "+Hour()+" | "+str+" | "+Minute()+" | "+Seconds()+" | "+bull+" | "+FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0)+" | "+bull+" | "+
FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Sell.txt", 0)+" | "+m3_RSI(PERIOD_H1, 2)+" | "+ticket+" | "+fl_Trade; #endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
  if ((DayOfWeek() < 5 || H1 < H3) && t_night && Hour() == H1 && ((str!="-CHN" && str!="-HKG") || Minute() >= 40) && (str!="-CHN" || (Seconds() > 4 &&
   ((bull && FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0)) || (! bull && FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Sell.txt", 0))) &&
   (m3_RSI(PERIOD_H1, 2) < 38 || m3_RSI(PERIOD_H1, 2) > 62))) && ticket <= 7) { if (str == "-CHN") fl_Trade = Fl_Trade;    // && t_ind300
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 30:
DayOfWeek()+" | "+H1+" | "+H3+" | "+t_night+" | "+Hour()+" | "+str+" | "+Minute()+" | "+Seconds()+" | "+bull+" | "+FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0)+" | "+bull+" | "+
FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Sell.txt", 0)+" | "+m3_RSI(PERIOD_H1, 2)+" | "+ticket+" | "+fl_Trade); #endif
      Print("** -> DrawArrow_OS 7 ",bull_," ",bull," ",t_night," ",ticket," ",(str=="-CHN"? IntegerToString(Seconds())+" ": ""),TimeToStr(Time[0],TIME_MINUTES)," *(30)*");
      t_night = ! DrawArrow_OS(7, (bull? Ask: Bid)+(bull? 150*vScale*Point: 625*vScale*Point), 0, 0, bull, 0);          t_h6 = true; }    // 6
  if (Hour() == H1 && str == "-CHN" && Minute() > 40) GlobalVariableSet("t_ngt_2", (t_ngt0 = ! (((bull && FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0)) || 
   (! bull && FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Sell.txt", 0))) && (m3_RSI(PERIOD_H1, 2) < 38 || m3_RSI(PERIOD_H1, 2) > 62))));
  if (DayOfWeek() < 5 && !t_h6 && t_night && Hour() == H1 && Minute() >= 40 && (str == "-CHN" || str == "-HKG"))
      Print("** -> DrawArrow_OS 7 ATTENTE ",bull_," ",bull," ",t_night," ",ticket," ",(str == "-CHN"? FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0)+" "+
         DoubleToStr(m3_RSI(PERIOD_H1, 2), 2) + " " + IntegerToString(Seconds()) + " ": ""), TimeToStr(Time[0],TIME_MINUTES), " **"); //*/
  if (H1 > H3 && t_night != t_night_) Print("** Suivi de t_night et tr_allow (3) : "+Symbol()+" / "+IntegerToString(Period())+" - t_night = "+t_night+" - tr_allow = "+tr_allow+" **");
#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(31) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 31:
DayOfWeek()+" | "+Hour()+" | "+Minute()+" | "+t_night+" | "+m3_RSI(0,3)+" | "+ticket; #endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
  if (((DayOfWeek() == 5 && (((Hour() == 16 && Minute() > 39) || Hour() > 16 || t_night) && m3_RSI(0,3) > 38 && m3_RSI(0,3) < 62)) || (Hour()==23 && Minute() > 30)) && ticket > 7) {
//  if (((DayOfWeek() == 5 && ((Hour() == 16 && Minute() > 39) || Hour() > 16)) || (t_night && (H1 < H3 || Hour() != H1))) && ticket > 7) { t_night = true;
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 31:
DayOfWeek()+" | "+Hour()+" | "+Minute()+" | "+t_night+" | "+m3_RSI(0,3)+" | "+ticket); #endif
      Print("** -> DrawArrow_OS 8 ", bull_, " ", bull, " ",t_night, " ", ticket, " ", TimeToStr(Time[0],TIME_MINUTES)," *(31)*");
      DrawArrow_OS(8, obj_prClots[pos]+(bull_? 150*vScale*Point: 625*vScale*Point), 0, 0, bull_, ticket);         t_night = true; }
  if ((DayOfWeek() == 5 && ((Hour() == 16 && Minute() > 39) || Hour() > 16)) || (H1 > H3 && DayOfWeek() == 1 && Hour() == H2 && ! Minute() && Seconds() < 7)) {
      GlobalVariableSet("t_ngt_2", 0.0);              if (str == "-CHN") fl_Trade = Fl_Trade; }
//if (str=="-CHN" || str=="-HKG") Print("** -> DrawArrow_OS 8 ATTENTE ",bull_," ",bull," ",t_night," ",ticket," ",TimeToStr(Time[0],TIME_MINUTES)," **");

  if (Hour() != 8 && Hour() != 15 && Hour() != 23 && tmp_saved) tmp_saved = false;
  else if (! tmp_saved && (Hour() == 8 || Hour() == 15 || Hour() == 23) && MQLInfoInteger(MQL_DLLS_ALLOWED)) { tmp_saved = true;
      int ts_=ShellExecuteW(0,"open","C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal\\6BCF14A3917E5BC71FD48812B8ED0586\\templates\\"+
         "template_saved_BTCUSD_.bat", "", "C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal\\6BCF14A3917E5BC71FD48812B8ED0586\\templates", 1);
      Sleep(500);       ChartSaveTemplate(0, "template_saved_"+Symbol());        ChartSaveTemplate(0, "template_saved_"+StringSubstr(Symbol(), 0, 6)); }

  Calcul_accelerator(habull, haOpen, haClose);        tst = false;         if (Period() == PERIOD_M15) rect_Order();
  if (ac_ticket && OrderSelect(ac_ticket, SELECT_BY_TICKET)) { if (((TimeCurrent() - OrderOpenTime() > 3600 && ((OrderType() &&
   OrderOpenPrice() - Ask < 125) || (! OrderType() && Bid - OrderOpenPrice() < 25)))) &&            // 25 et 110 (75*2+10) ne sont que pour le BTC
   OrderStopLoss() != (OrderType()? OrderOpenPrice() + 50: OrderOpenPrice() - 50) && (OrderModify(ac_ticket,
   OrderOpenPrice(), OrderType()? OrderOpenPrice() + 50: OrderOpenPrice() - 50, 0, 0, OrderProfit() > 0? Aqua: Yellow) ||
   (tst=OrderClose(ac_ticket, lot, OrderType()? Ask: Bid, slip, OrderProfit()>0? Aqua: Yellow)))) {
      if (tst) { Alert("***** Le signal d'accélération a été annulé (1) : " + IntegerToString(ac_ticket) + " - " + (TimeCurrent() - OrderOpenTime()) + " - " +
            DoubleToStr(OrderType()? Ask - OrderOpenPrice(): OrderOpenPrice() - Bid, Digits()) + " ! *****");
         ticket = 0;          ac_ticket = 0; }
      else if (OrderSelect(ac_ticket, SELECT_BY_TICKET)) { Alert("***** Le signal d'accélération a été modifié (SL) : " + IntegerToString(ac_ticket) + " - " +
            (TimeCurrent() - OrderOpenTime()) + " - " + DoubleToStr(OrderType()? Ask - OrderOpenPrice(): OrderOpenPrice() - Bid, Digits()) + " ! *****"); } }
   if (((TimeCurrent() - OrderOpenTime() > 2 * 3600 && ((OrderType() && OrderOpenPrice() - Ask < 125) || (! OrderType() && Bid - OrderOpenPrice() < 25))) ||
   (OrderType() && Ask - OrderOpenPrice() > 110) || (! OrderType() && OrderOpenPrice() - Bid > 110)) &&
   OrderClose(ac_ticket, lot, OrderType()? Ask: Bid, slip, OrderProfit()>0? Aqua: Yellow)) {
      Alert("***** Le signal d'accélération a été annulé (2) : " + IntegerToString(ac_ticket) + " - " + (TimeCurrent() - OrderOpenTime()) + " - " +
         DoubleToStr(OrderType()? Ask - OrderOpenPrice(): OrderOpenPrice() - Bid, Digits()) + " ! *****");
      ticket = 0;          ac_ticket = 0; } }
  if (ac_tickt2 && OrderSelect(ac_tickt2, SELECT_BY_TICKET) && OrderStopLoss() != (OrderType()? ac_lmtick + 50: ac_lmtick - 50) &&
  ((OrderType() && ac_lmtick > OrderOpenPrice() && ac_lmtick < OrderStopLoss()) || (! OrderType() && ac_lmtick < OrderOpenPrice() && ac_lmtick > OrderStopLoss()))
  && OrderModify(ac_tickt2, OrderOpenPrice(), OrderType()? ac_lmtick + 50: ac_lmtick - 50, 0, 0, OrderProfit() > 0? Aqua: Yellow)) {
      if (OrderSelect(ac_tickt2, SELECT_BY_TICKET)) Alert("***** Le signal d'accélération a été modifié (SL-2) : " + IntegerToString(ac_tickt2) + " - " +
            (TimeCurrent() - OrderOpenTime()) + " - " + DoubleToStr(OrderType()? Ask - OrderOpenPrice(): OrderOpenPrice() - Bid, Digits()) + " ! *****"); }
//    ici le Ask est le Ask du backtest, c'est-à-dire avec un spread en principe systématique de $ 100.00

/* BE - paramètres utilisés :
Bollinger 20 0 2.0 - Liquidity Line - RSI515 - Accélérateur - Signal 5 *
1- validation / invalidation trade,    précision : 100 * (Period() / 60) * (M5 : 3.5 / M15 : 2.5 / M30 : 1.5 / H1 : 1)
2- après trade ouvert, si touche BB (précison 1)   OrderModify -> BE + enregistrer l'ordre en BE par une variable bool
3- trade invalidé si touche Liquidity Line (-1) + (-2) + (-3), précision -> 	100 * (Period() / 60) * (M5 : 3.5 / M15 : 2.5 / M30 : 1.5 / H1 : 1)
4- après trade ouvert, si touche Liquidity Line (<=>3) OrderModify->BE + enregistrer l'ordre en BE par une variable bool
5- trade invalidé si touche Expansion Line (-1) + (-2) + (-3), précision -> 	100 * (Period() / 60) * (M5 : 3.5 / M15 : 2.5 / M30 : 1.5 / H1 : 1)
6- après trade ouvert, si touche Expansion Line (<=>5) OrderModify->BE + enregistrer l'ordre en BE par une variable bool
7- après avoir touché le BE, si touche limite opposée Bollinger   -> réactiver l'ordre et fermer la variable du BE
8- après avoir touché le BE, si touche Liquidity Line du trade en BE -> réactiver l'ordre et fermer la variable du BE
9- basé sur les vars nDrArrChk + dDrArrChk et nDrArrHA + dDrArrHA */
  double val_prec=100*Period()/60*(Period()==PERIOD_M5? 3.6: Period()==PERIOD_M15? 2.8 : Period()==PERIOD_M30? 1.6: 1),       // <- *1*
   bb_val0=iBands(NULL,0,20,2.0,0,PRICE_TYPICAL,MODE_MAIN,0), bb_val1=iBands(NULL,0,20,2.0,0,PRICE_TYPICAL,MODE_UPPER,0), bb_val2=iBands(NULL,0,20,2.0,0,PRICE_TYPICAL,MODE_LOWER,0);

#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(34) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 34:
ticket+" | "+MQLInfoInteger(MQL_TESTER)+" | "+(tst1=OrderSelect(ticket, SELECT_BY_TICKET))+" | "+val1+" | "+bb_val1+" | "+(val1-bb_val1)+" | "+val_prec+" | "+OrderType()+" | "+Bid+" | "+
pr_val1+" | "+OrderOpenPrice()+" | "+a_tmpHiLo+" | "+(a_tmpHiLo/(a_tmpHiLo>100.0? 2: 1))+" | "+bb_val2+" | "+(val1-bb_val2)+" | "+Ask; #endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
  ResetLastError();     if ((ticket > 7 || (ticket && MQLInfoInteger(MQL_TESTER))) && OrderSelect(ticket, SELECT_BY_TICKET) &&                      // <- *2*
  ((fabs(val1 - bb_val1) < val_prec && ! OrderType() && Bid > (pr_val1 > 0.0? pr_val1: OrderOpenPrice()) + a_tmpHiLo / (a_tmpHiLo > 100.0? 2: 1)) || 
  (fabs(val1 - bb_val2) < val_prec && OrderType() && Ask < (pr_val1 > 0.0? pr_val1: OrderOpenPrice()) - a_tmpHiLo / (a_tmpHiLo > 100.0? 2: 1))) &&
  OrderStopLoss() != NormalizeDouble((pr_val1 > 0.0? pr_val1: OrderOpenPrice()) + (OrderType() ? 1 : -1) * (Ask - Bid) / 2, Digits())) {
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+   // case 34:
ticket+" | "+MQLInfoInteger(MQL_TESTER)+" | "+tst1+" | "+val1+" | "+bb_val1+" | "+(val1-bb_val1)+" | "+val_prec+" | "+OrderType()+" | "+Bid+" | "+
pr_val1+" | "+OrderOpenPrice()+" | "+a_tmpHiLo+" | "+(a_tmpHiLo/(a_tmpHiLo>100.0? 2: 1))+" | "+bb_val2+" | "+(val1-bb_val2)+" | "+Ask); #endif
      if (fabs(OrderStopLoss() - (tmp=(OrderOpenPrice() + (OrderType() ? 1 : -1) * (Ask - Bid) / 2))) > 10.0 && !OrderModify(ticket, OrderOpenPrice(), tmp, OrderTakeProfit(), 0, clrSkyBlue))        // <- BE
         Alert("*** OrderModify Error(1): "+DoubleToStr(val1, Digits())+" "+DoubleToStr(bb_val1, Digits())+" "+DoubleToStr(bb_val2, Digits())+" "+
         DoubleToStr(val_prec, Digits())+" "+DoubleToStr(pr_val1, Digits())+" "+DoubleToStr(a_tmpHiLo, Digits())+" "+DoubleToStr(a_tmpHiLo/(a_tmpHiLo>100.0? 2: 1), Digits())+" | "+
            (fabs(val1 - bb_val1) < val_prec && ! OrderType() && Bid > (pr_val1 > 0.0? pr_val1: OrderOpenPrice()) + a_tmpHiLo / (a_tmpHiLo > 100.0? 2: 1))+" "+
            (fabs(val1 - bb_val2) < val_prec && OrderType() && Ask < (pr_val1 > 0.0? pr_val1: OrderOpenPrice()) - a_tmpHiLo / (a_tmpHiLo > 100.0? 2: 1))+" ***");
      if (OrderSelect(ticket, SELECT_BY_TICKET)) Print("** -> OrderModify(BE 2) " + OrderType() + " " + bull_ + " " + bull + " " + bull2 + " " + habull + " " + ticket + " " + t_night + " " +
            TimeToStr(Time[0],TIME_MINUTES) + " " + DoubleToStr(pr_val1, Digits()) + " " + DoubleToStr(pr_val1 + (OrderType() ? 1 : -1) * (Ask - Bid) / 2, Digits()) + " **");
      be_trade = (OrderType() ? -1 : 1) * val1;       be_tick = ticket;       if (OrderType()) BE_s = TimeCurrent();          else BE_b = TimeCurrent(); }

//    v     ici même valriables que case 35:  **
  inv_LiqLine = ((fabs(val1 - last_liq_p2) < val_prec * Point && last_liq_t22 - last_liq_t12 > Period() * 120 && fabs(last_liq_p2 - last_ntr_p2) > val_prec * Point) ||    // <- *3*
//   fabs(ObjectGet((obj_liqTypes[pos]=="Buy"?nam_B:nam_S),OBJPROP_PRICE1) - ObjectGet(name, OBJPROP_PRICE1)) > 100 * Point) ||        // voir en option **
   (fabs(val1 - last_liq_p3) < val_prec * Point && last_liq_t23 - last_liq_t13 > Period() * 120 && fabs(last_liq_p3 - last_ntr_p3) > val_prec * Point)) &&
//   fabs(ObjectGet((obj_liqTypes[pos-1]=="Buy"?nam_B2:nam_S2),OBJPROP_PRICE1) - ObjectGet(ObjectName(pos-1),OBJPROP_PRICE1)) > 100 * Point)) &&   // voir en option **
   ((obj_liqTyp_1 == "Buy" && val1 > last_ntr_pr) || (obj_liqTyp_1 == "Sell" && val1 < last_ntr_pr));       // attention ici ce n'est pas le même sens que dans la 1ère partie 

#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(35) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 35:
val1+" | "+last_liq_p2+" | "+(val1-last_liq_p2)+" | "+val_prec+" | "+last_liq_t22+" | "+last_liq_t12+" | "+(last_liq_t22-last_liq_t12)+" | "+(Period()*120)+" | "+
last_ntr_p2+" | "+last_liq_p3+" | "+(val1-last_liq_p3)+" | "+last_liq_t23+" | "+last_liq_t13+" | "+(last_liq_t23 - last_liq_t13)+" | "+last_ntr_p3+" | "+obj_liqTyp_1+" | "+last_ntr_pr; #endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
  if ((ticket > 7 || (ticket && MQLInfoInteger(MQL_TESTER))) && OrderSelect(ticket, SELECT_BY_TICKET) &&                      // <- *4*
  ((fabs(val1 - last_liq_p2) < val_prec * Point && last_liq_t22 - last_liq_t12 > Period() * 120 && fabs(last_liq_p2 - last_ntr_p2) > val_prec * Point) ||
//   fabs(ObjectGet((obj_liqTypes[pos]=="Buy"?nam_B:nam_S),OBJPROP_PRICE1) - ObjectGet(name, OBJPROP_PRICE1)) > 100 * Point) ||        // voir en option **
   (fabs(val1 - last_liq_p3) < val_prec * Point && last_liq_t23 - last_liq_t13 > Period() * 120 && fabs(last_liq_p3 - last_ntr_p3) > val_prec * Point)) &&
//   fabs(ObjectGet((obj_liqTypes[pos-1]=="Buy"?nam_B2:nam_S2),OBJPROP_PRICE1) - ObjectGet(ObjectName(pos-1),OBJPROP_PRICE1)) > 100 * Point)) &&   // voir en option **
   ((obj_liqTyp_1 == "Buy" && val1 > last_ntr_pr) || (obj_liqTyp_1 == "Sell" && val1 < last_ntr_pr)) &&
  OrderStopLoss() != NormalizeDouble((pr_val1 > 0.0? pr_val1: OrderOpenPrice()) + (OrderType() ? 1 : -1) * (Ask - Bid) / 2, Digits())) {
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+   // case 35:
val1+" | "+last_liq_p2+" | "+(val1-last_liq_p2)+" | "+val_prec+" | "+last_liq_t22+" | "+last_liq_t12+" | "+(last_liq_t22-last_liq_t12)+" | "+(Period()*120)+" | "+
last_ntr_p2+" | "+last_liq_p3+" | "+(val1-last_liq_p3)+" | "+last_liq_t23+" | "+last_liq_t13+" | "+(last_liq_t23 - last_liq_t13)+" | "+last_ntr_p3+" | "+obj_liqTyp_1+" | "+last_ntr_pr); #endif
      if (fabs(OrderStopLoss() - (tmp=(OrderOpenPrice() + (OrderType() ? 1 : -1) * (Ask - Bid) / 2))) > 10.0 && OrderModify(ticket, OrderOpenPrice(), tmp, OrderTakeProfit(), 0, clrSkyBlue))         // <- BE
         if (OrderSelect(ticket, SELECT_BY_TICKET)) Print("** -> OrderModify(BE 4) " + OrderType() + " " + bull_ + " " + bull + " " + bull2 + " " + habull + " " + ticket + " " + t_night + " " +
               TimeToStr(Time[0],TIME_MINUTES) + " " + DoubleToStr(pr_val1, Digits()) + " " + DoubleToStr(pr_val1 + (OrderType() ? 1 : -1) * (Ask - Bid) / 2, Digits()) + " **");
      be_trade = (OrderType() ? -1 : 1) * val1;       be_tick = ticket;       if (OrderType()) BE_s = TimeCurrent();          else BE_b = TimeCurrent(); }

//    v     ici même valriables que case 36:  **
  inv_ExpLine = ((fabs(val1 - last_ntr_p2) < val_prec * Point && last_liq_t22 - last_liq_t12 > Period() * 120 && fabs(last_liq_p2 - last_ntr_p2) > val_prec * Point) ||    // <- *5*
//   fabs(ObjectGet((obj_liqTypes[pos]=="Buy"?nam_B:nam_S),OBJPROP_PRICE1) - ObjectGet(name, OBJPROP_PRICE1)) > 100 * Point) ||        // voir en option **
   (fabs(val1 - last_ntr_p3) < val_prec * Point && last_liq_t23 - last_liq_t13 > Period() * 120 && fabs(last_liq_p3 - last_ntr_p3) > val_prec * Point));
//   fabs(ObjectGet((obj_liqTypes[pos-1]=="Buy"?nam_B2:nam_S2),OBJPROP_PRICE1) - ObjectGet(ObjectName(pos-1),OBJPROP_PRICE1)) > 100 * Point)) &&   // voir en option **

#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(36) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 36:
val1+" | "+last_ntr_p2+" | "+(val1-last_ntr_p2)+" | "+val_prec+" | "+last_liq_t22+" | "+last_liq_t12+" | "+(last_liq_t22-last_liq_t12)+" | "+(Period()*120)+" | "+
last_liq_p2+" | "+last_ntr_p2+" | "+(last_liq_p2-last_ntr_p2)+" | "+last_ntr_p3+" | "+(val1-last_ntr_p3)+" | "+last_liq_t23+" | "+last_liq_t13+" | "+(last_liq_t23-last_liq_t13)+" | "+
last_liq_p3+" | "+last_ntr_p3+" | "+(last_liq_p3 - last_ntr_p3); #endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
  if ((ticket > 7 || (ticket && MQLInfoInteger(MQL_TESTER))) && OrderSelect(ticket, SELECT_BY_TICKET) &&                         // <- *6*
  ((fabs(val1 - last_ntr_p2) < val_prec * Point && last_liq_t22 - last_liq_t12 > Period() * 120 && fabs(last_liq_p2 - last_ntr_p2) > val_prec * Point) ||      // <- *5*
//   fabs(ObjectGet((obj_liqTypes[pos]=="Buy"?nam_B:nam_S),OBJPROP_PRICE1) - ObjectGet(name, OBJPROP_PRICE1)) > 100 * Point) ||        // voir en option **
  (fabs(val1 - last_ntr_p3) < val_prec * Point && last_liq_t23 - last_liq_t13 > Period() * 120 && fabs(last_liq_p3 - last_ntr_p3) > val_prec * Point)) &&
  OrderStopLoss() != NormalizeDouble((pr_val1 > 0.0? pr_val1: OrderOpenPrice()) + (OrderType() ? 1 : -1) * (Ask - Bid) / 2, Digits())) {
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+   // case 36:
val1+" | "+last_ntr_p2+" | "+(val1-last_ntr_p2)+" | "+val_prec+" | "+last_liq_t22+" | "+last_liq_t12+" | "+(last_liq_t22-last_liq_t12)+" | "+(Period()*120)+" | "+
last_liq_p2+" | "+last_ntr_p2+" | "+(last_liq_p2-last_ntr_p2)+" | "+last_ntr_p3+" | "+(val1-last_ntr_p3)+" | "+last_liq_t23+" | "+last_liq_t13+" | "+(last_liq_t23-last_liq_t13)+" | "+
last_liq_p3+" | "+last_ntr_p3+" | "+(last_liq_p3 - last_ntr_p3)); #endif
      if (fabs(OrderStopLoss() - (tmp=(OrderOpenPrice() + (OrderType() ? 1 : -1) * (Ask - Bid) / 2))) > 10.0 && OrderModify(ticket, OrderOpenPrice(), tmp, OrderTakeProfit(), 0, clrSkyBlue))         // <- BE
         if (OrderSelect(ticket, SELECT_BY_TICKET)) Print("** -> OrderModify(BE 6) " + OrderType() + " " + bull_ + " " + bull + " " + bull2 + " " + habull + " " + ticket + " " + t_night + " " +
               TimeToStr(Time[0],TIME_MINUTES) + " " + DoubleToStr(pr_val1, Digits()) + " " + DoubleToStr(pr_val1 + (OrderType() ? 1 : -1) * (Ask - Bid) / 2, Digits()) + " **");
      be_trade = (OrderType() ? -1 : 1) * val1;       be_tick = ticket;       if (OrderType()) BE_s = TimeCurrent();          else BE_b = TimeCurrent(); }

#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(37) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 37:
OrderCloseTime()+" | "+val1+" | "+bb_val2+" | "+(val1-bb_val2)+" | "+val_prec+" | "+OrderType()+" | "+Ask+" | "+OrderOpenPrice()+" | "+a_tmpHiLo+" | "+(a_tmpHiLo / (a_tmpHiLo > 200.0? 2: 1))+" | "+
bb_val1+" | "+(val1 - bb_val1)+" | "+Bid+" | "+pr_val1+" | "+OrderOpenPrice()+" | "+last_liq_pr+" | "+(val1-last_liq_pr)+" | "+last_liq_t22+" | "+last_liq_t12+" | "+(last_liq_t22-last_liq_t12)+" | "+
(Period()*120)+" | "+last_liq_p2+" | "+last_ntr_p2+" | "+(last_liq_p2 - last_ntr_p2)+" | "+last_ntr_pr; #endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
  if (((ticket <= 7 && ! MQLInfoInteger(MQL_TESTER)) || ! ticket) && OrderSelect(be_tick, SELECT_BY_TICKET) && OrderCloseTime() &&        // <- *7* *8*
  (((fabs(val1 - bb_val2) < val_prec && ! OrderType() && Ask < OrderOpenPrice() - a_tmpHiLo / (a_tmpHiLo > 200.0? 2: 1)) || 
  (fabs(val1 - bb_val1) < val_prec && OrderType() && Bid > (pr_val1 > 0.0? pr_val1: OrderOpenPrice()) + a_tmpHiLo / (a_tmpHiLo > 200.0? 2: 1))) ||
  ((fabs(val1 - last_liq_pr) < val_prec * Point && last_liq_t22 - last_liq_t12 > Period() * 120 && fabs(last_liq_p2 - last_ntr_p2) > val_prec * Point) &&
//   fabs(ObjectGet((obj_liqTypes[pos-1]=="Buy"?nam_B2:nam_S2),OBJPROP_PRICE1) - ObjectGet(ObjectName(pos-1),OBJPROP_PRICE1)) > 100 * Point)) &&   // voir en option **
  ((! OrderType() && val1 < last_ntr_pr) || (OrderType() && val1 > last_ntr_pr))))) {
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 37:
OrderCloseTime()+" | "+val1+" | "+bb_val2+" | "+(val1-bb_val2)+" | "+val_prec+" | "+OrderType()+" | "+Ask+" | "+OrderOpenPrice()+" | "+a_tmpHiLo+" | "+(a_tmpHiLo / (a_tmpHiLo > 200.0? 2: 1))+" | "+
bb_val1+" | "+(val1 - bb_val1)+" | "+Bid+" | "+pr_val1+" | "+OrderOpenPrice()+" | "+last_liq_pr+" | "+(val1-last_liq_pr)+" | "+last_liq_t22+" | "+last_liq_t12+" | "+(last_liq_t22-last_liq_t12)+" | "+
(Period()*120)+" | "+last_liq_p2+" | "+last_ntr_p2+" | "+(last_liq_p2 - last_ntr_p2)+" | "+last_ntr_pr); #endif
      if (OrderSelect(ticket, SELECT_BY_TICKET)) Print("** -> DrawArrow_OS 16 " + bull_ + " " + bull + " " + bull2 + " " + habull + " " + ticket + " " + t_night + " " +
            TimeToStr(Time[0],TIME_MINUTES) + " " + DoubleToStr(pr_val1, Digits()) + " " + DoubleToStr(pr_val1 + (OrderType() ? 1 : -1) * (Ask - Bid) / 2, Digits()) + " **");
      DrawArrow_OS(16, ! OrderType()? Ask + 75*vScale*Point: Bid + 312*vScale*Point, 0, 0, ! OrderType(), 0);
      be_trade = 0.0;         be_tick = 0; }          // relatif à *2* *4* *6*

//    v bien testé sur la journée du 19-07-2022 avec le compteur de la fonction DrawArrow_HA()
  int nDrArrHA=nDrArrHAs > 5 && nDrArrHAs > nDrArrHAb? nDrArrHAs: nDrArrHAb > 5? nDrArrHAb: 0;        bool opt=true;
  if ((ticket > 7 || (ticket && MQLInfoInteger(MQL_TESTER))) && OrderSelect(ticket, SELECT_BY_TICKET) && Period() < PERIOD_M30 &&            // <- *9*
  ((tst1=((nDrArrChk > 5 * PERIOD_M15 / Period() && ((OrderType() && OrderOpenPrice() > (dDrArrChk + 25) && Bid < (dDrArrChk - 25)) ||
  (! OrderType() && OrderOpenPrice() < (dDrArrChk - 25) && Ask > (dDrArrChk + 25)))) && OrderStopLoss() != OrderOpenPrice() + (OrderType()? 1: -1) * 20)) ||
  (((tst2=(nDrArrHA > 5 * PERIOD_M15 / Period() && opt && fabs(OrderOpenPrice() - dDrArrHAb) > 50 && ((OrderType() && OrderOpenPrice() > (dDrArrHAb + 25) &&
  Ask < (dDrArrHAb - 25)) || (! OrderType() && OrderOpenPrice() < (dDrArrHAs - 25) && Bid > (dDrArrHAs + 25))))) || (nDrArrHA > 5 * PERIOD_M15 / Period() &&
  ((OrderType() && iClose(NULL,0,iHighest(NULL,0,MODE_CLOSE,12,1)) > (dDrArrHAb + 25) && Ask < (dDrArrHAb - 25)) || (! OrderType() &&
  iClose(NULL,0,iLowest(NULL,0,MODE_CLOSE,12,1)) < (dDrArrHAs - 25) && Bid > (dDrArrHAs + 25))))) && OrderStopLoss() != NormalizeDouble((OrderType() ?
  tst2? fmin(OrderOpenPrice(), dDrArrHAb): fmax(OrderOpenPrice(), dDrArrHAb) : tst2? fmax(OrderOpenPrice(), dDrArrHAs): fmin(OrderOpenPrice(), dDrArrHAs)) +
  (OrderType()? 1: -1) * 20, Digits()))) && (TimeCurrent()-OrderOpenTime() > 600 || tst1) &&          // && TimeCurrent() - N_P_Time > 600
  fabs(dDrArrHAs - OrderOpenPrice()) > 50 && fabs(dDrArrHAb - OrderOpenPrice()) > 50) {
//      if (tst1 || (! tst1 && OrderStopLoss() != NormalizeDouble((OrderType()? tst2? fmin(OrderOpenPrice(), dDrArrHA): fmax(OrderOpenPrice(), dDrArrHA):
//      tst2? fmax(OrderOpenPrice(), dDrArrHA): fmin(OrderOpenPrice(), dDrArrHA)) + (OrderType()? 1: -1) * 20, Digits()))) {                          // v BE
         if (OrderModify(ticket, OrderOpenPrice(), (OrderType()? tst1? OrderOpenPrice(): tst2? fmin(OrderOpenPrice(), dDrArrHAb): fmax(OrderOpenPrice(), dDrArrHAb):
         tst1? OrderOpenPrice(): tst2? fmax(OrderOpenPrice(), dDrArrHAs): fmin(OrderOpenPrice(), dDrArrHAs)) + (OrderType()? 1: -1) * 20, OrderTakeProfit(), 0, clrSkyBlue)) {}
//    ** le "OrderSelect(ticket, SELECT_BY_TICKET)" ne sert qu'à mettre à jour les data donc le OrderStopLoss() **
         if (OrderSelect(ticket, SELECT_BY_TICKET)) Print("** -> OrderModify(BE 9) " + OrderType() + " - " + bull_ + " - " + bull + " - " + bull2 + " - " + habull + " - " + ticket + " - " + t_night +
               " - " + TimeToStr(Time[0],TIME_MINUTES) + " - " + DoubleToStr(pr_val1, Digits()) + " - " + DoubleToStr((OrderType()? tst1? OrderOpenPrice(): tst2? fmin(OrderOpenPrice(), dDrArrHAb):
               fmax(OrderOpenPrice(), dDrArrHAb): tst1? OrderOpenPrice(): tst2? fmax(OrderOpenPrice(), dDrArrHAs): fmin(OrderOpenPrice(), dDrArrHAs)) + (OrderType()? 1: -1) * 20, Digits()) + " - " +
               tst1 + " - " + tst2 + " - " + (nDrArrHA > 5 * PERIOD_M15 / Period() && ((OrderType() && iClose(NULL,0,iHighest(NULL,0,MODE_CLOSE,12,1)) > (dDrArrHAb + 25) &&
               Ask < (dDrArrHAb - 25)) || (! OrderType() && iClose(NULL,0,iLowest(NULL,0,MODE_CLOSE,12,1)) < (dDrArrHAs - 25) && Bid > (dDrArrHAs + 25)))) + " **");
         if (OrderType()) BE_s = TimeCurrent();       else BE_b = TimeCurrent(); }// }

  GlobalVariableSet("last_liq_pr", last_liq_pr);         // pour "retour Heikin Ashi (de CMA).mq4"
/*  view_All_Params(); */              #ifdef v_dump_1 copy_file_45(-1, NULL); #endif

  if (Hour() != 11 && Hour() != 22 && tmp_savd2 > 0) tmp_savd2 = 0;            else if (! int(tmp_savd2) && (Hour() == 11 || Hour() == 22)) { tmp_savd2 = TimeCurrent();         // 23
      int ts1=ShellExecuteW(0,"open","C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal\\6BCF14A3917E5BC71FD48812B8ED0586\\MQL4\\Files\\"+
         "Complet v_Zip.bat", ">Complet_v_Zip.log", "C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal\\6BCF14A3917E5BC71FD48812B8ED0586\\MQL4\\Files", 1); }
  if (Hour() != 11 && Hour() != 22 && tmp_savd3) tmp_savd3 = false;            else if (! tmp_savd3 && (Hour() == 11 || Hour() == 22) && Minute() == 30) { tmp_savd3 = true;     // 23
      int ts2=ShellExecuteW(0,"open","C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal\\6BCF14A3917E5BC71FD48812B8ED0586\\MQL4\\"+
         "Versions v_Zip.bat", "> Versions_v_Zip.log", "C:\\Users\\Administrateur.WIN-UT3H45995UJ\\AppData\\Roaming\\MetaQuotes\\Terminal\\6BCF14A3917E5BC71FD48812B8ED0586\\MQL4", 1); }
#endif
#ifdef v_opfx
  if (r_coptime == INVALID_HANDLE) r_coptime = copy_time(s_coptime);
#endif
  if (r1_coporder == INVALID_HANDLE) r1_coporder = copy_file(s1_coporder, 0);    // ordres en attente de transfert (handle)
  if (r2_coporder == INVALID_HANDLE) r2_coporder = copy_file(s2_coporder, 1);    else if (! r_copyFtp) r_copyFtp = copy_FTP();
  if (r3_coporder == INVALID_HANDLE) r3_coporder = copy_file(s3_coporder, 1);    else if (! r_copyFtp) r_copyFtp = copy_FTP();
  if (r4_coporder == INVALID_HANDLE) r4_coporder = copy_file(s4_coporder, 2);
  GlobalVariableSet("total", total);
  GlobalVariableSet("total2", total2);
  GlobalVariableSet("total3", total3);
  GlobalVariableSet("AccBalance", AccBalance);
//  CreateLabel_end(0,0,0,0,"  WM: "+DoubleToStr(WM,5));
  pass1 = false;     pass1b = Chart_M5 ? false : pass1b;
  return;
}

// calcul du profil de chaque bougie : (précédente obj_liqTypes[]=="Buy" ? -1 : 1) * (iClose() - iOpen()) / (iHigh() - iLow()) > 0.3  (> 30%)
//       testés entre deux bougies identifiées par deux valeurs de obj_bars[pos]

void OnDeinit(const int reason) {
#ifdef v_opfx
  if (mOrderSelect(mOrdersTotal(magic_nb)==1?0:2,SELECT_BY_POS)) ticket = OrderTicket();
#endif
#ifndef v_opfx_0
  GlobalVariableSet("Bullish", bull_);
  GlobalVariableSet(tr_allow? tck_vstr: "Ticket0", ticket);
  Print("*** -> Ticket SAVED! ",ticket," ***");
#else
  int ticket_=GlobalVariableGet(tck_vstr);         bool t_tick=(ticket_ > 7);
  GlobalVariableSet(tr_allow || t_tick ? tck_vstr : "Ticket0", ticket);
  Print("*** -> Ticket SAVED! ",IntegerToString(ticket)," - ",IntegerToString(bull_)," - ",DoubleToStr(OrderLots(),2)," ***");
  ObjectDelete(LabelNameEnd);                   GlobalVariableSet(bull_str, bull_);
  Print("*** END_EA -> ", TimeToStr(TimeCurrent(), TIME_DATE|TIME_MINUTES), " ("+IntegerToString(reason)+") ***");

  SL = ((iHigh(NULL, 0, 5) - iLow(NULL, 0, 5)) + (iHigh(NULL, 0, 1) - iLow(NULL, 0, 1)) + (iHigh(NULL, 0, 2) -    // <- tmpHiLo
      iLow(NULL, 0, 2)) + (iHigh(NULL, 0, 3) - iLow(NULL, 0, 3)) + (iHigh(NULL, 0, 4) - iLow(NULL, 0, 4))) / Point / 5;
  if (ticket > 7 && OrderSelect(ticket, SELECT_BY_TICKET))
      if (OrderModify(ticket, OrderOpenPrice(), OrderType()? Bid+SL/(SL>200.0? 2: 1): Ask-SL/(SL>200.0? 2: 1), OrderTakeProfit(), 0, clrSkyBlue)) {}

  if (ac_ticket && OrderSelect(ac_ticket, SELECT_BY_TICKET)) if (((TimeCurrent() - OrderOpenTime() > 2 * 3600 && ((OrderType() &&      // 25 et 75 ne sont que pour le BTC
   OrderOpenPrice() - Ask < 25) || (! OrderType() && Bid - OrderOpenPrice() < 25))) || (OrderType() && Ask - OrderOpenPrice() > 110) ||
   (! OrderType() && OrderOpenPrice() - Bid > 110)) && OrderClose(ac_ticket, lot, OrderType()? Ask: Bid, slip, OrderProfit()>0? Aqua: Yellow)) {
      Alert("***** Le signal d'accélération a été annulé (2) : " + IntegerToString(ac_ticket) + " - " + (TimeCurrent() - OrderOpenTime()) + " - " +
         DoubleToStr(OrderType()? Ask - OrderOpenPrice(): OrderOpenPrice() - Bid, Digits()) + " ! *****");     ticket = 0;    ac_ticket = 0; }

#ifdef v_dump_1  if (f_tmp4 != "") copy_file_45(-1, NULL); #endif
  tmp3 = "*****3* "+TimeToStr(TimeCurrent(), TIME_MINUTES|TIME_SECONDS)+" "+DoubleToStr(a_tim5 - floor(a_tim5 / 1000) * 1000, 0) + " - " +
      a_tim1+" - "+a_tim2+" - "+val2+" - "+val1+" / "+dval2+" - "+val4+" - "+val3+" / "+dval3+" - "+val6+" - "+val5+" / "+dval4+" - "+val7+" - "+ival1+" / "+a_tim5+" - "+a_tim6+" - "+dval4+" - "+dval5+
      " / "+co_a1+" - "+co_a3+" - "+co_a5+" - "+co_a7+" | "+c_reg1+" - "+c_reg3+" - "+c_reg5+" - "+c_reg7+" / "+a_tim0+" - "+a_tim0b+" *****";
  StringReplace(tmp3, " - ", " / ");            StringReplace(tmp3, " | ", " / ");
  tmp3 = StringSubstr(tmp3, 8, StringLen(tmp3) - 15) + "- ";         a_copy_file_(1, tmp3);
#endif
//  if (reason == 3) ObjectsDelete(2);
  ObjectDelete(LabelNameEnd);    ObjectDelete(LabelNameEnd2);
//  Comment("");
  return;
}

int tim_min;
void OnTimer() { t_web ++;
   if (! t_web || t_web >= 450) { ResetLastError();      cpt = 0;
      int res=1, timeout=5000;         char post[], result[];
      string URL="http://www.ecomclub.com/transfert_VPS/FH2/", headers;

      if ((StrToInteger(StringSubstr(TimeToStr(TimeLocal(), TIME_DATE), 8, 2)) == Day() && DayOfWeek() && DayOfWeek() < 6)) {
         URL = "http://www.ecomclub.com/web_send_mail.php?vps=FH2b_6BCF1&src=ATS_BTC";    res = WebRequest("GET", URL, NULL, NULL, timeout, post, 0, result, headers); }
      ScrShot2web();       t_web = 0;        TrailingStop(2, 30, NULL); }
   if (! t_web || ! (t_web % 150)) { TrailingStop(1, 30, NULL);         tim_min = Minute();#ifdef o_real
      double vScale=(WindowPriceMax()-WindowPriceMin())/(!WindowPriceMax()?1.154:WindowPriceMax())/1.154/(1.154-1.061);          ObjectsPositions(vScale);
      if (! DrawArrow_chk(WindowPriceMax()-50 * vScale*Point,0, 1)) {/*Print("*** DrawArrow_chk Error (1): ", GetLastError(), " ***");*/}#endif

      bool tst=false, tst1;      string Symbs="";
      for (int pos=0; pos < ObjectsTotal(); pos ++) {    // && ! tst
         string name=ObjectName(pos);              datetime time1=ObjectGet(ObjectName(pos), OBJPROP_TIME1);
         tst1 = (StringSubstr(name, 0, 9) == "FXSSI.CAL" && ((TimeCurrent() < time1 && time1 - TimeCurrent() < 600) ||
            (TimeCurrent() > time1 && TimeCurrent() - time1 < 900)));
         if (tst1) Symbs += ObjectGet(ObjectName(pos), OBJPROP_TEXT) + "|";        tst = tst? tst: tst1; } }
//   return(res >= 0);
   TrailingStop(0, tst? 50: 30, Symbs);
//   return(res >= 0);

   if (TimeCurrent() == prevTimeCurrent && ! clrYell) {
      Comment ("Market is CLOSED - Local Time : ",TimeLocal()," - ",Hour(),":",Minute()," *");
      infoMarket = FALSE; }

   else { Comment("");
//      Comment ("Market is OPEN - Local Time : ",TimeLocal()," - ",Hour(),":",Minute()," *");
      infoMarket = TRUE; }

  prevTimeCurrent = TimeCurrent(); }

int nDrArrChk=0;     double dDrArrChk_, dDrArrChk, dDrArrChk1;       datetime tDrArrChk;
bool DrawArrow_chk(double LinePrice,int BarNum,int I) { //int tmfr=Period();
   string/* stmfr= tmfr==PERIOD_M1? "M1": tmfr==PERIOD_M5? "M5": tmfr==PERIOD_M15? "M15": tmfr==PERIOD_M30? "M30": 
      tmfr==PERIOD_H1? "H1": tmfr==PERIOD_H4? "H4": tmfr==PERIOD_D1? "D1": tmfr==PERIOD_W1? "W1": "MN1", */
      ArrowName="EA_Check-"+stmfr+"-"+IntegerToString(I)+"_"+IntegerToString(BarNum)+" "+IntegerToString(Time[BarNum]);
   if (! ObjectCreate(ArrowName,OBJ_ARROW,0,Time[BarNum],LinePrice)) return false;
   dDrArrChk_ = dDrArrChk > 0.0? dDrArrChk: dDrArrChk1;              dDrArrChk1 = LinePrice;
   if (fabs(dDrArrChk_ - dDrArrChk1) < 10) { nDrArrChk ++;
      if (nDrArrChk > 5 * PERIOD_M15 / Period()) { tDrArrChk = TimeCurrent();    dDrArrChk = dDrArrChk1; } }
   else  if (TimeCurrent() - tDrArrChk > 900) { nDrArrChk = 0;       dDrArrChk = 0.0; }
Alert("***** dDrArrChk (* 3) " + DoubleToStr(dDrArrChk_, Digits()) + " - " + DoubleToStr(dDrArrChk1, Digits()) + " - " + DoubleToStr(dDrArrChk, Digits()) +
   " - " + IntegerToString(nDrArrChk) + " - " + TimeToStr(tDrArrChk, TIME_MINUTES) + " *****");
   ObjectSet(ArrowName, OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet(ArrowName, OBJPROP_ARROWCODE, I? 252: 251);
   ObjectSet(ArrowName, OBJPROP_COLOR, I==1? clrSilver: clrSkyBlue);
#ifndef v_opfx_0
   ObjectSet(ArrowName, OBJPROP_ARROWCODE, I==3? 251: 252);
#else
   ObjectSet(ArrowName, OBJPROP_ARROWCODE, I==3? 251: I==4? fl_Trade? 252: 253: 252); // I==4? 252 si FollowTrade activé
#endif
   ObjectSet(ArrowName, OBJPROP_COLOR, I==1 || I>=4? I==1 && mOrdersTotal(magic_nb)? clrGold: clrSilver: clrSkyBlue);
   ObjectSet(ArrowName, OBJPROP_SELECTABLE, 0);
   ObjectSet(ArrowName, OBJPROP_SELECTED, 0);
   ObjectSet(ArrowName, OBJPROP_WIDTH, I==5? 1: 2);
//   ObjectSet(ArrowName, OBJPROP_YDISTANCE, 55);
   return true;
}

#ifdef v_opfx_0
bool time_allow=true;
#endif
bool DrawArrow_OS(int Typ,double LinePrice,int BarNum,int Code,bool Bullish,int Clot) {
#ifdef v_opfx_0
   if (Clot && Typ == 8 && (pr_val1 > 0.0 || (H1 < H3 && t_rsi515o))) return(false);
   string str="-"+StringSubstr(EnumToString(magic_nb), 0, 3), temp;     int i=iCustom(NULL, 0, "super-trend_.ex4", 10, 4.5, 1, 1) == 2147483647? 0: 1;
   if (Clot && pr_val1>0.0 && (Typ==8 || (Typ==10 && ac_ticket==Clot && OrderSelect(ac_ticket, SELECT_BY_TICKET) && fabs(OrderOpenPrice()-(Bid+Ask)/2)<100) || Bullish==bull_)) return(false);
Alert("***** Suivi SuperTrend! - " + Bullish + " - " + DoubleToStr(sup_trend, Digits()) + " - " + iCustom(NULL, 0, "super-trend_.ex4", 10, 4.5, 0, 1) + " - " +
   iCustom(NULL, 0, "super-trend_.ex4", 10, 4.5, 1, 1) + " - " + (Bid + Ask) / 2 + " - " + ((! Bullish && sup_trend < Bid) || (Bullish && sup_trend > Ask)) + " - " +
   IntegerToString(i) + " - " + iCustom(NULL, 0, "super-trend_.ex4", 10, 4.5, 0, 1) + " - " + iCustom(NULL, 0, "super-trend_.ex4", 10, 4.5, 1, 1) + " *****");
   if (Typ != 13 && ! Clot && ! ticket && ((! Bullish && sup_trend < Bid && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.5, i, 1) < Bid) || (Bullish && sup_trend > Ask &&
   iCustom(NULL, 0, "super-trend_.ex4", 10, 4.5, i, 1) > Ask) || (Bullish && TimeCurrent()-BE_b < 1800) || (! Bullish && TimeCurrent()-BE_s < 1800)) && Hour() > 2) return(false);
   if (! Clot && ((!(((Hour()>1 || (Hour() && Minute()>2)) && (Hour()<23 || Minute()<59)) || (Bid>0 && Ask>Bid && (Ask-Bid)*Point < 8)) &&
      (Period() > PERIOD_M15 || DayOfWeek() == 5)) || (t_night && (Hour() < H1 && (H1<H3 || Hour()>H3)) && (Hour() || Seconds() > 3)))) {    // 6
      if (time_allow) { Print("*** TRADE ANNULE A CAUSE FIN DE JOURNEE ! "+IntegerToString(Hour())+"h "+IntegerToString(Minute())+"m ***");
         CreateObText(0, LinePrice,BarNum,Bullish,"*ANNULE*"); }           Sleep(100);
         if (t_night) GlobalVariableSet(bull_str, Bullish);             return((time_allow=false)); }       else time_allow = true;
   if ((Period() == PERIOD_M30#ifdef mkt_stocks || (magic_nb==50100600 && Period()==PERIOD_M1)#endif) && (FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0) ||
      FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Sell.txt", 0))) Bullish = FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0)? true: false;
   bool t_monday=(DayOfWeek() < First_Day || (DayOfWeek() == First_Day && Hour() < 5) || ! TerminalInfoInteger(TERMINAL_TRADE_ALLOWED)), tst_5, tst_6, tr_Allow, t_Night;
   tst_5b = Clot || tst_5c < Time[0] || (((tmfr == PERIOD_H1 || tmfr == PERIOD_M30) && ((FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0) &&  // || tmfr == PERIOD_M5
      Bullish) || (FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Sell.txt", 0) && ! Bullish))) || Typ < 5 || tmfr == PERIOD_M1 || tmfr == PERIOD_M5);
// ** ou utiliser tr_allow_ = tr_allow au début et tr_allow = tr_allow_ à la fin, à la place de tr_Allow **
/*   t8_rsi515o = H1 < H3 && ((t_rsi515o && Typ != 8) || (! t_rsi515o && Typ == 8));
   tr_Allow = tr_allow || Typ == 7 || t8_rsi515o;              t_Night = ! (! t_night || Typ == 7 || t8_rsi515o); */
   tr_Allow = (tr_allow || Typ == 7 || (Typ > 12 && Typ < 16)) && ! inv_LiqLine && ! inv_ExpLine;     t_Night = ! (! t_night || Typ == 7 || (Typ > 12 && Typ < 16));
   if (ticket <= 7 && tr_Allow) { ticket = 0;      GlobalVariableSet(tck_vstr, ticket); }
#endif
   Bullish = Clot? Bullish? false: true: Bullish;        int ticket_=ticket#ifdef v_opfx_0, cpt2=1, tmfr_n#endif;       //, tmfr;
   string ArrowName = "EA_OS-"+IntegerToString(Typ)+(Typ==1||Typ==4?"-out":"-in")+"_Arr"+(Bullish? "-Up_": "-Down_")+   //&&!Clot)||(!Bullish&&Clot)
      IntegerToString(Code?Code:Bullish?241:242)+"-"+IntegerToString(BarNum)+"-"+IntegerToString(Clot)+" "+IntegerToString(TimeCurrent());
   if (tst_5b && cpt == 1) { if (! ObjectCreate(ArrowName,OBJ_ARROW,0,Typ==1? blue_time: Time[BarNum],LinePrice)) return false;
      if (Typ > 5) DrawArrow(LinePrice, BarNum, Typ==6? 134: Typ==7? 135: Typ==8? 136: Typ==9? 137: 138, Bullish, Clot); }
   if (Typ==1) blue_time = 0;       if (Typ==3) orge_time = 0;          if (Typ==4) vilt_time = 0;    //: Typ==3? orge_time: Typ==4? vilt_time
   if (Typ==3 || Typ==5) { ADX_time = 0;        St_Trd = false;      FileMove("St-Trd_On.txt", FILE_COMMON, "St-Trd_Off.txt", FILE_COMMON); }
   if (Typ==2 || Typ==5) FileMove("ATS-Int_On.txt", FILE_COMMON, "ATS-Int_Off.txt", FILE_COMMON);
   ObjectSet(ArrowName, OBJPROP_ARROWCODE, tr_Allow? Bullish? SYMBOL_ARROWUP: SYMBOL_ARROWDOWN: Bullish? 233: 234);
   ObjectSet(ArrowName, OBJPROP_COLOR, Typ==1? clrSkyBlue: Typ==3? clrOrange: Typ==4? clrViolet: 
                                                Bullish? Typ==2? clrMediumSpringGreen: clrLimeGreen: Typ==2? clrViolet: clrDeepPink);
   ObjectSet(ArrowName, OBJPROP_SELECTABLE, 0);
   ObjectSet(ArrowName, OBJPROP_SELECTED, 0);               //ticket = Clot? 0: ticket;
   ObjectSet(ArrowName, OBJPROP_WIDTH, (Typ > 12 && Typ < 16) ? 2: Typ == 2 ? 4: 5);
   bool t_close=false, t_tick=ticket#ifdef v_opfx_0, vtst=(DayOfWeek() == 5 && Hour() == 23 && Minute() > 57)#endif;
   if (AccBalance != AccountBalance()) AccBalance = AccountBalance();         p_Coef = 100.0;   // revoir avec pips2dbl et lot
Alert("***** TEST ALLOWED! (1) " + vtst + " " + cpt2 + " " + tr_allow + " " + ticket + " " + Clot + " " + t_close + " " + Bullish + " *****");
#ifndef v_opfx_0
   if ((Clot || ticket) && ((OrderSelect(floor(Clot? Clot: ticket), SELECT_BY_TICKET) && ! OrderCloseTime()) || ! tr_allow))
#else
   while ((Clot || ticket > 7) && ! t_close && cpt2 < 4) {
      if ((((vtst && mOrderSelect(mOrdersTotal(magic_nb)==1?0:2,SELECT_BY_POS)) ||
         OrderSelect(floor(Clot? Clot: ticket), SELECT_BY_TICKET)) && ! OrderCloseTime()) || ! tr_Allow)
#endif
      while (! t_close && cpt2 < 4) { t_close = OrderClose(floor(Clot? Clot: ticket), lot, Bullish? Bid: Ask, slip, Clot? OrderProfit()>0? Aqua: Yellow: clrNONE);
if (t_close) Alert("***** TEST CLOSED! (2) " + vtst + " " + tr_allow + " " + ticket + " " + Clot + " " + t_close + " " + Bullish + " *****");
else  Alert("***** TEST NOT CLOSED! (2) " + vtst + " " + tr_allow + " " + ticket + " " + Clot + " " + t_close + " " + Bullish + " " +  GetLastError() + " *****");
         if (t_close || ! tr_Allow) { ticket = 0;           total3_ = total3;          if (! tr_Allow) t_close = true;
            Print("** -> OrderClose ",ticket_," - ",Typ," - ",OrderProfit()," - ",OrderSwap()," - ",OrderCommission()," - ",DoubleToStr(OrderOpenPrice(),5)," - ",
   DoubleToStr(OrderClosePrice(),5)," - ",DoubleToStr(Bid,5)," - ",DoubleToStr(Ask,5)," - ",TimeToStr(OrderCloseTime(),TIME_MINUTES)," - ",TimeToStr(TimeCurrent(),TIME_MINUTES)," **");
//            p_Coef = fabs(OrderClosePrice() - OrderOpenPrice() / OrderProfit()) / Point; //p_Coef (= 100 pour lot = 0.01)
            total3 += (OrderProfit() + OrderSwap() + OrderCommission()) * p_Coef;
            AccBalance += OrderProfit() + OrderSwap() + OrderCommission();
            if (AccountBalance() - AccBalance > -0.015) Print("** -> AccountBalance() - AccBalance! (1) ",(AccountBalance() - AccBalance)," ***");
            else  Print("** -> AccountBalance() - AccBalance! (2) ",(AccountBalance() - AccBalance)," - ",AccountBalance()," - ",AccBalance," (",
               OrderProfit()," - ",OrderSwap()," - ",OrderCommission()," - ",DoubleToStr(OrderOpenPrice(),5)," - ",DoubleToStr(OrderClosePrice(),5),") ***");
            if (AccBalance != AccountBalance()) { total3 += (AccountBalance() - AccBalance) * p_Coef;
               if (AccountBalance() - AccBalance > -0.015) AccBalance = AccountBalance(); } }
#ifndef v_opfx_0
         else  Sleep(1000); }                             // v attention au spread en fin de marché -> ok si décalage favorable **
#else
         else if (infoMarket && !t_Night && (!vtst || cpt2 < 4)) { Sleep(1000);     if (vtst) cpt2 ++; }       else break; }   //if (vtst) cpt2 ++;
#endif
//Alert("TEST ALLOWED! (3) " + tr_allow + " " + ticket + " " + Clot + " " + t_close + " " + Bullish);
   if (Typ != 13 && ! Clot && ((! Bullish && sup_trend < Bid && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.5, i, 1) < Bid) ||
   (Bullish && sup_trend > Ask && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.5, i, 1) > Ask))) return(false);
   if (ticket) { Print("** -> Ticket Select ERROR! (1) (cpt ",cpt,", typ ",Typ,") ",GetLastError(),", ticket ",ticket," ***");
#ifndef v_opfx_0
      if (Clot && (ticket==1 || cpt==2)) { ticket = 0;   cpt = 1; }     else cpt ++; }
#else
      if (ticket <= 7 || cpt > 2) { if (! vtst) ticket = 0;     cpt = 1; }    else { cpt ++;      //Clot && 
         if (infoMarket && !t_Night) Sleep(100);         if (mOrderSelect(mOrdersTotal(magic_nb)==1?0:2,SELECT_BY_POS)) {
            ticket = OrderTicket();          Print("*** -> (3) Ticket LOADED! ",ticket," - ... ***"); } } }    cpt2 ++; }
   if (ticket) Print("** -> Ticket Select ERROR! (2) (cpt ",cpt,", typ ",Typ,") ",GetLastError(),", ticket ",ticket,", tr_Allow ",tr_Allow,", t_Night ",t_Night," ***");
#endif
   else if (! Clot || ! tr_Allow) { if (! tr_Allow) { ticket = Clot ? 0 : ticket_ + 1;    //(tmfr=Period())
         if (! Clot) { Print((s2_coporder="** -> ATS 1.01 Ultimate PERIOD_" + (tmfr==PERIOD_M1? "M1": tmfr==PERIOD_M5? "M5": tmfr==PERIOD_M15? "M15": tmfr==PERIOD_M30? "M30": 
               tmfr==PERIOD_H1? "H1": tmfr==PERIOD_H4? "H4": tmfr==PERIOD_D1? "D1": tmfr==PERIOD_W1? "W1": "MN1") + " " + Symbol() + " " + (Bullish? "BUY": "SELL")));
            s1_coporder = "0 Liste_dObjets_EA 0 0 ATS 1.01 Ultimate PERIOD_" + (tmfr==PERIOD_M1? "M1": tmfr==PERIOD_M5? "M5": tmfr==PERIOD_M15? "M15": tmfr==PERIOD_M30? 
               "M30": tmfr==PERIOD_H1? "H1": tmfr==PERIOD_H4? "H4": tmfr==PERIOD_D1? "D1": tmfr==PERIOD_W1? "W1": "MN1") + " " + Symbol() + " " + (Bullish? "BUY": "SELL") + " - | " +
            IntegerToString(Typ) + " " + DoubleToStr(Bullish? Ask: Bid, 2) + " " + IntegerToString(int(Typ==1? blue_time: Time[BarNum])) + " " + IntegerToString(Code) + " " + IntegerToString(Bullish); }
         else { Print((s2_coporder="** -> ATS 1.01 Ultimate PERIOD_" + (tmfr==PERIOD_M1? "M1": tmfr==PERIOD_M5? "M5": tmfr==PERIOD_M15? "M15": tmfr==PERIOD_M30? "M30": 
               tmfr==PERIOD_H1? "H1": tmfr==PERIOD_H4? "H4": tmfr==PERIOD_D1? "D1": tmfr==PERIOD_W1? "W1": "MN1") + " " + Symbol() + " " + (Bullish? "BUY": "SELL") + " CLOT"));
            s1_coporder = "0 Liste_dObjets_EA 0 0 ATS 1.01 Ultimate PERIOD_" + (tmfr==PERIOD_M1? "M1": tmfr==PERIOD_M5? "M5": tmfr==PERIOD_M15? "M15": tmfr==PERIOD_M30? 
               "M30": tmfr==PERIOD_H1? "H1": tmfr==PERIOD_H4? "H4": tmfr==PERIOD_D1? "D1": tmfr==PERIOD_W1? "W1": "MN1") + " " + Symbol() + " " + (Bullish? "BUY": "SELL") + " CLOT | " +
            IntegerToString(Typ) + " " + DoubleToStr(Bullish? Ask: Bid, 2) + " " + IntegerToString(int(Typ==1? blue_time: Time[BarNum])) + " " + IntegerToString(Code) + " " + IntegerToString(Bullish); }
         s2_coporder = TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS) + " " + s2_coporder + ", DrawArrow_OS(" + IntegerToString(Typ) + ")";
         r1_coporder = copy_file(s1_coporder, 0);           r2_coporder = copy_file(s2_coporder, 1);           r4_coporder = copy_file((s4_coporder=TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS) +
            ";Liste dObjets EA;" + DoubleToStr(LinePrice,1) + ";" + (Bullish? "Buy": "Sell") + ";B/A;" + DoubleToStr(Bullish? Ask: Bid, 1) + ";Typ=" + IntegerToString(Typ)), 2);
/*         Alert("ATS 1.01 Ultimate PERIOD_" + ((tmfr=Period())==PERIOD_M1? "M1": tmfr==PERIOD_M5? "M5": tmfr==PERIOD_M15? "M15": tmfr==PERIOD_M30? "M30": 
      tmfr==PERIOD_H1? "H1": tmfr==PERIOD_H4? "H4": tmfr==PERIOD_D1? "D1": tmfr==PERIOD_W1? "W1": "MN1") + " " + Symbol() + " " + (Bullish? "BUY": "SELL"));*/ }
      else#ifdef v_opfx_0 { if ((tst_5=(((tmfr == PERIOD_H1 || tmfr == PERIOD_M30) && ((FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0) &&     // || tmfr == PERIOD_M5
      Bullish) || (FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Sell.txt", 0) && ! Bullish))) || Typ < 5 || (tmfr <= PERIOD_M15 && (str != "-CHN" || (tst_6 =
      (OrderProfit() / lot < 100 || m3_RSI(0, 2) < 38 || m3_RSI(0, 2) > 62))))))) {       // && (str=="-GLD" || t_night))
        #endif SL2 = Bullish ? dDrArrHAb > 0.0 ? dDrArrHAb : dDrArrHAb_ : dDrArrHAs > 0.0 ? dDrArrHAs : dDrArrHAs_;
         TP2 = ! Bullish ? dDrArrHAb > 0.0 ? dDrArrHAb : dDrArrHAb_ : dDrArrHAs > 0.0 ? dDrArrHAs : dDrArrHAs_;
         if (SL2 > 0.0) { if (fabs(TP2 - (Bid + Ask) / 2) < fabs(SL2 - (Bid + Ask) / 2) || ! TP2) TP2 = Bid + Ask - SL2;
               if (fabs(SL2 - (Bid + Ask) / 2) < fabs(TP2 - (Bid + Ask) / 2) * 0.3) SL2 = (Bid + Ask) * 3.0 / 2.0 - TP2 / 2.0; }    else SL2 = Bullish ? Ask - SL : Bid + SL;
         ticket = OrderSend(Symbol(), Bullish? ORDER_TYPE_BUY: ORDER_TYPE_SELL, lot, Bullish? Ask: Bid, slip,#ifndef v_opfx_0 0.0, 0.0, NULL#else/* str == "-HKG" ?
            round(Bullish ? Ask - SL : Bid + SL) : str == "-GER" && Typ == 9 ? Bullish ? iLowest(NULL, 0, MODE_CLOSE, 5, 0) : iHighest(NULL, 0, MODE_CLOSE, 5, 0) : Bullish ? 
            Ask - SL : Bid +*/ SL2, TP2, (Bullish? "buy": "sell") + " - " + stmfr#endif, magic_nb);
         GlobalVariableSet(Symbol() + StringSubstr(IntegerToString(ticket), StringLen(IntegerToString(ticket)) - 4) + "_TP2", TP2);
#ifdef v_opfx
       if (OrderProfit() != 0 || OrderSwap() != 0 || OrderCommission() != 0) 
         copy_file_(2, TimeToStr(TimeCurrent())+":"+IntegerToString(Seconds())+"."+IntegerToString(getCurrentMs()%1000)+
            " ** -> OrderSend ("+Typ+") "+ticket+" "+OrderProfit()+" - "+OrderSwap()+" - "+OrderCommission()+" - "+
            DoubleToStr(OrderOpenPrice(),5)+" - "+DoubleToStr(OrderClosePrice(),5)+" **");
       if (OrderSelect(floor(ticket), SELECT_BY_TICKET)) 
         copy_file_(2, TimeToStr(TimeCurrent())+":"+IntegerToString(Seconds())+"."+IntegerToString(getCurrentMs()%1000)+
            " ** -> OrderSend ("+Typ+") "+ticket+" "+OrderProfit()+" - "+OrderSwap()+" - "+OrderCommission()+" - "+
            DoubleToStr(OrderOpenPrice(),5)+" - "+DoubleToStr(OrderClosePrice(),5)+" - Op_Liq2-4 "+Op_Liq2+"-"+Op_Liq4+" **"); }
#else }#endif
       if (! tr_Allow) { Print("NOT ALLOWED! ", tr_Allow);            Alert("NOT ALLOWED! " + tr_Allow); } }
#ifdef v_opfx_0
      if (str == "-CHN" && ! tst_6) t_ngt0 = true;       if (ticket < 0 && tr_Allow) { ticket = 0;
         Print("*** OrderSend failed with error #",GetLastError()," - "+Symbol()+"-"+(Bullish? "Buy": "Sell")+"-"+Period()+" - "+
            DoubleToStr(StringSubstr(str, 1, 3)=="HKG"? round(Bullish? Ask-SL: Bid+SL): Bullish? Ask-SL: Bid+SL, Digits())+" ***"); }
      if (Period() == PERIOD_M30) { FileMove("ATS-Ind_On-Off\\ATS-Ind_Buy.txt", 0, "ATS-Ind_On-Off\\ATS-Ind_Off.txt", 0);
         FileMove("ATS-Ind_On-Off\\ATS-Ind_Sell.txt", 0, "ATS-Ind_On-Off\\ATS-Ind_Off.txt", 0); }        if (Typ == 13) ac_ticket = ticket;
      if (Typ == 5 || Typ == 13) { bool tst=false;    int t=0, t1=0, t2=0, err1, err2=0;     while(!tst && t<17 && tmfr_n!=Period()) {
         if (Period() == PERIOD_H1 || Period() == PERIOD_M30) { tmfr_ = Period();     GlobalVariableSet(t_ATS_str, Time[0]);
            while(! (tst=ChartSetSymbolPeriod(0, NULL, (tmfr_n=PERIOD_M5))) && t1 < 17) { t1 ++;      Sleep(100); }     err1 = GetLastError();
            if (tst) { Sleep(50);     ChartSetInteger(0, CHART_SCALE, 0, 3);         tmfr = PERIOD_M5;      tmf_Diff = true;
//               while((! Chart_M5 || ! int(ChartPeriod(Chart_M5))) && t2 < 17) { t2 ++;    Chart_M5 = chart_find();   Sleep(100); }
               if (! chk_chartm5(8)) { temp = "*** ERROR Chart_M5 (1) "+IntegerToString(ChartPeriod(Chart_M5))+" - "+IntegerToString(Chart_M5)+" ***";
                  Alert(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp); }
               t2 = 0;     while(! ChartSetSymbolPeriod(Chart_M5, NULL, ENUM_TIMEFRAMES(tmfr_)) && t2 < 17) { t2 ++;    Sleep(100); }
               Sleep(50);            ChartSetInteger(Chart_M5, CHART_SCALE, 0, 5);                err2 = GetLastError();
               tim_Chart_M5 = TimeCurrent();       GlobalVariableSet(t1_Chart_str, tim_Chart_M5);
               t5a_Bullish = Bullish;              t5b_Bullish = FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0);
               GlobalVariableSet(t1_Bull_str, t5a_Bullish);    GlobalVariableSet(t2_Bull_str, t5b_Bullish);
               GlobalVariableSet(tmfr1_str, tmfr_);            GlobalVariableSet(tmfr0_str, tmfr); } }
/*         else if (Period() == PERIOD_M5 && ! t_night) { tmfr_b = Period();
            while(! (tst=ChartSetSymbolPeriod(0, NULL, (tmfr_n=PERIOD_M1))) && t1 < 17) { t1 ++;      Sleep(100); }     err1 = GetLastError();
            if (tst) { Sleep(50);        ChartSetInteger(0, CHART_SCALE, 0, 4);              tmfr = PERIOD_M1;
//               while((! Chart_M5 || ! int(ChartPeriod(Chart_M5))) && t2 < 17) { t2 ++;    Chart_M5 = chart_find();   Sleep(100); }
               if (! chk_chartm5(9)) Alert("*** ERROR Chart_M5 (2) "+IntegerToString(ChartPeriod(Chart_M5))+" - "+IntegerToString(Chart_M5)+" ***");
               t2 = 0;     while(! ChartSetSymbolPeriod(Chart_M5, NULL, ENUM_TIMEFRAMES(tmfr_b)) && t2 < 17) { t2 ++;     Sleep(100); }
               Sleep(50);           ChartSetInteger(Chart_M5, CHART_SCALE, 0, 5);            err2 = GetLastError();
               tim_Chart_M5b = TimeCurrent();      GlobalVariableSet(t2_Chart_str, tim_Chart_M5b);
               t5a_Bull_b = Bullish;               t5b_Bull_b = FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0);
               GlobalVariableSet(t3_Bull_str, t5a_Bull_b);     GlobalVariableSet(t4_Bull_str, t5b_Bull_b);
               GlobalVariableSet(tmfr2_str, tmfr_b);           GlobalVariableSet(tmfr0_str, tmfr); } } */       else t = 17;
#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(18) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 18:
Typ+" | "+tst+" | "+t+" | "+t1+" | "+t2+" | "+err1+" | "+err2+" | "+tmfr_n+" | "+Period()+" | "+tmfr_+" | "+Time[0]+" | "+tmfr+" | "+tmf_Diff+" | "+Chart_M5; #endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
         if (tmfr_n==Period()) { temp = "** Passage SANS effet en M"+IntegerToString(tmfr_n)+" avec OrderSend "+(tst_5? "OK": "ANNULE")+" ! (Typ="+IntegerToString(Typ)+
               ", Period()=" + IntegerToString(Period()) + ", Bullish=" + (Bullish) + ") *(18)*";
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 18:
Typ+" | "+tst+" | "+t+" | "+t1+" | "+t2+" | "+err1+" | "+err2+" | "+tmfr_n+" | "+Period()+" | "+tmfr_+" | "+Time[0]+" | "+tmfr+" | "+tmf_Diff+" | "+Chart_M5);
copy_file_45(5, "18;"+TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+";"+IntegerToString(TimeCurrent())+";"+IntegerToString(Period())); #endif
            Print(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp); }
         else if (tst) { temp = "** Passage en M"+IntegerToString(tmfr_n)+" avec OrderSend "+(tst_5? "OK": "ANNULE")+" ! (Typ="+
               IntegerToString(Typ) + ", Period()=" + IntegerToString(Period()) + ", Bullish=" + (Bullish) + ", t1="+IntegerToString(t1) + ", t2="+IntegerToString(t2) +
               (t2==17 ? ", err2=" + IntegerToString(err2) : "") + ") *(19)*";
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 18:
Typ+" | "+tst+" | "+t+" | "+t1+" | "+t2+" | "+err1+" | "+err2+" | "+tmfr_n+" | "+Period()+" | "+tmfr_+" | "+Time[0]+" | "+tmfr+" | "+tmf_Diff+" | "+Chart_M5);
copy_file_45(5, "19;"+TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+";"+IntegerToString(TimeCurrent())+";"+IntegerToString(Period())); #endif
            Print(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp);
            if (tmf_Diff_b > 1) ObjectSet(ArrowName, OBJPROP_ARROWCODE, tr_Allow? tmf_Diff? 215: 216: tmf_Diff? 223: 224);    ObjectSet(ArrowName, OBJPROP_WIDTH, 3); }
         else { if (Period()>PERIOD_M1) { temp = "*** Erreur - Passage en M5 (ou M1) avec OrderSend "+(tst_5? "OK": "ANNULE")+" ! (Typ="+IntegerToString(Typ)+
               ", Period()=" + IntegerToString(Period()) + ", Bullish=" + (Bullish) + ", t1=" + IntegerToString(t1) + ", t=" + IntegerToString(t) +
               ", err1=" + IntegerToString(err1) + ") ***";
            Print(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp); }       tst_5b = tst_5;
            if (! tst_5) { tst_5c = Time[0];       ObjectSet(ArrowName, OBJPROP_WIDTH, 2); }       Sleep(100); }     t ++; }     tmf_Diff = false;    if (! tst_5) return true; }
#endif
      endbull = Bullish;      if (! t_tick) if (! OrderSelect(floor(Clot? Clot: ticket), SELECT_BY_TICKET) && ! OrderCloseTime())
            Print("** -> Ticket Select ERROR! (3) (cpt ",cpt,", typ ",Typ,") ",GetLastError(),", ticket ",ticket,", tr_Allow ",tr_Allow,", t_Night ",t_Night," ***");// }
//Alert("TEST ALLOWED! (4) " + tr_allow + " " + ticket + " " + Clot + " " + t_close + " " + Bullish);
      if (ticket > 7) { temp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) + " ** -> OrderSend " + ticket + " - Typ: " + Typ + " - " + OrderProfit() + " - " + OrderSwap() + " - Bull: " + Bullish + " - " +
            DoubleToStr(OrderOpenPrice(),Digits()) + " - " + DoubleToStr(OrderStopLoss(), Digits()) + " - " + DoubleToStr(SL, Digits()) + " **";      copy_file_(2, temp);       Print(temp); } }  //*/
   if (ticket_ != ticket) Print("** --> Ticket CHANGED! (",Typ,") ",ticket_," ",ticket," - ",Bullish," **");
#ifdef v_opfx_0
   if (GlobalVariableCheck(tck_vstr)) ticket_ = GlobalVariableGet(tck_vstr);           t_tick = (ticket_ > 7);
   if (nb_ticks && OrderSelect(ticket_, SELECT_BY_TICKET) && t_tick) if (OrderProfit() < 0.0) { nb_tcks_N ++;
      if (pr_val1 > 0.0) a_nb_tcksN ++; }             else { nb_ticks = 0;    nb_tcks_N = 0;       a_nb_tcksN = 0; }
   nb_ticks ++;      if (t_tick && OrderProfit() == 0.0) Alert("***** ATTENTION : OrderProfit() NON RENSEIGNE ! *****");
   bool t_Ntcks=(str=="-HKG" || str=="-CHN" || str=="-GLD");
   if (t_Ntcks && Hour() < 6 && nb_ticks > 2 && nb_ticks == nb_tcks_N + 1) 
      Print("** -> (1) nb_ticks > 2 && nb_ticks == nb_tcks_N + 1 : ",IntegerToString(nb_ticks)," ",IntegerToString(nb_tcks_N)," ",ticket," ",t_night," ",TimeToStr(Time[0],TIME_MINUTES)," **");
   if (Typ==2 || Typ==5) GlobalVariableSet(bull_str, Bullish);    GlobalVariableSet(tr_Allow || t_tick? tck_vstr: "Ticket0", ticket);     op_Liq_ = false;   cpt = 1;   trd_on = true;
   if (Typ == 7) { GlobalVariableSet(bull_str, Bullish);       bull_ = Bullish; }            no_OS5 = true;
#else
   GlobalVariableSet(bull_str, Bullish);           GlobalVariableSet(tr_allow ? tck_vstr : "Ticket0", ticket);
#endif
//int ticket = OrderSend(parts[10], (parts[11]=="SELL"?1:0), lot, (parts[11]=="SELL"?vBid:vAsk), 1, 0.0, 0.0, tmp2);
//   DrawArrow_OS(LinePrice, BarNum, Code, Bullish, Clot);  */
   return (t_night ? ticket > 0 : true);
}

int copy_file(string tmp, int item) { int handle, it=0;
//   string filename="EA-write-file_Orders.txt";
   MqlDateTime t;   TimeLocal(t);   bool tst=false;
   string filename=item==2? "Price_List.csv": item? "EA_List_Orders_"+stmfr+".log": StringFormat("%d%02d%02d-o.log",t.year,t.mon,t.day);
   while (! tst && it < 7) { if (!FileIsExist(filename)) handle = FileOpen (filename,item==2? FILE_TXT|FILE_WRITE|FILE_COMMON: FILE_TXT|FILE_WRITE);
      else   handle = FileOpen (filename,item==2? FILE_TXT|FILE_READ|FILE_WRITE|FILE_COMMON: FILE_TXT|FILE_READ|FILE_WRITE);
      if (handle != INVALID_HANDLE) {
         if (FileSize(handle)) FileSeek(handle, FileSize(handle), 0);
         tst = FileWrite(handle, TimeToStr(TimeCurrent(), TIME_MINUTES) + " " + tmp);
         if (! tst) Print ("Problème : FileWrite(handle, ("+it+" - "+IntegerToString(GetLastError())+") / "+Symbol()+" ***");
         else if (item) r_copyFtp = copy_FTP(); }
      else Print ("Problème : handle == INVALID_HANDLE. ("+it+" - "+IntegerToString(GetLastError())+") / "+Symbol()+" ***");
   FileClose(handle);   it ++; }
   return(handle);
}

bool copy_FTP() { return(true);     int res=-1, timeout=5000;        char post[], result[];
   string filename="EA_List_Orders_M5.log", URL="http://www.ekom.ovh/logs_ATS/concat_files.php", headers;
   if (SendFTP(filename, NULL)) { Print("**  copy_FTP(): File HAS BEEN copied!  **");
      res = WebRequest("GET", URL, NULL, NULL, timeout, post, 0, result, headers);
      if(res < 0) Print("*** Error in WebRequest. Error code = ", GetLastError(), " ***");
      else {
         PrintFormat("** The file has been successfully loaded, File size = %d bytes **", ArraySize(result));
         int filehandle = FileOpen("EA_List_Orders_All.log", FILE_WRITE|FILE_BIN|FILE_COMMON);
         if (filehandle != INVALID_HANDLE) {
            FileWriteArray (filehandle, result, 0, ArraySize(result));
            FileClose(filehandle); }
      else Print("*** Error in FileOpen. Error code=", GetLastError(), " ***"); } }
   else  Print("*** copy_FTP(): File NOT copied! - error: ", GetLastError(), " ***");
   return(res >= 0);
}

//void DrawArrow(double linePrice,datetime time,bool bullish){
const string PREFIX = "EA_Test";
void DrawArrow(double LinePrice,int BarNum,int Code,bool Bullish,bool Clot) {
   string ArrowName = PREFIX+"_Arr"+(Bullish?"-Up_":"-Down_")+IntegerToString(Code?Code:Bullish?233:234)+"-"+IntegerToString(BarNum)+"-"+IntegerToString(Clot);
   if (ea_show) { ObjectCreate(ArrowName,OBJ_ARROW,0,Time[BarNum],LinePrice);
      ObjectSet(ArrowName, OBJPROP_STYLE, STYLE_SOLID);
      ObjectSet(ArrowName, OBJPROP_ARROWCODE, Code? Code: Bullish? 233: 234);
      ObjectSet(ArrowName, OBJPROP_COLOR, Code==3? clrBlack: Clot? clrSkyBlue: Bullish? clrLimeGreen: clrDeepPink);
      ObjectSet(ArrowName, OBJPROP_SELECTABLE, 0);
      ObjectSet(ArrowName, OBJPROP_SELECTED, 0);
      ObjectSet(ArrowName, OBJPROP_WIDTH, Code == 159? 1: 2); }
}
// DrawArrowUp("Arr_up",Low[barre]-50*Point,DeepSkyBlue);
// DrawArrowDn("Arr_dn",High[barre]+150*Point,DeepPink);

int nDrArrHAb=0, nDrArrHAb1=0, nDrArrHAs=0, nDrArrHAs1=0;   datetime tDrArrHAs, tDrArrHAb;
double dDrArrHAb_, dDrArrHAb, dDrArrHAb1, dDrArrHAs_, dDrArrHAs, dDrArrHAs1;
void DrawArrow_HA(double LinePrice,int BarNum,int Code,int Bullish) {
   string ArrowName = "H-A_Test_Arr"+(Bullish?"-Up_":"-Down_")+IntegerToString(Code)+"-"+LinePrice+" "+IntegerToString(Time[BarNum]);
//    v bien testé sur la journée du 19-07-2022
/*   dDrArrHA_ = dDrArrHA > 0.0? dDrArrHA: dDrArrHA1;         if (Bullish >= 0) dDrArrHA1 = LinePrice;
   if (fabs(dDrArrHA_ - dDrArrHA1) < 15 && nDrArrHA1 < 4) { nDrArrHA ++;
      if (nDrArrHA > 3) { if (nDrArrHA > 5 * PERIOD_M15 / Period()) if (dDrArrHA > Ask) { tDrArrHAs = TimeCurrent();
            dDrArrHAs = dDrArrHA; }          else { dDrArrHAb = dDrArrHA;        tDrArrHAb = TimeCurrent(); }
         if (! nDrArrHA1) dDrArrHA = dDrArrHA1;       if (dDrArrHA == dDrArrHA1) nDrArrHA1 = 0;    else nDrArrHA1 ++; } }
   if (fabs(dDrArrHA_ - dDrArrHA1) >= 15) { if (nDrArrHA < 4) nDrArrHA = 0;      else  nDrArrHA1 ++; }
   if (nDrArrHA1 > 4 || (tDrArrHAs && TimeCurrent()-tDrArrHAs > 900) || (tDrArrHAb && TimeCurrent()-tDrArrHAb > 900)) {
      nDrArrHA = 0;        nDrArrHA1 = 0;       dDrArrHA = 0.0;         dDrArrHA1 = 0.0;
      if (tDrArrHAs && TimeCurrent() - tDrArrHAs > 900) tDrArrHAs = 0;
      if (tDrArrHAb && TimeCurrent() - tDrArrHAb > 900) tDrArrHAb = 0; }
   if (tDrArrHAs && TimeCurrent() - tDrArrHAs > 3600) tDrArrHAs = 0;
   if (tDrArrHAb && TimeCurrent() - tDrArrHAb > 3600) tDrArrHAb = 0; */
   if (LinePrice > Bid) { dDrArrHAs_ = dDrArrHAs > 0.0? dDrArrHAs: dDrArrHAs1;   if (Bullish >= 0) dDrArrHAs1 = LinePrice;
      if (fabs(dDrArrHAs_ - dDrArrHAs1) < 15 && nDrArrHAs1 < 4) { nDrArrHAs ++;
         if (nDrArrHAs > 3) { if (nDrArrHAs > 5 * PERIOD_M15 / Period()) tDrArrHAs = TimeCurrent();
            if (! nDrArrHAs1) dDrArrHAs = dDrArrHAs1;       if (dDrArrHAs == dDrArrHAs1) nDrArrHAs1 = 0;    else nDrArrHAs1 ++; } }
      if (fabs(dDrArrHAs_ - dDrArrHAs1) >= 15) { if (nDrArrHAs < 4) nDrArrHAs = 0;      else  nDrArrHAs1 ++; }
      if (nDrArrHAs1 > 4 || (tDrArrHAs && TimeCurrent() - tDrArrHAs > 900)) {
         nDrArrHAs = 0;        nDrArrHAs1 = 0;       dDrArrHAs = 0.0;         dDrArrHAs1 = 0.0;
         if (tDrArrHAs && TimeCurrent() - tDrArrHAs > 900) tDrArrHAs = 0; } }
   else { dDrArrHAb_ = dDrArrHAb > 0.0? dDrArrHAb: dDrArrHAb1;         if (Bullish >= 0) dDrArrHAb1 = LinePrice;
      if (fabs(dDrArrHAb_ - dDrArrHAb1) < 15 && nDrArrHAb1 < 4) { nDrArrHAb ++;
         if (nDrArrHAb > 3) { if (nDrArrHAb > 5 * PERIOD_M15 / Period()) tDrArrHAb = TimeCurrent();
            if (! nDrArrHAb1) dDrArrHAb = dDrArrHAb1;       if (dDrArrHAb == dDrArrHAb1) nDrArrHAb1 = 0;    else nDrArrHAb1 ++; } }
      if (fabs(dDrArrHAb_ - dDrArrHAb1) >= 15) { if (nDrArrHAb < 4) nDrArrHAb = 0;      else  nDrArrHAb1 ++; }
      if (nDrArrHAb1 > 4 || (tDrArrHAb && TimeCurrent() - tDrArrHAb > 900)) {
         nDrArrHAb = 0;        nDrArrHAb1 = 0;       dDrArrHAb = 0.0;         dDrArrHAb1 = 0.0;
         if (tDrArrHAb && TimeCurrent() - tDrArrHAb > 900) tDrArrHAb = 0; } }
   if (tDrArrHAs && TimeCurrent() - tDrArrHAs > 3600) { tDrArrHAs = 0;     dDrArrHAs = 0.0; }
   if (tDrArrHAb && TimeCurrent() - tDrArrHAb > 3600) { tDrArrHAb = 0;     dDrArrHAb = 0.0; }
Alert("*****-s dDrArrHAs (* 3) " + DoubleToStr(dDrArrHAs_, Digits()) + " - " + DoubleToStr(dDrArrHAs1, Digits()) + " - " + DoubleToStr(dDrArrHAs, Digits()) + " - " +
   " - " + IntegerToString(nDrArrHAs) + " - " + IntegerToString(nDrArrHAs1) + " - " + TimeToStr(tDrArrHAs, TIME_MINUTES) + " *****");
Alert("*****-b dDrArrHAb (* 3) " + DoubleToStr(dDrArrHAb_, Digits()) + " - " + DoubleToStr(dDrArrHAb1, Digits()) + " - " + DoubleToStr(dDrArrHAb, Digits()) +
   " - " + IntegerToString(nDrArrHAb) + " - " + IntegerToString(nDrArrHAb1) + " - " + TimeToStr(tDrArrHAb, TIME_MINUTES) + " *****");
   ObjectCreate(ArrowName,OBJ_ARROW,0,Time[BarNum],LinePrice);
   ObjectSet(ArrowName, OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet(ArrowName, OBJPROP_ARROWCODE, Code);
   ObjectSet(ArrowName, OBJPROP_COLOR, Bullish? Bullish<0? clrGray: clrLime: clrDeepPink);
   ObjectSet(ArrowName, OBJPROP_SELECTABLE, 0);
   ObjectSet(ArrowName, OBJPROP_SELECTED, 0);
   ObjectSet(ArrowName, OBJPROP_WIDTH, Code == 159? 1: 2);
}

void CreateLabel(double LinePrice,int BarNum,int Pos,bool Bullish,string vText,int li,int Clot) {
   string LabelName = PREFIX+"_Label_"+IntegerToString(Bullish?233:234)+"-"+IntegerToString(Pos)+"-"+IntegerToString(BarNum)+"-"+IntegerToString(li+1)+"-"+IntegerToString(Clot);
   ObjectCreate(LabelName,OBJ_LABEL,0,0,0);     int vX, vY;
   ChartTimePriceToXY(0,0,Time[BarNum],LinePrice,vX,vY);
   ObjectSet(LabelName,OBJPROP_XDISTANCE,vX+(Clot? 5: 0));
   ObjectSet(LabelName,OBJPROP_YDISTANCE,vY+17*li-(Clot? 3: 0));
   ObjectSet(LabelName,OBJPROP_CORNER,CORNER_LEFT_UPPER);
   ObjectSet(LabelName,OBJPROP_ANCHOR,Clot? ANCHOR_LEFT: Bullish?ANCHOR_LEFT_LOWER:ANCHOR_LEFT);
   ObjectSetString(0,LabelName,OBJPROP_TEXT,vText);
   ObjectSet(LabelName,OBJPROP_FONTSIZE,12);
   ObjectSet(LabelName,OBJPROP_COLOR,#ifdef v_opfx Pos>=0?#endif  Clot? Clot==1? clrViolet: clrGold: Bullish? clrLimeGreen: clrDeepPink#ifdef v_opfx: clrOrangeRed#endif);
   ObjectSet(LabelName,OBJPROP_SELECTABLE, true);     // clrAqua
   ObjectSet(LabelName,OBJPROP_SELECTED, false);
   ObjectSet(LabelName,OBJPROP_HIDDEN, true);
}
#ifdef v_opfx_0

void CreateObText(int Item,double LinePrice,int BarNum,bool Bullish,string vText) {
   double vScale=(WindowPriceMax()-WindowPriceMin())/(!WindowPriceMax()?1.154:WindowPriceMax())/1.154/(1.154-1.061);
   string LabelName = PREFIX+(Item? "_v-TmFr_": "_Label_")+IntegerToString(Bullish?233:234)+"-"+IntegerToString(BarNum)+" "+IntegerToString(TimeCurrent());
   if (Item) { ObjectCreate(LabelName,OBJ_LABEL, 0, 0, 0);
      int vX, vY;          ChartTimePriceToXY(0,0,Time[BarNum],LinePrice, vX, vY);
      ObjectSet(LabelName,OBJPROP_XDISTANCE, vX + (ChartGetInteger(0, CHART_SCALE)==3? 11: 8));
      ObjectSet(LabelName,OBJPROP_YDISTANCE, vY + (ChartGetInteger(0, CHART_SCALE)==3? 11: 3)); }
   else  ObjectCreate(LabelName,OBJ_TEXT,0,Time[BarNum],LinePrice+(Bullish?500:-500)*vScale*Point);
   ObjectSet(LabelName,OBJPROP_ANCHOR,Bullish?ANCHOR_LEFT_LOWER:ANCHOR_LEFT_UPPER);
   ObjectSetString(0,LabelName,OBJPROP_TEXT, Item && ChartGetInteger(0, CHART_SCALE)==3 ? "-" : vText);
   ObjectSet(LabelName,OBJPROP_FONTSIZE, Item? Item==PERIOD_M5 || Item < 0? (ChartGetInteger(0, CHART_SCALE)==3? 15: 14): 16: 12);
   ObjectSet(LabelName,OBJPROP_COLOR, Item? Item==PERIOD_M5? clrLightSeaGreen: Item==PERIOD_M15? clrGreen: Item < 0? clrDarkGray: clrBlue: Bullish? clrLimeGreen: clrDeepPink);
   ObjectSet(LabelName,OBJPROP_SELECTABLE, true);     // clrAqua
   ObjectSet(LabelName,OBJPROP_SELECTED, false);
   ObjectSet(LabelName,OBJPROP_HIDDEN, true);
}
#endif

void CreateLabel0(double LinePrice,int BarNum,string vText,int Item,int mX,int mY) {
   string LabelName = PREFIX+"_Label_"+StringSubstr(vText,0,7)+" "+IntegerToString(BarNum)+"-"+IntegerToString(mX)+"-"+IntegerToString(mY);
   ObjectCreate(LabelName,OBJ_LABEL,0,0,0);           int vX, vY;
   if (BarNum && LinePrice) ChartTimePriceToXY(0,0,Time[BarNum],LinePrice,vX,vY);
   ObjectSet(LabelName,OBJPROP_XDISTANCE,mX? mX: vX);
   ObjectSet(LabelName,OBJPROP_YDISTANCE,mY? mY: vY);
   ObjectSet(LabelName,OBJPROP_CORNER,CORNER_LEFT_UPPER);
   ObjectSet(LabelName,OBJPROP_ANCHOR,ANCHOR_LEFT);
   ObjectSetString(0,LabelName,OBJPROP_TEXT,vText);
   ObjectSet(LabelName,OBJPROP_FONTSIZE,Item? 10: 13);
   ObjectSet(LabelName,OBJPROP_COLOR, !BarNum? clrAqua: !Item? clrYellow: Item==1? clrOrange: clrViolet);
   ObjectSet(LabelName,OBJPROP_SELECTABLE, true);
   ObjectSet(LabelName,OBJPROP_SELECTED, false);
   ObjectSet(LabelName,OBJPROP_HIDDEN, true);
}

void DrawArrowInt(double LinePrice,int BarNum,int Code,bool Bullish) {
   string ArrowName = PREFIX+"_Arr"+(Bullish?"-In_":"-Out_")+IntegerToString(Code?Code:Bullish?233:234)+"-"+IntegerToString(BarNum);
   ObjectCreate(ArrowName,OBJ_ARROW,0,Time[BarNum],LinePrice);
   ObjectSet(ArrowName, OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet(ArrowName, OBJPROP_ARROWCODE, Code?Code:Bullish?233:234);
   ObjectSet(ArrowName, OBJPROP_COLOR, Bullish? clrOrange: clrViolet);
   ObjectSet(ArrowName, OBJPROP_SELECTABLE, true);
   ObjectSet(ArrowName, OBJPROP_SELECTED, false);
   ObjectSet(ArrowName, OBJPROP_WIDTH, 2);
}

void Label_Arrow_Test(int Type,int Pos,int P,int I,int K,double IClose,bool Bull,int mX,int mY,double Total,int &T1[],int &T2[]) {
   CreateLabel0(iClose(NULL,0,Bars-I+1),Bars-I+1,"- "+(Type==1?"reOps":"reCls")+" - "+IntegerToString(Pos)+" - "+
         DoubleToStr(iOpen(NULL,0,Bars-I+1),5)+" - "+DoubleToStr(iHigh(NULL,0,Bars-I+1),5)+" - "+DoubleToStr(iLow(NULL,0,Bars-I+1),5)+" - "+
         DoubleToStr(iClose(NULL,0,Bars-I+1),5)+" - "+IntegerToString(K)+" - "+DoubleToStr((Bull ? 1 : -1) * 
         (iClose(NULL,0,Bars-I+1)-iOpen(NULL,0,Bars-I+1)) / (iHigh(NULL,0,Bars-I+1)-iLow(NULL,0,Bars-I+1)), 2)+" *",Type,mX,mY); //Bull?1:2

   CreateLabel0(iClose(NULL,0,Bars-I+1),Bars-I+1,"- "+(Type==1?"reOps":"reCls")+" fnd - "+IntegerToString(Pos)+"-"+
         IntegerToString(T1[P])+"-"+IntegerToString(T1[P+1])+"-"+IntegerToString(T2[P])+"-"+IntegerToString(T2[P+1])+" - "+
         DoubleToStr((Bull ? 1 : -1) * (IClose - iOpen(NULL,0,Bars-I+1)) / (iHigh(NULL,0,Bars-I+1)-iLow(NULL,0,Bars-I+1)),2)+" - "+
         DoubleToStr((Bull ? 1 : -1) * (IClose - iOpen(NULL,0,Bars-I+1)),5)+" - "+
         DoubleToStr((Bull ? 1 : -1) * (iOpen(NULL,0,Bars-I+1) - (iHigh(NULL,0,Bars-I+1)+iLow(NULL,0,Bars-I+1)) / 2),5)+" - "+
//         DoubleToStr((Bull ? 1 : -1) * (IClose - iOpen(NULL,0,Bars-I+1)) / (iHigh(NULL,0,Bars-I+1)-iLow(NULL,0,Bars-I+1)),2)+
         IntegerToString(Total)+" *",Type,mX,mY+17);   //Bull?1:2 -> Type

   DrawArrowInt(iClose(NULL,0,Bars-I+1), Bars-I+1, 3, Type==1? 1: 0);      DrawArrowInt(iClose(NULL,0,Bars-I+1), Bars-I+1, 5, Type==1? 1: 0); }

void CreateButton(double LinePrice,int BarNum,string vText,int Item,int mX,int mY,int Color) {
   string LabelName = PREFIX+"_Label_"+StringSubstr(vText,0,7);
   ObjectCreate(LabelName,OBJ_LABEL,0,0,0);           int vX, vY;
   if (BarNum && LinePrice) ChartTimePriceToXY(0,0,Time[BarNum],LinePrice,vX,vY);
   ObjectSet(LabelName,OBJPROP_XDISTANCE,mX? mX: vX);
   ObjectSet(LabelName,OBJPROP_YDISTANCE,mY? mY: vY);
   ObjectSet(LabelName,OBJPROP_CORNER,CORNER_LEFT_UPPER);
   ObjectSet(LabelName,OBJPROP_ANCHOR,ANCHOR_LEFT);
   ObjectSetString(0,LabelName,OBJPROP_TEXT,vText);
   ObjectSet(LabelName,OBJPROP_FONTSIZE, Item? 10: 9);
   ObjectSet(LabelName,OBJPROP_COLOR, Color? Color==1 && Op_OHL? clrAqua: Color==2 && Op_Show? clrAqua: Color==3 && Op_DDw? 
      clrAqua: /*Color==4 && Op_DDw2? clrAqua: Color==5 && Op_DDw3? clrAqua: */Color==6 && Op_HiLo? clrAqua: clrSilver: clrSkyBlue);
   ObjectSet(LabelName,OBJPROP_SELECTABLE, true);
   ObjectSet(LabelName,OBJPROP_SELECTED, false);
   ObjectSet(LabelName,OBJPROP_HIDDEN, true);
}

void CreateLabel_end(double LinePrice,int BarNum,int Pos,bool Bullish,string vText,int Item,int Itm2) {
   string LabelName = PREFIX+"_end"+IntegerToString(Itm2)+"_Label_"+IntegerToString(Bullish?241:242)+"-"+IntegerToString(Pos)+"-"+IntegerToString(BarNum)+"-0-0";
   ObjectCreate(LabelName,OBJ_LABEL,0,0,0);                             if (!Itm2 && LabelNameEnd==NULL) LabelNameEnd = LabelName;
   ObjectSet(LabelName,OBJPROP_XDISTANCE,Item? 150: 10);                if (Itm2 && LabelNameEnd2==NULL) LabelNameEnd2 = LabelName;
   ObjectSet(LabelName,OBJPROP_YDISTANCE,(Pos? 30: 40) + Itm2 * 18);
   ObjectSet(LabelName,OBJPROP_CORNER,CORNER_RIGHT_UPPER);
   ObjectSet(LabelName,OBJPROP_ANCHOR,ANCHOR_RIGHT);
   ObjectSetString(0,LabelName,OBJPROP_TEXT,vText);
   ObjectSet(LabelName,OBJPROP_FONTSIZE,Item || Itm2? 10: 12);
   ObjectSet(LabelName,OBJPROP_COLOR, Item?clrSilver:clrGold);
   ObjectSet(LabelName,OBJPROP_SELECTABLE, true);
   ObjectSet(LabelName,OBJPROP_SELECTED, false);
   ObjectSet(LabelName,OBJPROP_HIDDEN, true);
}

/* void ObjectsDelete(int P) {
   int obj_total=ObjectsTotal(), i=0, j=0;
   string name;   for (int pos=0; pos < obj_total; pos ++) {
     name = ObjectName(pos);                          // v OnDeinit(..reason=3), timeframe changé manuellement
     if (pos && (StringSubstr(name,0,8)=="EA_Test_" || StringSubstr(name,0,6) == "EA_pf_" ||
     (P==2 && StringSubstr(name,0,8)!="EA_Check"))) {
         j ++;       if (ObjectDelete(name)) { i ++;  pos --; } } }
   if (P) Print("** ", pos, " objects, DELETED: ", i, " / ", j, " / ", obj_total, " **");
   return; } //*/

void ObjectsPositions(double vScale) {                                             //,tmfr=Period()
#ifdef v_opfx_0
   string str="-"+StringSubstr(EnumToString(magic_nb), 0, 3);
#endif
   if (Minute() < 2) { stmp = "*** (1) " + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) + " - " + DoubleToStr(vScale, 2)  + " - " + DoubleToStr(WindowPriceMax(), Digits()) + " - " +
      DoubleToStr(WindowPriceMin(), Digits()) + " ***";           copy_file(stmp, 0); }
   int j=0,bar=WindowFirstVisibleBar(),obj_total=ObjectsTotal(),bars=WindowBarsPerChart();       while(! Time[bar-bars+j]) j ++;
   string name/*, stmfr= tmfr==PERIOD_M1? "M1": tmfr==PERIOD_M5? "M5": tmfr==PERIOD_M15? "M15": tmfr==PERIOD_M30? "M30": 
      tmfr==PERIOD_H1? "H1": tmfr==PERIOD_H4? "H4": tmfr==PERIOD_D1? "D1": tmfr==PERIOD_W1? "W1": "MN1" */;
//   Print("** ---> ", WM, " ", WindowPriceMax(), " ", tmfr, " ", stmfr, " ", j, " ", bar, " ", bars, " ", TimeToStr(Time[bar],TIME_MINUTES), " ", TimeToStr(Time[bar-bars+j],TIME_MINUTES), " **");
   datetime OTime;      WM = WindowPriceMax();     for (int pos=0; pos < obj_total; pos ++) {
     name = ObjectName(pos);    OTime = ObjectGet(name,OBJPROP_TIME1);
/*     if (pos && (StringSubstr(name,0,8) == "EA_Check" || StringSubstr(name,0,8) == "EA_Test1" ||
        StringSubstr(name,0,8) == "EA_Test2") && Time[bar] <= OTime && Time[bar-bars+j] >= OTime)
   Print("** --> ",name," ",TimeToStr(OTime,TIME_MINUTES)," ",ObjectGet(name,OBJPROP_PRICE)," ",TimeToStr(ObjectGet(name,OBJPROP_TIME1),TIME_MINUTES)," ",ObjectGet(name,OBJPROP_PRICE1)," **");//*/
     if (pos && (StringSubstr(name,0,8) == "EA_Check" || StringSubstr(name,0,8) == "EA_Test1" || StringSubstr(name,0,8) == "EA_Test2")) //{
//   Print("**(1) -> ", name, " ", TimeToStr(OTime,TIME_MINUTES), " OBJPROP_COLOR: ", ColorToString(ObjectGet(name,OBJPROP_COLOR)), " **");
      if (Time[bar] <= OTime && Time[bar-bars+j]+Period()*60 >= OTime) {
         if (StringSubstr(name,9,StringFind(name,"-",StringFind(name,"-")+1)-9) != stmfr) {   // && stmfr!="M1"
            ObjectSet(name,OBJPROP_BACK,true);       #ifndef v_opfx_0 ObjectSet(name,OBJPROP_PRICE1, WM + 1500 * vScale * Point);
#else          ObjectSet(name,OBJPROP_PRICE1, WM + 15 * vScale * Point);         ObjectSet(name,OBJPROP_WIDTH, 1);
#endif            if (ObjectGet(name,OBJPROP_COLOR) && ObjectGet(name,OBJPROP_COLOR) != clrDarkOrchid) {
                     ObjectSet(name,OBJPROP_ZORDER,ObjectGet(name,OBJPROP_COLOR));           ObjectSet(name,OBJPROP_COLOR,clrDarkOrchid); }
/*   Print("**(2a) -> ", name, " ", TimeToStr(OTime,TIME_MINUTES), " OBJPROP_COLOR: ", ColorToString(ObjectGet(name,OBJPROP_COLOR)), " OBJPROP_ZORDER: ", ObjectGet(name,OBJPROP_ZORDER), 
         " OBJPROP_PRICE1: ", ObjectGet(name,OBJPROP_PRICE1), " OBJPROP_BACK: ", ObjectGet(name,OBJPROP_BACK), " **");*/ }
         else {#ifdef v_opfx_0 string tmp=StringSubstr(name,StringSubstr(name,0,7) == "EA_Test"? 7: (StringSubstr(name,8,1)=="-"? StringFind(name,"-",StringFind(name,"-")+1)+1: 8), 1);
           #endif ObjectSet(name,OBJPROP_BACK,false);      ObjectSet(name,OBJPROP_PRICE1, WM -#ifdef v_opfx_0 (tmp=="1"||tmp=="5"? 50+(tmp=="5"? str=="-EUS"?120:80: 0)#else 50#endif: 310)*vScale*Point);
#ifdef v_opfx_0
            if (StringSubstr(name, StringFind(name, "_") - 1, 1) != "5") ObjectSet(name,OBJPROP_WIDTH, 2);
#endif
            if (ObjectGet(name,OBJPROP_ZORDER) > 0) { ObjectSet(name,OBJPROP_COLOR,ObjectGet(name,OBJPROP_ZORDER));        ObjectSet(name,OBJPROP_ZORDER,0); }
/*   Print("**(2b) -> ", name, " ", TimeToStr(OTime,TIME_MINUTES), " OBJPROP_COLOR: ", ColorToString(ObjectGet(name,OBJPROP_COLOR)), " OBJPROP_ZORDER: ", ObjectGet(name,OBJPROP_ZORDER), 
         " OBJPROP_PRICE1: ", ObjectGet(name,OBJPROP_PRICE1), " OBJPROP_BACK: ", ObjectGet(name,OBJPROP_BACK), " **");*/ }
/*   Print("** -> ", name, " ", OTime, " ", ObjectGet(name,OBJPROP_PRICE1), " ", WM, " **");*/ } } //}
   return; }

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

void DrawArrow_pf(double LinePrice,int BarNum,int Code,bool Bullish,bool Clot) {
   string ArrowName = (Code==2||Code==6? "EA": PREFIX)+"_pf_Arr"+(Bullish?"-Up_":"-Down_")+IntegerToString(Code?Code:Bullish?241:242)+"-"+
      IntegerToString(BarNum)+"-"+IntegerToString(Clot)+(Code==2||Code==6? " "+IntegerToString(TimeCurrent()): "");
   ObjectCreate(ArrowName,OBJ_ARROW,0,Time[BarNum],LinePrice);
   ObjectSet(ArrowName, OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet(ArrowName, OBJPROP_ARROWCODE, Code? Code: Bullish? 241: 242);
   ObjectSet(ArrowName, OBJPROP_COLOR, Code==3? clrBlack: Clot? clrSkyBlue: Bullish? clrLimeGreen: clrDeepPink);
   ObjectSet(ArrowName, OBJPROP_SELECTABLE, 0);
   ObjectSet(ArrowName, OBJPROP_SELECTED, 0);
   ObjectSet(ArrowName, OBJPROP_WIDTH, 2);
}

bool DrawArrow_end(double LinePrice,int BarNum,int Code,bool Bullish,bool Clot) {
   string ArrowName = "EA_end_Arr"+((Bullish&&!Clot)||(!Bullish&&Clot)?"-Up_":"-Down_")+IntegerToString(Code?Code:Bullish?241:242)+"-"+
      IntegerToString(BarNum)+"-"+IntegerToString(Clot)+" "+IntegerToString(TimeCurrent());
   if (! ObjectCreate(ArrowName,OBJ_ARROW,0,Time[BarNum],LinePrice)) return false;
   ObjectSet(ArrowName, OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet(ArrowName, OBJPROP_ARROWCODE, Code?Code:Bullish?241:242);
   ObjectSet(ArrowName, OBJPROP_COLOR, Code==3? clrBlack: Clot? clrSkyBlue: Bullish? clrLimeGreen: clrDeepPink);
   ObjectSet(ArrowName, OBJPROP_SELECTABLE, 0);
   ObjectSet(ArrowName, OBJPROP_SELECTED, 0);
   ObjectSet(ArrowName, OBJPROP_WIDTH, 2);
   return true;
}

void CreateLabel_pf(double LinePrice,int BarNum,int Pos,bool Bullish,string vText,int li,int Clot) {
   string LabelName = PREFIX+"_pf_Label_"+IntegerToString(Bullish?241:242)+"-"+IntegerToString(Pos)+"-"+IntegerToString(BarNum)+"-"+IntegerToString(li+1)+"-"+IntegerToString(Clot);
   ObjectCreate(LabelName,OBJ_LABEL,0,0,0);     int vX, vY;
   ChartTimePriceToXY(0,0,Time[BarNum],LinePrice,vX,vY);
   ObjectSet(LabelName,OBJPROP_XDISTANCE,vX+(Clot? 5: 0));
   ObjectSet(LabelName,OBJPROP_YDISTANCE,vY+17*li-(Clot? 3: 0));
   ObjectSet(LabelName,OBJPROP_CORNER,CORNER_LEFT_UPPER);
   ObjectSet(LabelName,OBJPROP_ANCHOR,Clot? ANCHOR_LEFT: Bullish?ANCHOR_LEFT_LOWER:ANCHOR_LEFT);
   ObjectSetString(0,LabelName,OBJPROP_TEXT,vText);
   ObjectSet(LabelName,OBJPROP_FONTSIZE,12);
   ObjectSet(LabelName,OBJPROP_COLOR, Clot? Clot==1? clrViolet: clrGold: Bullish? clrLimeGreen: clrDeepPink);
   ObjectSet(LabelName,OBJPROP_SELECTABLE, true);     // clrAqua
   ObjectSet(LabelName,OBJPROP_SELECTED, false);
   ObjectSet(LabelName,OBJPROP_HIDDEN, true);
}

void CreateLabel0_pf(double LinePrice,int BarNum,string vText,int Item,int mX,int mY) {
   string LabelName = PREFIX+"_pf_Label_"+StringSubstr(vText,0,7)+" "+IntegerToString(BarNum)+"-"+IntegerToString(mX)+"-"+IntegerToString(mY);
   ObjectCreate(LabelName,OBJ_LABEL,0,0,0);           int vX, vY;
   if (BarNum && LinePrice) ChartTimePriceToXY(0,0,Time[BarNum],LinePrice,vX,vY);
   ObjectSet(LabelName,OBJPROP_XDISTANCE,mX? mX: vX);
   ObjectSet(LabelName,OBJPROP_YDISTANCE,mY? mY: vY);
   ObjectSet(LabelName,OBJPROP_CORNER,CORNER_LEFT_UPPER);
   ObjectSet(LabelName,OBJPROP_ANCHOR,ANCHOR_LEFT);
   ObjectSetString(0,LabelName,OBJPROP_TEXT,vText);
   ObjectSet(LabelName,OBJPROP_FONTSIZE,Item? 10: 13);
   ObjectSet(LabelName,OBJPROP_COLOR, !BarNum? clrAqua: !Item? clrYellow: Item==1? clrOrange: clrViolet);
   ObjectSet(LabelName,OBJPROP_SELECTABLE, true);
   ObjectSet(LabelName,OBJPROP_SELECTED, false);
   ObjectSet(LabelName,OBJPROP_HIDDEN, true);
}

void DrawArrowInt_pf(double LinePrice,int BarNum,int Code,bool Bullish) {
   string ArrowName = "EA_pf_Arr"+(Bullish?"-In_":"-Out_")+IntegerToString(Code?Code:Bullish?241:242)+"-"+IntegerToString(BarNum)+" "+IntegerToString(TimeCurrent());
   ObjectCreate(ArrowName,OBJ_ARROW,0,Time[BarNum],LinePrice);
   ObjectSet(ArrowName, OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet(ArrowName, OBJPROP_ARROWCODE, Code?Code:Bullish?241:242);
   ObjectSet(ArrowName, OBJPROP_COLOR, Bullish? clrOrange: clrViolet);
   ObjectSet(ArrowName, OBJPROP_SELECTABLE, 0);
   ObjectSet(ArrowName, OBJPROP_SELECTED, 0);
   ObjectSet(ArrowName, OBJPROP_WIDTH, 2);
}

void Label_Arrow_Test_pf(int Type,int Pos,int P,int I,int K,double IClose,bool Bull,int mX,int mY,double Total,int &T1[],int &T2[]) {
   CreateLabel0_pf(iClose(NULL,0,Bars-I+1),Bars-I+1,"- "+(Type==1?"reOps":"reCls")+" - "+IntegerToString(Pos)+" - "+
         DoubleToStr(iOpen(NULL,0,Bars-I+1),5)+" - "+DoubleToStr(iHigh(NULL,0,Bars-I+1),5)+" - "+DoubleToStr(iLow(NULL,0,Bars-I+1),5)+" - "+
         DoubleToStr(iClose(NULL,0,Bars-I+1),5)+" - "+IntegerToString(K)+" - "+DoubleToStr((Bull ? 1 : -1) * 
         (iClose(NULL,0,Bars-I+1)-iOpen(NULL,0,Bars-I+1)) / (iHigh(NULL,0,Bars-I+1)-iLow(NULL,0,Bars-I+1)), 2)+" *",Type,mX,mY); //Bull?1:2

   CreateLabel0_pf(iClose(NULL,0,Bars-I+1),Bars-I+1,"- "+(Type==1?"reOps":"reCls")+" fnd - "+IntegerToString(Pos)+"-"+
         IntegerToString(T1[P])+"-"+IntegerToString(T1[P+1])+"-"+IntegerToString(T2[P])+"-"+IntegerToString(T2[P+1])+" - "+
         DoubleToStr((Bull ? 1 : -1) * (IClose - iOpen(NULL,0,Bars-I+1)) / (iHigh(NULL,0,Bars-I+1)-iLow(NULL,0,Bars-I+1)),2)+" - "+
         DoubleToStr((Bull ? 1 : -1) * (IClose - iOpen(NULL,0,Bars-I+1)),5)+" - "+
         DoubleToStr((Bull ? 1 : -1) * (iOpen(NULL,0,Bars-I+1) - (iHigh(NULL,0,Bars-I+1)+iLow(NULL,0,Bars-I+1)) / 2),5)+" - "+
//         DoubleToStr((Bull ? 1 : -1) * (IClose - iOpen(NULL,0,Bars-I+1)) / (iHigh(NULL,0,Bars-I+1)-iLow(NULL,0,Bars-I+1)),2)+
         IntegerToString(Total)+" *",Type,mX,mY+17);   //Bull?1:2 -> Type

   DrawArrowInt_pf(iClose(NULL,0,Bars-I+1), Bars-I+1, 3, Type==1? 1: 0);      DrawArrowInt(iClose(NULL,0,Bars-I+1), Bars-I+1, 5, Type==1? 1: 0); }

bool DrawArrow_chst(double LinePrice,int BarNum,int I) { //int tmfr=Period();
   string/* stmfr= tmfr==PERIOD_M1? "M1": tmfr==PERIOD_M5? "M5": tmfr==PERIOD_M15? "M15": tmfr==PERIOD_M30? "M30": 
      tmfr==PERIOD_H1? "H1": tmfr==PERIOD_H4? "H4": tmfr==PERIOD_D1? "D1": tmfr==PERIOD_W1? "W1": "MN1", */
      ArrowName="EA_Chck2-"+stmfr+"-"+IntegerToString(I)+"_"+IntegerToString(BarNum)+" "+IntegerToString(Time[BarNum]);
   if (! ObjectCreate(ArrowName,OBJ_ARROW,0,Time[BarNum],LinePrice)) {
//      Print("*** ObjectCreate Error : "+IntegerToHexString(GetLastError())+" / "+DoubleToStr(LinePrice,5)+" - "+IntegerToHexString(BarNum)+" ***");
      return false; }
   if (I) LabelNameStp = ArrowName;
   ObjectSet(ArrowName, OBJPROP_STYLE, STYLE_SOLID);
#ifndef v_opfx_0
   ObjectSet(ArrowName, OBJPROP_ARROWCODE, I==3? 251: 252);
#else
   ObjectSet(ArrowName, OBJPROP_ARROWCODE, I==3? 251: I==4? fl_Trade? 252: 253: I==5? 187: 252); // I==4? 252 si FollowTrade activé
#endif
   ObjectSet(ArrowName, OBJPROP_COLOR, I==1||I>=4? I==1&& ticket>7? clrGold: clrSilver: clrSkyBlue);
   ObjectSet(ArrowName, OBJPROP_SELECTABLE, 0);
   ObjectSet(ArrowName, OBJPROP_SELECTED, 0);
   ObjectSet(ArrowName, OBJPROP_WIDTH, 2);
//   ObjectSet(ArrowName, OBJPROP_YDISTANCE, 55);
   return true;
}

void CreateLabel_st(double LinePrice,int BarNum,string vText,bool bullish,bool now) {
   string LabelName = "EA_Stop-Trade-"+IntegerToString(BarNum)+" "+IntegerToString(Time[BarNum]);
   ObjectCreate(LabelName,OBJ_TEXT, 0, Time[BarNum], LinePrice);
   LabelNameSt2 = LabelName;
   ObjectSet(LabelName,OBJPROP_ANCHOR,ANCHOR_LEFT);
   ObjectSetString(0,LabelName,OBJPROP_TEXT,vText);
   ObjectSet(LabelName,OBJPROP_FONTSIZE,9);
   ObjectSet(LabelName,OBJPROP_COLOR, now? clrPink: bullish? clrLightGreen: clrGold);
   ObjectSet(LabelName,OBJPROP_SELECTABLE, true);
   ObjectSet(LabelName,OBJPROP_SELECTED, false);
   ObjectSet(LabelName,OBJPROP_HIDDEN, true);
}

bool op_case0;
void ObjectsDelete(int P, string str#ifdef v_opfx_0, bool chk, bool old#endif) {
   int obj_total=ObjectsTotal(), i=0, j=0;
   string name;
   for (int pos=0;pos<obj_total;pos++) {
     name = ObjectName(pos);
#ifndef v_opfx_0
     if (pos && ((str!="" && StringSubstr(name,0,StringLen(str)+4)=="EA_"+str+"-") || (str=="" && (StringSubstr(name,0,8) == "EA_Test_" ||
         StringSubstr(name,0,9) == "H-A_Test_")))) {      // StringSubstr(name,0,6) == "EA_pf_" || <- option en plus à cause de op_case0 **
         j ++;   if (ObjectDelete(name)) { i ++;  pos --; } } }
#else
     if (pos && ((str!="" && (StringSubstr(name,0,StringLen(str)+4)=="EA_"+str+"-" || StringSubstr(name,0,StringLen(str)+4)=="H-A_"+str)) ||
     (str == "" && ((old && Period() >= PERIOD_M5 && (ObjectGet(name, OBJPROP_TIME2) > 0 ? ObjectGet(name, OBJPROP_TIME2) :
     ObjectGet(name, OBJPROP_TIME1)) < Time[H1 < H3? 500: 300]) || (chk && (StringSubstr(name,0,9)=="EA_Chck2-" || StringSubstr(name,0,9)=="EA_Chck3-")) || 
     (! chk && (StringSubstr(name,0,8) == "EA_Test_" || (op_case0 && StringSubstr(name,0,6) == "EA_pf_" && 
     ! iBarShift(NULL,0,fmax(ObjectGetInteger(0,name,OBJPROP_TIME1),ObjectGetInteger(0,name,OBJPROP_TIME)),false)) ||
     (P==2 && StringSubstr(name,0,8) != "EA_Check"))))))) { j ++;     if (ObjectDelete(name)) { i ++;  pos --; } } }
#endif
   if (P) Print (pos, " objects, DELETED: ", i, " / ", j, " / ", obj_total);
   return; }
#ifdef v_opfx_0

void copy_file_(int Item, string tmp) { //if ((Period() == PERIOD_M5 && ! (Seconds() % 20)) || (Period() > PERIOD_M5 && ! Seconds()) || Item != 4) {
   int handle, t=0;        ulong cmpl_size;        string temp="", str;       bool tst=false;         if (Item == 4) return;
   string filename=Item < 3? "EA-write-file_List-Trades("+IntegerToString(Item+1)+").txt" : Item == 3 ? "EA-write-file_List TF + HA.txt" : 
      Item == 4 ? "EA-write-file_Logs COMPLET.txt" : Item == 9 ? "Accélération_write-file_params.txt" : "EA-write-file_List v-TmFr.csv";
   if (!FileIsExist(filename)) handle = FileOpen (filename,FILE_TXT|FILE_WRITE);       // ^ attention "Item == 9 ?" pour "ind Accélération ++.mqh"
   else   handle = FileOpen (filename,FILE_TXT|FILE_READ|FILE_WRITE);
   if (handle != INVALID_HANDLE) {
      if ((cmpl_size=FileSize(handle))>0) FileSeek(handle, FileSize(handle), 0);
      if (Item == 4 && (Hour() == 11 || Hour() == 23) && cmpl_size > 80000000 && tmp_savd2 > 0 && TimeCurrent() - tmp_savd2 > 150) {
         while(! tst && t < 5000) { FileSeek(handle, -10240, SEEK_CUR);             FileReadString(handle);
            str = FileReadString(handle);             str = StringSubstr(str, 11, 2);           t ++;
            tst = (StrToInteger(str) >= 9 && StrToInteger(str) < 11) || (StrToInteger(str) >= 21 && StrToInteger(str) < 23); }
         if (! tst) { FileClose(handle);              return; }
         while(! FileIsEnding(handle)) temp += (temp != "" ? "\r\n" : "") + FileReadString(handle);
         temp += "\r\n - - - - - - -";           FileClose(handle);          FileDelete(filename, 0);
         Sleep(100);          handle = FileOpen (filename, FILE_TXT|FILE_WRITE);
         FileWrite(handle, temp); }       FileWrite(handle, tmp); }
   else Print ("*** Problème : handle == INVALID_HANDLE. (2) / "+Symbol()+" / "+GetLastError()+" ***");
   FileClose(handle); } //}
#ifdef v_dump_1

void copy_file_45(int Item, string tmp) { if (Item == 4) f_tmp4 += (f_tmp4 != "" ? "\r\n" : "") + tmp;
   else if (Item == 5) f_tmp5 += (f_tmp5 != "" ? "\r\n" : "") + tmp;             else if (Item == -1) {
      copy_file_(4, f_tmp4);     Sleep(100);    if (f_tmp5 != "") copy_file_(5, f_tmp5);     f_tmp4 = "";   f_tmp5 = ""; } }
#endif

int copy_time(string str) { int handle;
   string filename="EA_Time_Synchro.txt";
   handle = FileOpen (filename,FILE_TXT|FILE_WRITE);
   if (handle != INVALID_HANDLE) {
       FileWrite(handle, str==""? (s_coptime=TimeToStr(TimeCurrent())+":"+IntegerToString(Seconds())): str); }
//   else Print ("Problème : handle == INVALID_HANDLE. (2) / "+vSymbol+" ***");
   FileClose(handle);
   return(handle); }

void DrawArrow_OS_(int Mode, string temp) {
/*  switch(Mode) {
      case 0 : 
temp = "** -> DrawArrow_OS ATS "+(obj_bars[prv_pos] >= Bars-1)+" "+bull+" "+Bid+" "+Ask+" "+prv_pos+" "+
      obj_bars[prv_pos]+" "+(Bars-obj_bars[prv_pos])+" "+TimeToStr(Time[Bars-obj_bars[prv_pos]],TIME_MINUTES)+" | "+pos+" "+iClose(NULL,0,Bars-i+1)+" "+vScale+" **");
      case 1 :
temp = "** -> DrawArrow_OS *1 "+bull+" "+t_clo+" "+Bid+" "+Ask+" "+i+" "+j+" "+Bars+" "+(Bars-i)+" "+
               TimeToStr(Time[Bars-i],TIME_MINUTES)+" | "+pos+" "+obj_prClots[pos]+" "+vScale+" **";
      case 2 :
temp = "** -> DrawArrow_OS *2 "+bull+" "+Bid+" "+Ask+" "+p+" "+obj_pos[p-1]+" "+
               obj_bars[obj_pos[p-1]]+" | "+pos+" "+obj_Prices[pos]+" "+vScale+" **";
      case 3 :
temp = "** -> DrawArrow_OS *3 "+bull+" "+t_clo+" "+Bid+" "+Ask+" "+i+" "+Bars+" "+(Bars-i+1)+" "+
               TimeToStr(Time[Bars-i+1],TIME_MINUTES)+" | "+pos+" "+obj_prClots[pos]+" "+vScale+" **";
      case 4 :
temp = "** -> DrawArrow_OS *4 "+bull+" "+t_clo+" "+Bid+" "+Ask+" "+i+" "+Bars+" "+(Bars-i+1)+" "+
                  TimeToStr(Time[Bars-i+1],TIME_MINUTES)+" | "+pos+" "+obj_prClots[pos]+" "+vScale+" **";
      case 5 :
temp = "** -> DrawArrow_OS *5 "+(obj_bars[prv_pos] >= Bars-1)+" "+bull+" "+Bid+" "+Ask+" "+prv_pos+" "+
      obj_bars[prv_pos]+" "+(Bars-obj_bars[prv_pos])+" "+TimeToStr(Time[Bars-obj_bars[prv_pos]],TIME_MINUTES)+" | "+pos+" "+iClose(NULL,0,Bars-i+1)+" "+vScale+" **";
      }*/
copy_file_(1, TimeToStr(TimeCurrent())+":"+IntegerToString(Seconds())+"."+IntegerToString(getCurrentMs()%1000)+" "+temp); }

uint prevSecondTick=0;
uint getCurrentMs() {
    return(GetTickCount() - prevSecondTick); }

bool DCC_Check() { // Dark Cloud Cover
      int i=0;    double tmpOpClo, tmpClose, midOpClo;      str_DCC = "";
      tmpOpClo = (fabs(iOpen(NULL,0,i+4) - iClose(NULL,0,i+4)) + fabs(iOpen(NULL,0,i+2) -
         iClose(NULL,0,i+2)) + fabs(iOpen(NULL,0,i+3) - iClose(NULL,0,i+3))) / 3.0;
      tmpClose = (fmax(iOpen(NULL,0,i+4), iClose(NULL,0,i+4)) + fmax(iOpen(NULL,0,i+2), 
         iClose(NULL,0,i+2)) + fmax(iOpen(NULL,0,i+3), iClose(NULL,0,i+3))) / 3.0;
      midOpClo = (iOpen(NULL,0,i+1) + iClose(NULL,0,i+1)) * 0.5;

      if (Open[i+1] < Close[i+1] && //Open[i+1] < Close[i] &&
         Open[i] > (High[i+1] - (Close[i+1] - Open[i+1]) / 7.0) &&
         Close[i] < (Open[i+1] + (Close[i+1] - Open[i+1]) / 3.0) &&
         fabs(iOpen(NULL,0,i+1) - iClose(NULL,0,i+1)) > tmpOpClo * 1.75 &&
         midOpClo > tmpClose) {      //  && i == 114     (^ attention ,Bars-i+1) dans d'autres codes)
//Print("** Dark Cloud Cover: ",TimeToStr(Time[i],TIME_DATE|TIME_MINUTES)," - "+DoubleToStr(tmpOpClo, 5)+" "+DoubleToStr(fabs(iOpen(NULL,0,i+1) - iClose(NULL,0,i+1)), 5)+" **");

         ObjectCreate("Dark Cloud Cover "+DoubleToStr(i,0),OBJ_ARROW,0,Time[i],High[i]+25*Point);
         ObjectSet("Dark Cloud Cover "+DoubleToStr(i,0),OBJPROP_ARROWCODE,234);
         ObjectSet("Dark Cloud Cover "+DoubleToStr(i,0),OBJPROP_COLOR,Yellow);
         ObjectSet("Dark Cloud Cover "+DoubleToStr(i,0),OBJPROP_WIDTH,1);
         str_DCC = "Dark Cloud Cover";    return(true); }

      tmpClose = (fmin(iOpen(NULL,0,i+4), iClose(NULL,0,i+4)) + fmin(iOpen(NULL,0,i+2), 
         iClose(NULL,0,i+2)) + fmin(iOpen(NULL,0,i+3), iClose(NULL,0,i+3))) / 3.0;

      if (Open[i+1] > Close[i+1] && //Open[i+1] > Close[i] &&
         Open[i] < (Low[i+1] + (Close[i+1] - Open[i+1]) / 7.0) &&
         Close[i] > (Open[i+1] - (Close[i+1] - Open[i+1]) / 3.0) &&
         fabs(iOpen(NULL,0,i+1) - iClose(NULL,0,i+1)) > tmpOpClo * 1.75 &&
         midOpClo < tmpClose) {      //  && i == 114
//Print("** Piercing Line: ",TimeToStr(Time[i],TIME_DATE|TIME_MINUTES)," - "+DoubleToStr(tmpOpClo, 5)+" "+DoubleToStr(fabs(iOpen(NULL,0,i+1) - iClose(NULL,0,i+1)), 5)+" **");

         ObjectCreate("Piercing Line "+DoubleToStr(i,0),OBJ_ARROW,0,Time[i],High[i]-55*Point);
         ObjectSet("Piercing Line "+DoubleToStr(i,0),OBJPROP_ARROWCODE,233);
         ObjectSet("Piercing Line "+DoubleToStr(i,0),OBJPROP_COLOR,Pink);
         ObjectSet("Piercing Line "+DoubleToStr(i,0),OBJPROP_WIDTH,1);
         str_DCC = "Piercing Line";       return(true); }

   return(false); }

int mOrdersTotal(int mag_nb) { int total=OrdersTotal(), mtotal=0;
  if (! mag_nb || ! magic_on) return(total);

  for (int pos=0; pos < total; pos ++) {
     if (! OrderSelect(pos, SELECT_BY_POS)) continue;
     if (OrderMagicNumber() == mag_nb || (OrderSymbol() == Symbol() && Symbol() != "EURUSDp")) mtotal ++; }
  return(mtotal); }

bool mOrderSelect(int Pos, bool notused) {
  if (! magic_nb || ! magic_on) return(OrderSelect(Pos, SELECT_BY_POS));
  int total=OrdersTotal();    bool tst=false;

  for (int pos=0; pos < total && ! tst; pos ++) {
     if (! OrderSelect(pos, SELECT_BY_POS)) continue;
     if (OrderMagicNumber() == magic_nb || (OrderSymbol() == Symbol() && Symbol() != "EURUSDp")) { tst = true;    break; } }
  return(tst); }

long chart_find() { // recherche le chart de même symbole et autre période
   long currChart, thisChart=0, prevChart=ChartFirst(), this_ID=ChartID();
   int i=0, limit=25, thisTmfr;    // = ChartPeriod(prevChart);
//   sym_target = EnumToString(Symbol_Target);       //per_target = PERIOD_H1;                // chart cible pour le multi timeframe **
//   per_target = !Period_Target? PERIOD_M1: Period_Target==1? PERIOD_M5: Period_Target==2? PERIOD_M15: Period_Target==3? PERIOD_M30: 
//      Period_Target==4? PERIOD_H1: Period_Target==5? PERIOD_H4: Period_Target==6? PERIOD_D1: Period_Target==7? PERIOD_W1: PERIOD_MN1;
   if (! Chart_M5) Chart_M5 = GlobalVariableGet(Chart_str);
   tmfr_ = Period() == PERIOD_H1 || Period() == PERIOD_M30 ? Period() : tmfr_ ? tmfr_ : PERIOD_H1;
//   per_target = Period() == PERIOD_H1 || Period() == PERIOD_M30 || Period() == PERIOD_M1 ? PERIOD_M5 : NULL;
   while(i < limit && ! thisTmfr) {
      currChart = ChartNext(prevChart);      if (currChart < 0) break;        if (currChart != this_ID &&
      ChartSymbol(currChart) == Symbol() && ChartPeriod(currChart) == PERIOD_M5) { thisChart = currChart;      thisTmfr = ChartPeriod(currChart);
         Print("* Chart ",(i+2)," ",ChartSymbol(currChart)," ",(thisTmfr==PERIOD_M1? "M1": thisTmfr==PERIOD_M5? "M5": thisTmfr==PERIOD_M15? "M15": thisTmfr == 
            PERIOD_M30? "M30": thisTmfr==PERIOD_H1? "H1": thisTmfr==PERIOD_H4? "H4": thisTmfr==PERIOD_D1? "D1": thisTmfr==PERIOD_W1? "W1": "MN1")," ID = ",currChart); }
      prevChart = currChart;        i ++; }
   if (! thisTmfr) { Print("*** PAS DE CHART CIBLE TROUVE ! ***");         return(Chart_M5); }
   else { GlobalVariableSet(Chart_str, thisChart);          Print("** CHART CIBLE TROUVE ! "+thisChart+" **"); }
   return(thisChart); }

bool chk_chartm5(int i) { int t=0;
   while((! Chart_M5 || (!int(ChartPeriod(Chart_M5)) && !int(ChartPeriod(Chart_M5+t)) && !int(ChartPeriod(Chart_M5-t)))) && t < 13) t ++;

   if ((ChartPeriod(Chart_M5 + t) > 0 || ChartPeriod(Chart_M5 - t) > 0) && t > 0)
      if (ChartPeriod(Chart_M5 + t) > 0) Chart_M5 = Chart_M5 + t;
      else if (ChartPeriod(Chart_M5 - t) > 0) Chart_M5 = Chart_M5 - t;

   if (! Chart_M5) Chart_M5 = chart_find();

   if (GlobalVariableCheck(i_Cht_str)) i_Cht_M5 = GlobalVariableGet(i_Cht_str);
   if (i!=2 || t) if (t < 13) Print("** ChartPeriod(Chart_M5 +/- t) : "+IntegerToString(i)+" / "+IntegerToString(t)+" - "+TimeToStr(i_Cht_M5, TIME_SECONDS)+" **");
      else  Print("*** ChartPeriod(Chart_M5 +/- t) : PAS TROUVE ! -> i_Cht_M5 "+TimeToStr(i_Cht_M5, TIME_SECONDS)+" ***");
   return(t < 13); }    // Chart_M5 > 0

datetime tim_L_Objs7(long thisChart) { int obj_total=ObjectsTotal(thisChart);
   string name;      datetime OTim1;      bool t_neutral, t_liquid_s, t_liquid_b;
   for (int pos = 0; pos < obj_total; pos ++) {
      name = ObjectName(thisChart,pos);     //type = ObjectGetInteger(thisChart,name,OBJPROP_TYPE);
//      t_neutral0 = t_neutral;   t_liquid_b0 = t_liquid_b;   t_liquid_s0 = t_liquid_s;
      if ((t_neutral=(StringFind(name, "neutral") > 0)) ||
      (t_liquid_b=(StringFind(name, "liquid_buy") > 0)) || (t_liquid_s=(StringFind(name, "liquid_sell") > 0)))
         if (ObjectGet(name, OBJPROP_TIME1) > OTim1 && (t_liquid_b || t_liquid_s) && (! t_liquid_b || ! t_liquid_s))
//         if ((! t_neutral0 && t_neutral) || (! t_liquid_b0 && t_liquid_b) || (! t_liquid_s0 && t_liquid_s)) i = 0;
            OTim1 = ObjectGetInteger(thisChart, name, OBJPROP_TIME1); }
   return(OTim1); }

datetime tim_L_Rects(int I) { int obj_total=ObjectsTotal();
   string name;      datetime OTim1, OTim2;        bool tst=false;
   for (int pos = obj_total-1; pos && ! tst; pos --) {
      name = ObjectName(pos);     //type = ObjectGetInteger(thisChart,name,OBJPROP_TYPE);
      if (StringFind(name, "rect") > 0 && StringSubstr(name, 0, 3) == "ATS") { tst = true;
         if (! I) OTim1 = ObjectGet(name, OBJPROP_TIME1);      else  OTim2 = ObjectGet(name, OBJPROP_TIME2); } }
   return(! I ? OTim1 : OTim2); }

double prx_L_Rects(int I) { int obj_total=ObjectsTotal();
   string name;      datetime OLevel1, OLevel2;    bool tst=false;
   for (int pos = obj_total-1; pos && ! tst; pos --) {
      name = ObjectName(pos);     //type = ObjectGetInteger(thisChart,name,OBJPROP_TYPE);
      if (StringFind(name, "rect") > 0 && StringSubstr(name, 0, 3) == "ATS") { tst = true;
         if (! I) OLevel1 = ObjectGet(name, OBJPROP_PRICE1);   else  OLevel2 = ObjectGet(name, OBJPROP_PRICE2); } }
   return(! I ? OLevel1 : OLevel2); }

void rect_Order() { double sl;
   if (((OrderSelect(OrdersTotal() - 1, SELECT_BY_POS) && tim_L_Rects(0) < OrderOpenTime() && tim_L_Rects(1) + 600 > OrderOpenTime() &&
   OrderOpenTime() - tim_L_Rects(0) > 3600 && (prx_L_Rects(0) - prx_L_Rects(1)) > (WindowPriceMax() - WindowPriceMin()) / 8 &&
   ((OrderType() && fabs(prx_L_Rects(1) - OrderOpenPrice()) < 75) || (! OrderType() && fabs(prx_L_Rects(0) - OrderOpenPrice()) < 75)) &&
   OrderStopLoss() != (sl=NormalizeDouble(OrderType()? OrderOpenPrice()+10+(prx_L_Rects(0)-prx_L_Rects(1))/(TimeCurrent()-OrderOpenTime()<3600?
   1: 2): OrderOpenPrice() - 10 - (prx_L_Rects(0) - prx_L_Rects(1)) / (TimeCurrent() - OrderOpenTime() < 3600? 1: 2), Digits()))) ||
   (Hour() < 3 && OrderSelect(OrdersTotal() - 1, SELECT_BY_POS) && tim_L_Rects(0) < OrderOpenTime() && tim_L_Rects(1) + 900 > OrderOpenTime() &&
   OrderOpenTime() - tim_L_Rects(0) > 3000 && (prx_L_Rects(0) - prx_L_Rects(1)) > (WindowPriceMax() - WindowPriceMin()) / 8 &&
   ((OrderType() && fabs(prx_L_Rects(1) - OrderOpenPrice()) < 75) || (! OrderType() && fabs(prx_L_Rects(0) - OrderOpenPrice()) < 75)) &&
   OrderStopLoss() != (sl=NormalizeDouble(OrderType()? OrderOpenPrice() + 10 + (prx_L_Rects(0) - prx_L_Rects(1)) / (TimeCurrent() -
   OrderOpenTime() < 3000? 1: 2): OrderOpenPrice() - 10 - (prx_L_Rects(0) - prx_L_Rects(1)) / (TimeCurrent() - OrderOpenTime() <
   3000? 1: 2), Digits())))) && OrderModify(OrderTicket(), OrderOpenPrice(), sl, OrderTakeProfit(), 0, clrNONE))
Alert("***** Le dernier trade est dans un rectangle ATS et a été modifié, SL = " + DoubleToStr(sl, Digits()) + " *****");
  return; }

bool typ_L_Rects() { int obj_total=ObjectsTotal();
   string name;      bool t_neutral, t_liquid_s, t_liquid_b, liquid_buy;
   for (int pos = 0; pos < obj_total; pos ++) { name = ObjectName(pos);
      if (((t_neutral=(StringFind(name, "neutral") > 0)) ||
      (t_liquid_b=(StringFind(name, "liquid_buy") > 0)) || (t_liquid_s=(StringFind(name, "liquid_sell") > 0)))
      && (! t_liquid_b || ! t_liquid_s)) liquid_buy = t_liquid_b; }
   return(liquid_buy); }

double set_Rectangles() { if (pass1) { objRects_del(0, "");    // ArrayInitialize(Rect_Ns, "");
      ArrayInitialize(Rect_Hs, 0);     ArrayInitialize(Rect_Ks, -1); }
   else { for (int i = 0; i < ArraySize(Rect_Hs) - 1; i ++) if (! Rect_Ks[i] &&
      Rect_Ns[i][0] != "") { ObjectDelete(Rect_Ns[i][0]);      ObjectDelete(Rect_Ns[i][1]);      if (NR && i > 7) { NR --;
         Rect_Hs[i][0] = 0.0;       Rect_Hs[i][1] = 0.0;       Rect_Ks[i] = -1;     Rect_Ns[i][0] = "";     Rect_Ns[i][1] = ""; } }
      while (Rect_Hs[40][0] > 0.0) { for (i = ArraySize(Rect_Hs)-1; i >= 0; i --) {
            Rect_Hs[ArraySize(Rect_Hs) - i-1][0] = Rect_Hs[ArraySize(Rect_Hs) - i][0];
            Rect_Hs[ArraySize(Rect_Hs) - i-1][1] = Rect_Hs[ArraySize(Rect_Hs) - i][1];
            Rect_Ns[ArraySize(Rect_Ns) - i-1][0] = Rect_Ns[ArraySize(Rect_Ns) - i][0];
            Rect_Ns[ArraySize(Rect_Ns) - i-1][1] = Rect_Ns[ArraySize(Rect_Ns) - i][1];
            Rect_Ks[ArraySize(Rect_Ks) - i-1] = Rect_Ks[ArraySize(Rect_Ks) - i]; }
         Rect_Hs[ArraySize(Rect_Hs)-1][0] = 0.0;   Rect_Hs[ArraySize(Rect_Hs)-1][1] = 0.0;
         Rect_Ks[ArraySize(Rect_Ks) - 1] = -1;     Rect_Ns[ArraySize(Rect_Ns) - 1][0] = "";
         Rect_Ns[ArraySize(Rect_Ns) - 1][1] = "";        NR --; } }
   double ADX_bars[50][3], rHigh, rLow, rHigh_, rLow_, tmp, rect_H;
   int nr, j_, J, K, vX1, vY1, vX2, vY2;        bool tst, r_on=false;
   for (int k = 0; k < (pass1? 100: 1); k += 15) { ArrayInitialize(ADX_bars, 0);
      for (i = k; i < k + 50; i ++) if ((rHigh_ = iHigh(NULL,0,iHighest(NULL,0,MODE_HIGH,i-k,k))) > 
      (rLow_ = iLow(NULL,0,iLowest(NULL,0,MODE_LOW,i-k,k)))) { ADX_bars[i-k][0] = i > k+4 ? (i-k) / (rHigh_ - rLow_) : 0;
         ADX_bars[i-k][1] = iCustom(NULL, 0, "New folder\\ADX.ex4", 0, i) < 30 && iCustom(NULL, 0, "New folder\\ADX.ex4", 1, i) < 30 &&
            iCustom(NULL, 0, "New folder\\ADX.ex4", 2, i) < 30 ? 1.0 : 0.0;
         if (i > k + 4) { for (int j = k; j < i; j ++) ADX_bars[i-k][2] += ADX_bars[j-k][1];
if (ADX_bars[i-k][2] > (i-k)) Alert("*** ADX_bars[i-k][2] > (i - k) : "+IntegerToString(ADX_bars[i-k][2])+" "+IntegerToString(i - k)+" ***");
            ADX_bars[i-k][2] = ADX_bars[i-k][2] / (i-k) * 1.0; } }
      int iRange, l;    j = 0;   for (i = k + 4; i < k + 50; i ++) if (ADX_bars[i-k][0] * ADX_bars[i-k][2] > iRange) {
         if (ADX_bars[i-k][2] > 0.8) { iRange = ADX_bars[i-k][0] * ADX_bars[i-k][2];      l = j;      j = i; } }
      if (rHigh != iHigh(NULL,0,iHighest(NULL,0,MODE_HIGH,j-k,k)) || rLow != iLow(NULL,0,iLowest(NULL,0,MODE_LOW,j-k,k))) { vY1 = 0;   vY2 = 0;
         rHigh = 0;        rLow = 0;      while (rHigh == 0.0 || rLow == 0.0) {
            rHigh = iHigh(NULL,0,iHighest(NULL,0,MODE_HIGH,j-k,k));     rLow = iLow(NULL,0,iLowest(NULL,0,MODE_LOW,j-k,k)); }
         ChartTimePriceToXY(0, 0, Time[j], rHigh, vX1, vY1);
         ChartTimePriceToXY(0, 0, Time[k], rLow, vX2, vY2);          J = j;      K = k;      tst = !j_ || j_ < j;
if (j && vY1 == vY2) Alert("***** vY1 == vY2 : "+IntegerToString(vY1)+" "+IntegerToString(vY2)+" "+IntegerToString(vY2-vY1)+" "+IntegerToString(nr)+" *****");
         if (j && ADX_bars[j-k][2] > 0.8 && (((vY2-vY1)*1.0 < (vX2-vX1)*0.8 && tst) || ((vY2-vY1)*1.0 < (vX2-vX1)*1.25 && !tst))) {
            while (iHigh(NULL, 0, J+2) < rHigh && iLow(NULL, 0, J+2) > rLow && J-j < 17) J ++;
            while (iHigh(NULL, 0, K-2) < rHigh && iLow(NULL, 0, K-2) > rLow && K && k-K < 17) K --;
            if (tst) { while (J && (iStdDev(NULL, 0, J-K, K, MODE_SMA, PRICE_TYPICAL, 0) / Point() / 100 > 1.0 ||
                  (tmp=iMA(NULL, 0, J-K, 0, MODE_SMA, PRICE_CLOSE, K)) < rLow + (rHigh-rLow)*0.3 ||
                  tmp > rLow + (rHigh-rLow) * 0.7)) { J --;       K ++; }
               while (iStdDev(NULL, 0, J+2-K, K, MODE_SMA, PRICE_TYPICAL, 0) / Point() / 100 < (Point()==0.00001 ||
                  Point()==0.001? 0.8: 1.0) && (tmp=iMA(NULL, 0, J-K, 0, MODE_SMA, PRICE_CLOSE, K)) > rLow + (rHigh-rLow)*0.3 &&
                  tmp < rLow + (rHigh-rLow) * 0.7 && J - j < 17) J ++;
               while (K && iStdDev(NULL, 0, J-K+2, K-2, MODE_SMA, PRICE_TYPICAL, 0) / Point() / 100 < (Point()==0.00001 ||
                  Point()==0.001? 0.8: 1.0) && (tmp=iMA(NULL, 0, J-K, 0, MODE_SMA, PRICE_CLOSE, K)) > rLow + (rHigh-rLow)*0.3 &&
                  tmp < rLow + (rHigh-rLow) * 0.7 && K && k - K < 17) K --; }
            if (J - K > 4) { rHigh = 0;      rLow = 0;      while (rHigh == 0.0 || rLow == 0.0) {
                  rHigh = iHigh(NULL,0,iHighest(NULL,0,MODE_HIGH,J-K,K));      rLow = iLow(NULL,0,iLowest(NULL,0,MODE_LOW,J-K,K)); }
               Rect_Ns[NR][0] = RectangleCreate(Time[J], rHigh, Time[K] + Period()*60, rLow, tst? 0: 1);             if (tst)
               Rect_Ns[NR][1] = CreateLabelR(rHigh, J, IntegerToString(nr+1)+" - "+IntegerToString(J-K)+" "+IntegerToString(K)+" "+DoubleToStr(ADX_bars[j-k][2],2)+" "+
               DoubleToStr((vY2-vY1)*1.0/(vX2-vX1)*1.0, 2)+" "+DoubleToStr(iStdDev(NULL, 0, J-K, K, MODE_SMA, PRICE_TYPICAL, 0)/Point()/100, 2), nr, tst? 0: 1);
               Rect_Hs[NR][0] = rHigh;       Rect_Hs[NR][1] = rLow;     Rect_Ks[NR] = K;        NR ++;
               if (! K && iBarShift(NULL, 0, Time[J]) > rect_HG) rect_HG = iBarShift(NULL, 0, Time[J]);
               if (! K && rect_H < rHigh - rLow) rect_H = rHigh - rLow; }     nr ++;      j_ = tst? J: j_;     r_on = r_on? r_on: ! K; } } }
   return(r_on? rect_H: 0.0); }

void ChangeRectangleEmptyPoints(datetime &time1,double &price1,datetime &time2,double &price2) {
   if (! time1) time1=TimeCurrent();
   if (! price1) price1 = SymbolInfoDouble(Symbol(), SYMBOL_BID);
   if (! time2) { datetime temp[10];
      CopyTime(Symbol(), Period(), time1, 10, temp);
      time2 = temp[0]; }
   if (! price2) price2 = price1 - 300 * SymbolInfoDouble(Symbol(),SYMBOL_POINT); }

string RectangleCreate(datetime time1,double price1,datetime time2,double price2,int Item) {
   ChangeRectangleEmptyPoints(time1, price1, time2, price2);         ResetLastError();
   string RectName = "EA_Rectangle_"+IntegerToString(iBarShift(NULL,0,time1,false))+"-"+IntegerToString(iBarShift(NULL,0,time2,false))+
      " " + IntegerToString(TimeCurrent());
   if (! ObjectCreate(RectName, OBJ_RECTANGLE, 0, time1, price1, time2, price2)) {
      Print(__FUNCTION__, ": failed to create a rectangle! Error code = ",GetLastError());   return(false); }
   ObjectSetInteger(0, RectName, OBJPROP_COLOR, Item? clrCornsilk: clrAqua);
   ObjectSetInteger(0, RectName, OBJPROP_STYLE, Item? STYLE_DOT: STYLE_SOLID);
   ObjectSetInteger(0, RectName, OBJPROP_WIDTH, 1);
   ObjectSetInteger(0, RectName, OBJPROP_FILL, false);
   ObjectSetInteger(0, RectName, OBJPROP_BACK, false);
   ObjectSetInteger(0, RectName, OBJPROP_SELECTABLE,false);
   ObjectSetInteger(0, RectName, OBJPROP_SELECTED, false);
   ObjectSetInteger(0, RectName, OBJPROP_HIDDEN, true);
   ObjectSetInteger(0, RectName, OBJPROP_ZORDER, 0);
   return(RectName); }

void objRects_del(bool L,string Line_N) {  // int P
   int I=0, J=0, P=0, obj_total=ObjectsTotal();
   string name;   for (int pos=0; pos < obj_total; pos ++) { name = ObjectName(pos);      if (! L || name != Line_N)
      if (StringSubstr(name,0,(L? 10: 13)) == "EA_"+(L? "R-Line": "Rectangle")+"_" || StringSubstr(name,0,13) == "EA_Rec-Label_") {
         J ++;       if (ObjectDelete(name)) { I ++;     pos --; } } }
   if (P) Print("** ", pos, " objects, DELETED: ", I, " / ", J, " / ", obj_total, " **");
  return; }

string CreateLabelR(double LinePrice,int BarNum,string vText,int Nr,int Item) {
   string LabelName = "EA_Rec-Label_"+DoubleToStr(LinePrice,Digits())+"-"+IntegerToString(BarNum)+"-"+IntegerToString(Nr)+" "+IntegerToString(TimeCurrent());
   ObjectCreate(LabelName,OBJ_TEXT, 0, Time[BarNum], LinePrice);
   ObjectSet(LabelName,OBJPROP_ANCHOR, ANCHOR_LEFT_LOWER);
   ObjectSetString(0,LabelName,OBJPROP_TEXT, vText);
   ObjectSet(LabelName,OBJPROP_FONTSIZE, 8);
   ObjectSet(LabelName,OBJPROP_COLOR, Item? clrCornsilk: clrTurquoise);
   ObjectSet(LabelName,OBJPROP_SELECTABLE, true);
   ObjectSet(LabelName,OBJPROP_SELECTED, false);
   ObjectSet(LabelName,OBJPROP_HIDDEN, true);
   ObjectSet(LabelName, OBJPROP_ZORDER, 10);
   return(LabelName); }

string LineCreate(double price) { ResetLastError();
   string LineName = "EA_R-Line_" + IntegerToString(TimeCurrent());
   if (! ObjectCreate(LineName, OBJ_HLINE, 0, 0, price)) {
      Print(__FUNCTION__, ": failed to create a rectangle! Error code = ",GetLastError());   return(false); }
   ObjectSetInteger(0, LineName, OBJPROP_COLOR, clrCornsilk);
   ObjectSetInteger(0, LineName, OBJPROP_STYLE, STYLE_DOT);
   ObjectSetInteger(0, LineName, OBJPROP_WIDTH, 1);
   ObjectSetInteger(0, LineName, OBJPROP_FILL, false);
   ObjectSetInteger(0, LineName, OBJPROP_BACK, false);
   ObjectSetInteger(0, LineName, OBJPROP_SELECTABLE,false);
   ObjectSetInteger(0, LineName, OBJPROP_SELECTED, false);
   ObjectSetInteger(0, LineName, OBJPROP_HIDDEN, true);
   ObjectSetInteger(0, LineName, OBJPROP_ZORDER, 0);
   return(LineName); }

void Liqu_x2_tf(string str) { int t1=0, t2=0, err;       bool tst;     string temp;
#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(20) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 20:
Period()+" | "+t1+" | "+tim_M15+" | "+Time[0]; #endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
   if (Period() == PERIOD_M15) { GlobalVariableSet(tmfr0_str, PERIOD_M5);
      while(! (tst=ChartSetSymbolPeriod(0, NULL, PERIOD_M5)) && t1 < 17) { t1 ++;      Sleep(100);       tim_M15 = Time[0]; }       if (tst) {
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 20:
Period()+" | "+t1+" | "+tim_M15+" | "+Time[0]);    copy_file_45(5, "20;"+TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+";"+IntegerToString(TimeCurrent())+";"+IntegerToString(Period()));#endif
         temp = "** Passage en M5 (x2) à "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" ! (Period()="+IntegerToString(Period())+", t1="+IntegerToString(t1)+") *(20)*";
         Print(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp);        tmf_Diff = true; }
         return; }

#ifdef v_dump_1   f_tmp = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+": "+f_tmp(21) + "\r\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " +       //      case 21:
Period()+" | "+chk_chartm5(10)+" | "+Chart_M5+" | "+StringTrimLeft(ChartSymbol(Chart_M5))+" | "+tmfr_+" | "+tmfr_b+" | "+t1+" | "+err+" | "+tmfr+" | "+tmf_Diff+" | - | "+
tim_Chart_M5b+" | "+TimeCurrent()+" | "+t5a_Bull_b+" | "+bull_+" | "+t5b_Bull_b+" | "+FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0); #endif
#ifdef v_dump_2   copy_file_45(4, f_tmp); #endif
   if (Period() > PERIOD_M15 || Period() <= PERIOD_M5) {
    if (! chk_chartm5(10)) Alert("*** ERROR Chart_M5 (10) "+IntegerToString(ChartPeriod(Chart_M5))+" - "+IntegerToString(Chart_M5)+" ***");
    if (StringTrimLeft(ChartSymbol(Chart_M5)) != "") {   if (Period() > PERIOD_M15) tmfr_ = Period();
      if (Period() == PERIOD_M5) tmfr_b = Period();      if (Period() == PERIOD_M1) tmfr_ = PERIOD_H1;
      while(! (tst=ChartSetSymbolPeriod(0, NULL, Period()==PERIOD_M5?PERIOD_M1:Period()==PERIOD_M1?PERIOD_M15:PERIOD_M5)) && t1 < 17) { t1 ++;  Sleep(100); }
         err = GetLastError();   if (tst) { if (! chk_chartm5(3)) Alert("*** ERROR Chart_M5 (11) "+IntegerToString(ChartPeriod(Chart_M5))+" - "+
            IntegerToString(Chart_M5)+" ***");       /* Sleep(50);        ChartSetInteger(0, CHART_SCALE, 0, Period() > PERIOD_M15? 4: 3); */
            tmfr = Period()==PERIOD_M5? PERIOD_M1: PERIOD_M5;           tmf_Diff = true;
//         while(! ChartSetSymbolPeriod(Chart_M5, NULL, ENUM_TIMEFRAMES(tmfr_)) && t2 < 17) { t2 ++;    Sleep(100); }
         Sleep(50);        /* ChartSetInteger(Chart_M5, CHART_SCALE, 0, Period() == PERIOD_M5? 5: 4); */    int err2 = GetLastError();
         if (Period() == PERIOD_M5) { tim_Chart_M5b = TimeCurrent();      GlobalVariableSet(t2_Chart_str, tim_Chart_M5b);
            t5a_Bull_b = bull_;                 t5b_Bull_b = FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0);
            GlobalVariableSet(t3_Bull_str, t5a_Bull_b);     GlobalVariableSet(t4_Bull_str, t5b_Bull_b);
            GlobalVariableSet(tmfr2_str, tmfr_b);           GlobalVariableSet(tmfr0_str, tmfr); }
/*         else { tim_Chart_M5 = TimeCurrent();       GlobalVariableSet("t_Chart_M5", tim_Chart_M5);
            t5a_Bullish = bull_;                t5b_Bullish = FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0);
            GlobalVariableSet(t1_Bull_str, t5a_Bullish);    GlobalVariableSet(t2_Bull_str, t5b_Bullish);
            GlobalVariableSet(tmfr1_str, tmfr_);            GlobalVariableSet(tmfr0_str, tmfr); }*/ }
      if (tst) { temp = "** Passage en " + (Period()==PERIOD_M5? "M1": "M5") + " à " + TimeToStr(TimeCurrent(),TIME_MINUTES) + " ! (Period()=" + IntegerToString(Period()) +
            ",t1=" + IntegerToString(t1)+", t2=" + IntegerToString(t2) + (t2==17 ? ", err2=" + IntegerToString(err2) : "") + ") *(21)*";
#ifdef v_dump_1   copy_file_45(4,#ifdef v_dump_2 StringSubstr(f_tmp, 0, StringFind(f_tmp, "\r")) #else f_tmp #endif+ "\r\n\t   "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" "+Symbol()+","+stmfr+": "+  // case 21:
Period()+" | "+chk_chartm5(10)+" | "+Chart_M5+" | "+StringTrimLeft(ChartSymbol(Chart_M5))+" | "+tmfr_+" | "+tmfr_b+" | "+t1+" | "+err+" | "+tmfr+" | "+tmf_Diff+" | "+err2+" | "+
tim_Chart_M5b+" | "+TimeCurrent()+" | "+t5a_Bull_b+" | "+bull_+" | "+t5b_Bull_b+" | "+FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0));
copy_file_45(5, "21;"+TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+";"+IntegerToString(TimeCurrent())+";"+IntegerToString(Period())); #endif
         Print(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp); }
      else { temp = "*** Erreur - Passage en " + (Period()==PERIOD_M5?"M1":"M5") + " à " + TimeToStr(TimeCurrent(),TIME_MINUTES) + " ! (Period()=" + IntegerToString(Period()) +
            ", t1=" + IntegerToString(t1) + ", err1=" + IntegerToString(err) + ") ***";
         Alert(temp);         copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp);         Sleep(100); } } } }

int f_Params(int mode) { int new_set=5;   // <- changer à chaque élément nouveau
  if (mode) {
   GlobalVariableSet("EURUSD_Comm", 13);         GlobalVariableSet("EURUSD_Sprd", 20);          GlobalVariableSet("EURUSD_Mag_N", 101);
/*   GlobalVariableSet("USDZAR_Comm", 706);        GlobalVariableSet("USDZAR_Sprd", 1600);
   GlobalVariableSet("EURZAR_Comm", 706);        GlobalVariableSet("EURZAR_Sprd", 1600);
   GlobalVariableSet("USDMXN_Comm", 606);        GlobalVariableSet("USDMXN_Sprd", 1500); */
   GlobalVariableSet("CADJPY_Comm", 13);         GlobalVariableSet("CADJPY_Sprd", 20);          GlobalVariableSet("CADJPY_Mag_N", 102);
   GlobalVariableSet("EURGBP_Comm", 13);         GlobalVariableSet("EURGBP_Sprd", 20);          GlobalVariableSet("EURGBP_Mag_N", 103);
   GlobalVariableSet("EURJPY_Comm", 13);         GlobalVariableSet("EURJPY_Sprd", 20);          GlobalVariableSet("EURJPY_Mag_N", 104);
   GlobalVariableSet("GBPJPY_Comm", 13);         GlobalVariableSet("GBPJPY_Sprd", 20);          GlobalVariableSet("GBPJPY_Mag_N", 105);
   GlobalVariableSet("USDTRY_Comm", 13);         GlobalVariableSet("USDTRY_Sprd", 20);          GlobalVariableSet("USDTRY_Mag_N", 106);

   GlobalVariableSet("BTCUSD_Comm", 3506);       GlobalVariableSet("BTCUSD_Sprd", 5000);        GlobalVariableSet("BTCUSD_Mag_N", 201);
/*   GlobalVariableSet("ETHUSD_Comm", 506);        GlobalVariableSet("ETHUSD_Sprd", 715);
   GlobalVariableSet("LTCUSD_Comm", 66););       GlobalVariableSet("LTCUSD_Sprd", 85);
   GlobalVariableSet("XRPUSD_Comm", 56);         GlobalVariableSet("XRPUSD_Sprd", 50); */

//   GlobalVariableSet("USTECH_Comm", 136);      GlobalVariableSet("USTECH_Sprd", 200);
   GlobalVariableSet("CHINAA_Comm", 13500);      GlobalVariableSet("CHINAA_Sprd", 42000);       GlobalVariableSet("CHINAA_Mag_N", 501);
   GlobalVariableSet("HKG50_Comm", 22000);       GlobalVariableSet("HKG50_Sprd", 65000);        GlobalVariableSet("HKG50_Mag_N", 502);
   GlobalVariableSet("SPX500_Comm", 55);         GlobalVariableSet("SPX500_Sprd", 170);         GlobalVariableSet("SPX500_Mag_N", 503);
   GlobalVariableSet("AUS200_Comm", 485);        GlobalVariableSet("AUS200_Sprd", 1500);        GlobalVariableSet("AUS200_Mag_N", 504);
   GlobalVariableSet("UK100_Comm", 105);         GlobalVariableSet("UK100_Sprd", 320);          GlobalVariableSet("UK100_Mag_N", 505);
   GlobalVariableSet("US30_Comm", 170);          GlobalVariableSet("US30_Sprd", 520);           GlobalVariableSet("US30_Mag_N", 506);
   GlobalVariableSet("GER30_Comm", 170);         GlobalVariableSet("GER30_Sprd", 520);          GlobalVariableSet("GER30_Mag_N", 507);
   GlobalVariableSet("JPN225_Comm", 1105);       GlobalVariableSet("JPN225_Sprd", 3320);        GlobalVariableSet("JPN225_Mag_N", 508);
   GlobalVariableSet("NAS100_Comm", 300);        GlobalVariableSet("NAS100_Sprd", 930);         GlobalVariableSet("NAS100_Mag_N", 509);
   GlobalVariableSet("FRA40_Comm", 130);         GlobalVariableSet("FRA40_Sprd", 380);          GlobalVariableSet("FRA40_Mag_N", 510);
   GlobalVariableSet("ESTX50_Comm", 160);        GlobalVariableSet("ESTX50_Sprd", 500);         GlobalVariableSet("ESTX50_Mag_N", 511);
   GlobalVariableSet("ITA40_Comm", 120);         GlobalVariableSet("ITA40_Sprd", 380);          GlobalVariableSet("ITA40_Mag_N", 512);
   GlobalVariableSet("SUI20_Comm", 45);         GlobalVariableSet("SUI20_Sprd", 150);           GlobalVariableSet("SUI20_Mag_N", 513);

   GlobalVariableSet("XAUUSD_Comm", 13);         GlobalVariableSet("XAUUSD_Sprd", 20);          GlobalVariableSet("XAUUSD_Mag_N", 301);
   GlobalVariableSet("BRENT_Comm", 56);          GlobalVariableSet("BRENT_Sprd", 100);          GlobalVariableSet("BRENT_Mag_N", 303);

   GlobalVariableSet("EURUSD_H1", 6);    GlobalVariableSet("EURUSD_H2", 8);    GlobalVariableSet("EURUSD_H3", 23);    GlobalVariableSet("EURUSD_Diff", 0);
/*   GlobalVariableSet("USDZAR_H1", 6);    GlobalVariableSet("USDZAR_H2", 8);    GlobalVariableSet("USDZAR_H3", 23);    GlobalVariableSet("USDZAR_Diff", 0);
   GlobalVariableSet("EURZAR_H1", 6);    GlobalVariableSet("EURZAR_H2", 8);    GlobalVariableSet("EURZAR_H3", 23);    GlobalVariableSet("EURZAR_Diff", 0);
   GlobalVariableSet("USDMXN_H1", 6);    GlobalVariableSet("USDMXN_H2", 8);    GlobalVariableSet("USDMXN_H3", 23);    GlobalVariableSet("USDMXN_Diff", 0); */
   GlobalVariableSet("CADJPY_H1", 6);    GlobalVariableSet("CADJPY_H2", 8);    GlobalVariableSet("CADJPY_H3", 23);    GlobalVariableSet("CADJPY_Diff", 0);
   GlobalVariableSet("EURGBP_H1", 6);    GlobalVariableSet("EURGBP_H2", 8);    GlobalVariableSet("EURGBP_H3", 23);    GlobalVariableSet("EURGBP_Diff", 0);
   GlobalVariableSet("EURJPY_H1", 6);    GlobalVariableSet("EURJPY_H2", 8);    GlobalVariableSet("EURJPY_H3", 23);    GlobalVariableSet("EURJPY_Diff", 0);
   GlobalVariableSet("GBPJPY_H1", 6);    GlobalVariableSet("GBPJPY_H2", 8);    GlobalVariableSet("GBPJPY_H3", 23);    GlobalVariableSet("GBPJPY_Diff", 0);
   GlobalVariableSet("USDTRY_H1", 6);    GlobalVariableSet("USDTRY_H2", 8);    GlobalVariableSet("USDTRY_H3", 23);    GlobalVariableSet("USDTRY_Diff", 0);

   GlobalVariableSet("BTCUSD_H1", 1);    GlobalVariableSet("BTCUSD_H2", 1);    GlobalVariableSet("BTCUSD_H3", 23);     GlobalVariableSet("BTCUSD_Diff", 0);
/*   GlobalVariableSet("ETHUSD_H1", 1);    GlobalVariableSet("ETHUSD_H2", 1);    GlobalVariableSet("ETHUSD_H3", 0);     GlobalVariableSet("ETHUSD_Diff", 0);
   GlobalVariableSet("LTCUSD_H1", 1);    GlobalVariableSet("LTCUSD_H2", 1);    GlobalVariableSet("LTCUSD_H3", 0);     GlobalVariableSet("LTCUSD_Diff", 0);
   GlobalVariableSet("XRPUSD_H1", 1);    GlobalVariableSet("XRPUSD_H2", 1);    GlobalVariableSet("XRPUSD_H3", 0);     GlobalVariableSet("XRPUSD_Diff", 0); */

// fin de journée : 22 h 45 - reprise lundi matin : 04 h 00 - reprise matin semaine : 03 h 45 
   GlobalVariableSet("CHINAA_H1", 22);   GlobalVariableSet("CHINAA_H2", 4);   GlobalVariableSet("CHINAA_H3", 14);    GlobalVariableSet("CHINAA_Diff", 0);
// fin de journée : 21 h 00 - reprise lundi matin : 04 h 15 - reprise matin semaine : 03 h 45 
   GlobalVariableSet("HKG50_H1", 20);    GlobalVariableSet("HKG50_H2", 4);    GlobalVariableSet("HKG50_H3", 14);     GlobalVariableSet("HKG50_Diff", 0);
   GlobalVariableSet("SPX500_H1", 3);    GlobalVariableSet("SPX500_H2", 6);   GlobalVariableSet("SPX500_H3", 23);    GlobalVariableSet("SPX500_Diff", 0);
   GlobalVariableSet("FRA40_H1", 8);     GlobalVariableSet("FRA40_H2", 8);    GlobalVariableSet("FRA40_H3", 20);     GlobalVariableSet("FRA40_Diff", 0);
// fin de journée : 23 h 00 - reprise lundi matin : 02 h 50 - reprise matin semaine : 02 h 50 
   GlobalVariableSet("AUS200_H1", 22);   GlobalVariableSet("AUS200_H2", 4);   GlobalVariableSet("AUS200_H3", 19);    GlobalVariableSet("AUS200_Diff", 0);
   GlobalVariableSet("UK100_H1", 6);     GlobalVariableSet("UK100_H2", 8);    GlobalVariableSet("UK100_H3", 23);     GlobalVariableSet("UK100_Diff", 0);
   GlobalVariableSet("US30_H1", 3);      GlobalVariableSet("US30_H2", 6);     GlobalVariableSet("US30_H3", 23);      GlobalVariableSet("US30_Diff", 0);
   GlobalVariableSet("GER30_H1", 8);     GlobalVariableSet("GER30_H2", 8);    GlobalVariableSet("GER30_H3", 20);     GlobalVariableSet("GER30_Diff", 0);
// fin de journée : 00 h 00 - reprise lundi matin : 01 h 50 - reprise matin semaine : 01 h 50 
   GlobalVariableSet("JPN225_H1", 23);   GlobalVariableSet("JPN225_H2", 1);   GlobalVariableSet("JPN225_H3", 19);    GlobalVariableSet("JPN225_Diff", 0);
   GlobalVariableSet("NAS100_H1", 3);    GlobalVariableSet("NAS100_H2", 6);   GlobalVariableSet("NAS100_H3", 23);    GlobalVariableSet("NAS100_Diff", 0);
   GlobalVariableSet("ESTX50_H1", 6);    GlobalVariableSet("ESTX50_H2", 8);   GlobalVariableSet("ESTX50_H3", 23);    GlobalVariableSet("ESTX50_Diff", 0);
   GlobalVariableSet("ITA40_H1", 8);     GlobalVariableSet("ITA40_H2", 8);    GlobalVariableSet("ITA40_H3", 20);     GlobalVariableSet("ITA40_Diff", 0);
   GlobalVariableSet("SUI20_H1", 8);     GlobalVariableSet("SUI20_H2", 8);    GlobalVariableSet("SUI20_H3", 20);     GlobalVariableSet("SUI20_Diff", 0);

   GlobalVariableSet("XAUUSD_H1", 1);    GlobalVariableSet("XAUUSD_H2", 8);   GlobalVariableSet("XAUUSD_H3", 23);     GlobalVariableSet("XAUUSD_Diff", 40);
   GlobalVariableSet("BRENT_H1", 6);     GlobalVariableSet("BRENT_H2", 8);    GlobalVariableSet("BRENT_H3", 23);     GlobalVariableSet("BRENT_Diff", 40);

   GlobalVariableSet("All_SL", 25); }    // / 1000

  comm = GlobalVariableGet(StringSubstr(Symbol(), 0, 6) + "_Comm");
  sprd = GlobalVariableGet(StringSubstr(Symbol(), 0, 6) + "_Sprd");
  H1 =   GlobalVariableGet(StringSubstr(Symbol(), 0, 6) + "_H1");
  H2 =   GlobalVariableGet(StringSubstr(Symbol(), 0, 6) + "_H2");    HOp = H2;
  H3 =   GlobalVariableGet(StringSubstr(Symbol(), 0, 6) + "_H3");    H3_ = H3;
  diff = GlobalVariableGet(StringSubstr(Symbol(), 0, 6) + "_Diff");
  Mg_N = GlobalVariableGet(StringSubstr(Symbol(), 0, 6) + "_Mag_N");
  SL =   GlobalVariableGet("All_SL") / 1000.0 * (Ask > 1000 ? round((Bid+Ask) / 2000.0) * 1000 :
      Ask > 100? round((Bid+Ask)/200.0) * 100.0: Ask > 10? round((Bid+Ask)/20.0) * 10.0: Ask > 1? round((Bid+Ask) / 2.0): 1.0);

  Alert("** f_Params("+IntegerToString(mode)+") OK-"+IntegerToString(new_set)+" : "+Symbol()+" / "+IntegerToString(Period())+" - comm "+IntegerToString(comm)+" - sprd "+
   IntegerToString(sprd)+" - H1 "+IntegerToString(H1)+" - H2 "+IntegerToString(H2)+" - H3 "+IntegerToString(H3)+" - diff "+IntegerToString(diff)+" - SL "+DoubleToStr(SL, Digits())+" **");
  GlobalVariableSet(p_Ver_str, new_set);
  return(mode ? 1 : new_set); }

void Close_All_Trades() { string temp;
  for (int i = OrdersTotal()-1; i >= 0; i --) {
    if (OrderSelect(i, SELECT_BY_POS)) {
       int type = OrderType();      bool result = false;
       switch(type) {
          //Close opened long positions
          case OP_BUY  : result = OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),Slippage,Pink);
                         break;
          //Close opened short positions
          case OP_SELL : result = OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),Slippage,Pink);
                         break;
          //Close pending orders
            case OP_BUYLIMIT  : result = OrderDelete( OrderTicket() );     break;
            case OP_BUYSTOP   : result = OrderDelete( OrderTicket() );     break;
            case OP_SELLLIMIT : result = OrderDelete( OrderTicket() );     break;
            case OP_SELLSTOP  : result = OrderDelete( OrderTicket() ); }
       if (result == false) Sleep(2000); } } //*/

  temp = "***** Account STOP LOSS Reached. All Trades Have Been Closed. ("+DoubleToStr(AccountBalance(),2)+" - "+Hour()+" - "+DoubleToStr(AccBalance_day,2)+") *****";
  Alert(temp);          copy_file_(3, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + temp);
  t_ngt0 = true;        GlobalVariableSet("t_ngt_3", 1.0);        Sleep(100);          ExpertRemove(); }

double m3_RSI (ENUM_TIMEFRAMES per,int nb) {
   return((iCustom(NULL, per, "RSI.ex4", 0, 1) + iCustom(NULL, per, "RSI.ex4", 0, 2) +
      (nb == 3 ? iCustom(NULL, per, "RSI.ex4", 0, 3) : 0.0)) / nb); }

string f_tmp(int i) { string str;
      switch(i) {
         case 1: 
str = "Hour() | H1 | H3 | HOp | str | Seconds() | last_rct_ | Time[0] | Period() | t_M5_M15 | t_M15_H1 | tmfr_ | tmfr | " +
   "t1 | err | t2 | err2 | Chart_M5 | chk_chartm5(3) | tim_Chart_M5 | bull_ | t5a_Bullish | t5b_Bullish | FileIsExist(\"ATS-Ind_On-Off\\ATS-Ind5\"+str+\"_Buy.txt\", 0) | t_night";
             break;  
         case 3: 
str = "str | Hour() | HOp | Minute() | Period() | t1";
             break;  
         case 4: 
str = "Hour() | HOp | Period() | TimeCurrent() | tim_Chart_M5 | tmfr_ | m3_RSI(PERIOD_M5, 2) | tst2 | nb_ticks | nb_tcks_N | " +
   "chk_chartm5(4) | Chart_M5 | StringTrimLeft(ChartSymbol(Chart_M5)) | bull_ | t5a_Bullish | t5b_Bullish | FileIsExist(\"ATS-Ind_On-Off\\ATS-Ind5\"+str+\"_Buy.txt\", 0) | " +
   "t1 | err | tmfr_ | t2 | chk_chartm5(5) | t_M15_H1";
             break;  
         case 5: 
str = "Period() | TimeCurrent() | tim_Chart_M5b | tmfr_b | chk_chartm5(6) | Chart_M5 | StringTrimLeft(ChartSymbol(Chart_M5)) | " +
   "str | bull_ | t5a_Bull_b | t5b_Bull_b | FileIsExist(\"ATS-Ind_On-Off\\ATS-Ind5\"+str+\"_Buy.txt\", 0) | t1 | t2 | chk_chartm5(7)";
             break;  
         case 6: 
str = "tst2 | Period() | m3_RSI(0, 2) | nb_ticks | nb_tcks_N";
             break;  
         case 7: 
str = "tst1 | ticket | bull_ | bull | tst2 | t_rsi515o | tim_flt | TimeCurrent() | Period() | last_ntr_pr | Ask | Bid | last_liq_t1 | " +
   "obj_bars[prv_pos] | Bars | tmf_Diff | OS5_tick | time_allow | OrderType() | obj_liqTypes[prv_pos] | ticket | t_rsi515 | H1 | H3 | Hour() | " +
   "Time[0] | OrderOpenTime() | haCoef | tim_flt | no_OS5 | Ask | Bid | H2 | m3_RSI(0, 2) | t1 | t_M5_M15 | tim_M15 | liqu_x2_n";
             break;  
         case 8: 
str = "nb_ticks | nb_tcks_N | m3_RSI(0, 2) | t_M5_M15 | Period() | Hour() | t1 | tim_M15 | Time[0] | tmf_Diff";
             break;  
         case 9: 
str = "t_rsi51_ | t_rsi515 | t_rsi515o | tim_M15 | Time[0] | Period() | m3_RSI(PERIOD_M5, 2) | t1 | t_M5_M15 | tmf_Diff";
             break;  
         case 10: 
str = "trd_on | OrderSymbol() | ticket | bull2 | OrderType() | OrderProfit() | OrderSwap() | OrderCommission() | AccBalance_day | lot | Bid | Ask | slip | OrderProfit()";
             break;  
         case 11: 
str = "tim_M15 | Time[0] | last_liq_t1 | iBarShift(NULL,0,last_liq_t1,false) | m3_RSI(0, 2) | Period() | H1 | H3 | Hour() | H2 | t1 | t_M5_M15 | tmf_Diff";
             break;  
         case 12: 
str = "m3_RSI(PERIOD_M5, 2) | m3_RSI(PERIOD_H1, 2) | Period() | t1 | tim_M15 | tmf_Diff";
             break;  
         case 13: 
str = "Period() | last_liq_t1 | iBarShift(NULL,0,last_liq_t1,false) | d_HiLo | last_liq_pr | Ask | Bid | douHiLo | bull2 | tim_flt | TimeCurrent() | Period() | " +
   "ticket | t_night | OS9_tick | habull | FileIsExist(\"ATS-Ind_On-Off\\ATS-Ind5\"+str+\"_Sell.txt\", 0) | FileIsExist(\"ATS-Ind_On-Off\\ATS-Ind5\"+str+\"_Buy.txt\", 0) | bull_";
             break;  
         case 17: 
str = "OS6_tick | last_rct_ | Time[0] | Period() | bull_ | FileIsExist(\"ATS-Ind_On-Off\\ATS-Ind5\"+str+\"_Buy.txt\", 0)";
             break;  
         case 18: 
str = "Typ | tst | t | t1 | t2 | err1 | err2 | tmfr_n | Period() | tmfr_ | Time[0] | tmfr | tmf_Diff | Chart_M5";
             break;  
         case 20: 
str = "Period() | t1 | tim_M15 | Time[0]";
             break;  
         case 21: 
str = "Period() | chk_chartm5(10) | Chart_M5 | StringTrimLeft(ChartSymbol(Chart_M5)) | tmfr_ | tmfr_b | t1 | err | tmfr | tmf_Diff | err2 | " +
   "tim_Chart_M5b | TimeCurrent() | t5a_Bull_b | bull_ | t5b_Bull_b | FileIsExist(\"ATS-Ind_On-Off\\ATS-Ind5\"+str+\"_Buy.txt\", 0)";
             break;  
         case 22: 
str = "t_clo_ | t_clo | i | Bars | j | ticket | blue_time2 | Time[Bars-j-i] | OS1_tick | time_allow | blue_time3 | Time[0] | total2 | total3 | total3_ | op_case01 | op_case0";
             break;  
         case 23: 
str = "op_Liq_ | p | obj_pos0[p-1] | obj_bars[obj_pos0[p-1]] | Bars | bull | Bid | op_Liq_pr | bull | Ask | op_Liq_pr | op_Liq_sp | lastliq | OS6_tick | time_allow | lastliq_";
             break;  
         case 24: 
str = "obj_bar_cl | Bars | obj_pos[p-1] | obj_bars[obj_pos[p-1]] | ntot | total | Hour() | H1 | H3 | Minute() | H2 | ticket | FileIsExist(\"ATS-Int_On.txt\", FILE_COMMON) | OS2_tick | time_allow | total2_";
             break;  
         case 25: 
str = "t_opn | p | obj_pos0[p] | obj_bars[obj_pos0[p]] | Bars | t_clo | orge_time | Time[Bars-i+j] | i | Bars | t_orge | orge_time2 | Time[j] | j | ticket | Time[Bars-j-i+1] | OS3_tick | time_allow";
             break;  
         case 26: 
str = "op_case01 | t_clo | i | Bars | j | ticket | vilt_time2 | Time[Bars-j-i+1] | OS4_tick | time_allow | vilt_time3 | Time[0] | total2_ | total2";
             break;  
         case 27: 
str = "OS5_tick | Bars | p | obj_pos[p-1] | obj_bars[obj_pos[p-1]] | obj_Prices[prv_pos] | obj_pos[p-2] | obj_bars[obj_pos[p-2]] | iOpen(NULL,0,Bars-obj_bars[obj_pos[p-2]]) | " +
   "rate1c | rate2c | rate3c | rate4c | iClose(NULL,0,Bars-obj_bars[obj_pos[p-2]]) | total2_";
             break;  
         case 28: 
str = "bull_ | Ask | rLow | rect_H | iHigh(NULL, 0, 0) | iHigh(NULL, 0, K) | Bid | rHigh | iLow(NULL, 0, 0) | iLow(NULL, 0, K) | K";
             break;  
         case 29: 	// str == "-CHN" seulement,
str = "ATS_Time | TimeCurrent() | str | Period() | H2 | StringSubstr(TimeToStr(ATS_Time, TIME_DATE), 8, 2) | Day() | ticket";
             break;  
         case 30: 
str = "DayOfWeek() | H1 | H3 | t_night | Hour() | str | Minute() | Seconds() | bull | str | FileIsExist(\"ATS-Ind_On-Off\\ATS-Ind5\"+str+\"_Buy.txt\", 0) | bull | " +
   "FileIsExist(\"ATS-Ind_On-Off\\ATS-Ind5\"+str+\"_Sell.txt\", 0) | m3_RSI(PERIOD_H1, 2) | ticket | fl_Trade";
             break;  
         case 31: 
str = "DayOfWeek() | Hour() | Minute() | t_night | m3_RSI(0,3) | ticket";
             break;  
         case 32: 
str = "dval2 | dval3 | val3 | (val3 / dval2) | a_nb_tcksN | val5 | (val5 / dval3) | pass1 | co_a1 | co_a3 | co_a5 | c_reg1 | c_reg3 | c_reg5 | " +
   "last_ntr_pr | last_liq_pr | val1";
             break;  
         case 33: 
str = "ticket | MQLInfoInteger(MQL_TESTER) | (tst1=OrderSelect(ticket, SELECT_BY_TICKET)) | OrderType() | Ask | pr_val1 | a_tmpHiLo | (a_tmpHiLo/(a_tmpHiLo>200.0? 2: 1)) | " +
   "a_haOpen | a_haClose | val1 | (pr_val1 - val1) | Bid";
             break;  
         case 34: 
str = "ticket | MQLInfoInteger(MQL_TESTER) | tst1 | val1 | bb_val1 | (val1-bb_val1) | val_prec | OrderType() | Bid | " +
   "pr_val1 | OrderOpenPrice() | a_tmpHiLo | (a_tmpHiLo/(a_tmpHiLo>100.0? 2: 1)) | bb_val2 | (val1-bb_val2) | Ask";
             break;  
         case 35: 
str = "val1 | last_liq_p2 | (val1-last_liq_p2) | val_prec | last_liq_t22 | last_liq_t12 | (last_liq_t22-last_liq_t12) | (Period()*120) | " +
   "last_ntr_p2 | last_liq_p3 | (val1-last_liq_p3) | last_liq_t23 | last_liq_t13 | (last_liq_t23 - last_liq_t13) | last_ntr_p3 | obj_liqTyp_1 | last_ntr_pr";
             break;  
         case 36: 
str = "val1 | last_ntr_p2 | (val1-last_ntr_p2) | val_prec | last_liq_t22 | last_liq_t12 | (last_liq_t22-last_liq_t12) | (Period()*120) | " +
   "last_liq_p2 | last_ntr_p2 | (last_liq_p2-last_ntr_p2) | last_ntr_p3 | (val1-last_ntr_p3) | last_liq_t23 | last_liq_t13 | (last_liq_t23-last_liq_t13) | " +
   "last_liq_p3 | last_ntr_p3 | (last_liq_p3 - last_ntr_p3)";
             break;  
         case 37: 
str = "OrderCloseTime() | val1 | bb_val2 | (val1-bb_val2) | val_prec | OrderType() | Ask | OrderOpenPrice() | a_tmpHiLo | (a_tmpHiLo / (a_tmpHiLo > 200.0? 2: 1)) | " +
   "bb_val1 | (val1 - bb_val1) | Bid | pr_val1 | OrderOpenPrice() | last_liq_pr | (val1-last_liq_pr) | last_liq_t22 | last_liq_t12 | (last_liq_t22-last_liq_t12) | " +
   "(Period()*120) | last_liq_p2 | last_ntr_p2 | (last_liq_p2 - last_ntr_p2) | last_ntr_pr";
             break; }

//      copy_file_45(4, TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) +" "+Symbol()+","+stmfr+": " + str);
return(IntegerToString(i) + (i < 10? " ": "") + "-" + str); }

void CreateVLine(datetime Ltim, int Per) {
   ObjectCreate(0, "vert-" + IntegerToString(Ltim), OBJ_VLINE, 0, Ltim > 0? Ltim: Time[0], 0);
   ObjectSetInteger(0, "vert-" + IntegerToString(Ltim), OBJPROP_COLOR, Per==PERIOD_M5? clrLightSeaGreen: Per==PERIOD_M15? clrGreen: clrBlue);
   ObjectSetInteger(0, "vert-" + IntegerToString(Ltim), OBJPROP_STYLE, STYLE_DASH);
   ObjectSetInteger(0, "vert-" + IntegerToString(Ltim), OBJPROP_WIDTH, Per==PERIOD_M5? 1: 1); }

string line_read[][4];
void CSV_FILE_READ() { string filename="EA-write-file_List v-TmFr.csv";
   int row=0, col=0, handle=FileOpen(filename,FILE_CSV|FILE_READ,";");
   if(handle > 0) {
      while(True) { string temp=FileReadString(handle);
         if (FileIsEnding(handle)) break;
         line_read[row][col] = temp;
         if(FileIsLineEnding(handle)) {
            col = 0;       row ++; }
         else col ++; }
      FileClose(handle); }
   else Alert("*** (2) File "+filename+" not found, the last error is ", GetLastError() + " ***"); }

void List_vTmFr() { int row=0, col=0, v_bar=WindowFirstVisibleBar(), nLines=ArraySize(line_read)/4;
  double vScale=(WindowPriceMax()-WindowPriceMin())/(!WindowPriceMax()?1.154:WindowPriceMax())/1.154/(1.154-1.061);
//  CSV_FILE_READ();          FileDelete("EA-write-file_List v-TmFr.csv", 0);
  ObjectsDelete(0, "_v-TmFr", false, false);
  while(row < nLines) { while(v_bar > iBarShift(NULL, 0, line_read[row][col+2], false)) {
      CreateObText(StrToInteger(line_read[row-1][col+3])? StrToInteger(line_read[row-1][col+3]): -1, 
         WindowPriceMax()+ 50*vScale*Point, v_bar, 0, "_");          v_bar --; }          row ++; }
  while(v_bar >= 0) { CreateObText(Period(), WindowPriceMax()+ 50*vScale*Point, v_bar, 0, "_");       v_bar --; } }
#endif

/* if (pass1) for (i = 1; i < Bars; i ++) {
         ha1Close = (iOpen(NULL,0,Bars-i) + iClose(NULL,0,Bars-i) + iHigh(NULL,0,Bars-i) + iLow(NULL,0,Bars-i)) / 4;
         ha1Open = ((i==1 ? iOpen(NULL, 0, Bars-1) : haOpen) + ha1Close) / 2;
         haOpen = (ha1Open + ha1Close) / 2;
         ha1Open = (iOpen(NULL, 0, Bars-i) + iClose(NULL, 0, Bars-i)) / 2;
         if (i > Bars - 17) { DrawArrow_HA(ha1Open, Bars-i-1, 4, 1);    DrawArrow_HA(ha1Close, Bars-i-1, 4, 0); } }
  else { ha1Close = (iOpen(NULL,0,1) + iClose(NULL,0,1) + iHigh(NULL,0,1) + iLow(NULL,0,1)) / 4;
         ha1Open = (haOpen + ha1Close) / 2;        haOpen = (ha1Open + ha1Close) / 2; }
//         ha1Open = (iOpen(NULL, 0, 1) + iClose(NULL, 0, 1)) / 2; * /
//      DrawArrow_HA(ha1Open, 0, 4, 0);           DrawArrow_HA(ha1Close, 0, 4, 0);

-------------------------------------------

if (Symbol() == "HKG50" && (Hour() >= 6 || local.hour >= 5) && (Hour() < 8 || (Hour() == 8 && Minute() <= 5))) 
         Print("** -> TEST-0 (6-8) DrawArrow_OS n ",bull_," - ",ticket," ",t_night," ",TimeToStr(Time[0],TIME_MINUTES)," / ",
         (!(((Hour()>1 || (Hour() && Minute()>2)) && (Hour()<23 || Minute()<59)) || (Bid>0 && Ask>Bid && (Ask-Bid)*Point < 8)) &&
         (Period() > PERIOD_M15 || DayOfWeek() == 5) && ! time_allow)," ",
         !(((Hour()>1 || (Hour() && Minute()>2)) && (Hour()<23 || Minute()<59)) || (Bid>0 && Ask>Bid && (Ask-Bid)*Point < 8))," ",
         ((Period() > PERIOD_M15 || DayOfWeek() == 5) && ! time_allow)," ",(Period() > PERIOD_M15 || DayOfWeek() == 5)," ",OS5_tick," ",Hour()," **");
. . .
if (Symbol() == "HKG50" && (Hour() >= 6 || local.hour >= 5) && (Hour() < 8 || (Hour() == 8 && Minute() <= 5))) 
         Print("** -> TEST-4 (6-8) DrawArrow_OS n ",bull_," ",bull," ",ticket," ",t_night," ",TimeToStr(Time[0],TIME_MINUTES)," / ",
         (!(((Hour()>1 || (Hour() && Minute()>2)) && (Hour()<23 || Minute()<59)) || (Bid>0 && Ask>Bid && (Ask-Bid)*Point < 8)) &&
         (Period() > PERIOD_M15 || DayOfWeek() == 5) && ! time_allow)," ",
         !(((Hour()>1 || (Hour() && Minute()>2)) && (Hour()<23 || Minute()<59)) || (Bid>0 && Ask>Bid && (Ask-Bid)*Point < 8))," ",
         ((Period() > PERIOD_M15 || DayOfWeek() == 5) && ! time_allow)," ",(Period() > PERIOD_M15 || DayOfWeek() == 5)," ",OS5_tick," ",Hour()," **");

   MqlDateTime local;      TimeLocal(local);       string str="-"+StringSubstr(EnumToString(magic_nb), 0, 3);
   if (Symbol() == "HKG50") { if (local.hour == 5 && (! local.min || ChartPeriod(Chart_M5) != PERIOD_M5)) { int t = 0;
         if (! chk_chartm5(5)) Alert("*** ERROR Chart_M5 (chk) "+IntegerToString(ChartPeriod(Chart_M5))+" - "+IntegerToString(Chart_M5)+" ***");
         if (ChartPeriod(Chart_M5) != PERIOD_M5) { while(! ChartSetSymbolPeriod(Chart_M5, NULL, PERIOD_M5) && t < 17) { t ++;       Sleep(100); }
            Alert("** PASSAGE EN M5 pour Chart_M5 ! ("+IntegerToString(ChartPeriod(Chart_M5))+", t = "+IntegerToString(t)+", err. : "+IntegerToString(GetLastError())+") **");
            ChartSetInteger(Chart_M5, CHART_SCALE, 0, 4); } }
      if (Symbol() == "HKG50" && local.hour >= 5 && (local.hour < 7 || local.min < 15) && ((FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Buy.txt", 0) && ! bull_) ||
         (FileIsExist("ATS-Ind_On-Off\\ATS-Ind5"+str+"_Sell.txt", 0) && bull_))) DrawArrow_OS(12, LinePrice, BarNum, 0, ! bull_, 0);
      if (local.hour == 7 && (! local.min || ChartPeriod(Chart_M5) != PERIOD_H1)) { t = 0;
         if (! chk_chartm5(5)) Alert("*** ERROR Chart_M5 (chk) "+IntegerToString(ChartPeriod(Chart_M5))+" - "+IntegerToString(Chart_M5)+" ***");
         if (ChartPeriod(Chart_M5) != PERIOD_H1) { while(! ChartSetSymbolPeriod(Chart_M5, NULL, PERIOD_H1) && t < 17) { t ++;       Sleep(100); }
            Alert("** REPASSAGE EN H1 pour Chart_M5 ! ("+IntegerToString(ChartPeriod(Chart_M5))+", t = "+IntegerToString(t)+", err. : "+IntegerToString(GetLastError())+") **");
            ChartSetInteger(Chart_M5, CHART_SCALE, 0, 5); } } }
if (Symbol() == "HKG50" && (Hour() >= 5 || local.hour >= 4) && (Hour() < 8 || (Hour() == 8 && Minute() <= 5))) 
         Print("** -> TEST-5 (6-8) DrawArrow_OS n ",bull_," § ",ticket," ",t_night," ",TimeToStr(Time[0],TIME_MINUTES)," / ",
         (!(((Hour()>1 || (Hour() && Minute()>2)) && (Hour()<23 || Minute()<59)) || (Bid>0 && Ask>Bid && (Ask-Bid)*Point < 8)) &&
         (Period() > PERIOD_M15 || DayOfWeek() == 5) && ! time_allow)," ",! (((Hour()>1 || (Hour() && Minute()>2)) && (Hour()<23 || Minute()<59)) ||
         (Bid>0 && Ask>Bid && (Ask-Bid)*Point < 8))," ",((Period() > PERIOD_M15 || DayOfWeek() == 5) && ! time_allow)," ",(Period() > PERIOD_M15 ||
         DayOfWeek() == 5)," ",OS5_tick," ",Hour()," ",local.hour," **"); */
#ifdef scrShot2web

int    timeframe        = 0;
string ucphi="false: use timeframe";
bool   UseCustomPeriod  = true;
string tsmh="1:days, 2:hours, 3:minuts, 4:bars";
int    CustomPeriodMode = 3;  //mode - 1:days, 2:hours, 3:minuts, 4:bars
double CustomPeriod     = 15;
bool   TakeScreenShot  = true;
int    ScreenShotSizeX = 1240; //1280;
int    ScreenShotSizeY = 500;  //1024;
bool   Send2Ftp        = true; //TakeScreenShot has to be TRUE also ...
string ftpPath         = "rep_logs_ATS/logs_ATS/rep_test-2b";
bool   PrintToJournal  = true;
bool   ShowPopupAlerts = false;
bool   PlaySounds      = false;
string SoundFileName   = "news.wav";
string smode;

void ScrShot2web() {
 double vScale=(WindowPriceMax()-WindowPriceMin())/(!WindowPriceMax()?1.154:WindowPriceMax())/1.154/(1.154-1.061);         ObjectsPositions(vScale);
 stmp = "*** (2) " + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) + " - " + DoubleToStr(vScale, 2)  + " - " + DoubleToStr(WindowPriceMax(), Digits()) + " - " +
      DoubleToStr(WindowPriceMin(), Digits()) + " ***";              copy_file(stmp, 0);
 if (CustomPeriodMode > 4 || CustomPeriodMode <= 0) { Comment("ScreenShot2webspace EA v1.1, © 2014, fxdaytrader, http://ForexBaron.net -> TF: "+TFtoStr(timeframe)+
   " *** ERROR - CustomPeriodMode must be 1,2,3 or 4 ...");       return; }//simple errorchecking

 string ScreenShotFileName=StringConcatenate(Symbol(), "_", TFtoStr(timeframe), "_EA.gif"), PrevFileName;
 //StringConcatenate(Symbol(),"_",Period(),"_",TimeToStr(TimeCurrent(),TIME_DATE),"_",Hour(),".",Minute(),".gif");

 int res=1, timeout=5000;         char post[], result[];
 string URL="http://www.ecomclub.com/rep_logs_ATS/logs_ATS/rep_test-2b/", headers;
 if (ScreenShotFileName != (PrevFileName = StringConcatenate(Symbol(), "_M5_EA.gif")))
   res = WebRequest("GET", URL + "file_delete.php?it=" + PrevFileName, NULL, NULL, timeout, post, 0, result, headers);
 if (ScreenShotFileName != (PrevFileName = StringConcatenate(Symbol(), "_M15_EA.gif")))
   res = WebRequest("GET", URL + "file_delete.php?it=" + PrevFileName, NULL, NULL, timeout, post, 0, result, headers);
 if (ScreenShotFileName != (PrevFileName = StringConcatenate(Symbol(), "_H1_EA.gif")))
   res = WebRequest("GET", URL + "file_delete.php?it=" + PrevFileName, NULL, NULL, timeout, post, 0, result, headers);

 if ((! UseCustomPeriod && IsNewBar(timeframe)) || (UseCustomPeriod && IsTimeForAction(timeframe, CustomPeriodMode, CustomPeriod))) {
  if (TakeScreenShot) if (DoScreenShot(ScreenShotFileName, ScreenShotSizeX, ScreenShotSizeY)) if (ShowPopupAlerts) Alert("ScreenShot taken ...");
   else if (ShowPopupAlerts) Alert("Screenshot NOT taken"); 
   
  if (Send2Ftp && TakeScreenShot) if (Send2ftp(ScreenShotFileName, ftpPath)) {
   if (ShowPopupAlerts) Alert("File sent to FTP");       FileDelete(ScreenShotFileName, 0); }
   else if (ShowPopupAlerts) Alert("File NOT sent to FTP");
   
  if (! TakeScreenShot && ! Send2Ftp) if (ShowPopupAlerts) Alert("Time for action, ...");
  if (PlaySounds) PlaySound(SoundFileName);
 } }//if (IsNewBar(timeframe)) {

bool IsNewBar(int tmframe) {
 static int lasttime = 0;
 if (lasttime != iTime(Symbol(), tmframe, 0)) {
  lasttime = iTime(Symbol(), tmframe, 0);
  return(true); }
 return(false); }

bool DoScreenShot(string ScreenShotFileName,int SizeX,int SizeY) {
 if(! ChartScreenShot(NULL, ScreenShotFileName, SizeX, SizeY)) {
   if (PrintToJournal) Print("ScreenShot2webspace EA: Take WindowScreenShot - Error "+GetLastError());
   return(false); }
 return(true); }

bool Send2ftp(string ftpFileName, string ftp_Path) { ResetLastError();
 if (! SendFTP(ftpFileName, ftp_Path)) {
  if (PrintToJournal) Print("ScreenShot2webspace EA: Send2Ftp - Error "+GetLastError());
  return(false); }
 return(true); }

string TFtoStr(int period) {
 if (period == 0) period = Period();
 switch(period) {
  case 1     : return("M1");  break;
  case 5     : return("M5");  break;
  case 15    : return("M15"); break;
  case 30    : return("M30"); break;
  case 60    : return("H1");  break;
  case 240   : return("H4");  break;
  case 1440  : return("D1");  break;
  case 10080 : return("W1");  break;
  case 43200 : return("MN1"); break;
  default    : return(DoubleToStr(period,0));
 }
 return("UNKNOWN");
}//string TFtoStr(int period) {

bool IsTimeForAction(int tmframe,int CustmPeriodMode,double CustmPeriod) {
 double TimeForAction=0.0;
 static int lastActionTime=0;
 if (CustmPeriodMode == 1) TimeForAction = CustmPeriod * 86400;   //days
 if (CustmPeriodMode == 2) TimeForAction = CustmPeriod * 3600;    //hours
 if (CustmPeriodMode == 3) TimeForAction = CustmPeriod * 60;      //minutes
 if (CustmPeriodMode == 4) TimeForAction = CustmPeriod * tmframe * 60;  //bars     
   if ((TimeCurrent() - lastActionTime) >= TimeForAction) {
    lastActionTime = TimeCurrent();
    return(true); }//if (TimeCurrent() - ...
 return(false); }
#endif

double NormPrice(double Price,string Symb) { return NormalizeDouble(Price, MarketInfo(Symb, MODE_DIGITS)); }

double OffsetDollars, LimitDollars, Bal_Max=0.0, Equ_Max=0.0, E_Balance=0.0;        datetime Max_Time;
void TrailingStop(int mode,int OffsetPoints,string Symbs) { bool tst1, tst2, tst3=false, tst4=false;     string temp;
   int TS;           if (OffsetPoints == 50) TS = 30;       else TS = 70;              double E_Bal=0.0;
   if (mode == 2) { if (FileIsExist("MT4_TrailingStop_tx.txt", 0)) FileDelete("MT4_TrailingStop_tx.txt", 0);
      int rs1, rs2=-1, timeout=5000;      char post[], result[];     string URL="http://www.ecomclub.com/", headers;
      rs1 = WebRequest("GET", URL + "MT4_no_TrailingStop.txt", NULL, NULL, timeout, post, 0, result, headers);        Sleep(2 * PAUSE);
      if (rs1 < 0 || rs1 == 404) rs2 = WebRequest("GET", URL + "MT4_TrailingStop_tx.txt", NULL, NULL, timeout, post, 0, result, headers);
      if (rs2 > 0 && rs2 != 404) { int filehandle = FileOpen("MT4_TrailingStop_tx.txt", FILE_WRITE|FILE_BIN);
         if (filehandle != INVALID_HANDLE) { FileWriteArray (filehandle, result, 0, ArraySize(result));        FileClose(filehandle); } } }
   if (FileIsExist("MT4_TrailingStop_tx.txt", 0)) { filehandle = FileOpen("MT4_TrailingStop_tx.txt", FILE_TXT|FILE_READ);
      if (filehandle != INVALID_HANDLE) { TS = StrToInteger(FileReadString(filehandle));     Sleep(PAUSE);     FileClose(filehandle); } }

   for (int i=OrdersTotal() - 1; i >= 0; i--) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES) && (TS == 70 ||    // && OrderType() < 2 && OrderMagicNumber() == mgc_num
      (TS == 30 && (StringFind(Symbs, StringSubstr(OrderSymbol(), 0, 3)) >= 0 || StringFind(Symbs, StringSubstr(OrderSymbol(), 3, 3)) >= 0)))) { E_Bal += OrderProfit();
         double TP1=GlobalVariableGet(OrderSymbol() + StringSubstr(IntegerToString(OrderTicket()), StringLen(IntegerToString(OrderTicket())) - 4) + "_TP1");
         TP2 = GlobalVariableGet(OrderSymbol() + StringSubstr(IntegerToString(OrderTicket()), StringLen(IntegerToString(OrderTicket())) - 4) + "_TP2");
         if (TP2 > 0.0) { if (TP1 == 0.0) TP1 = (OrderOpenPrice() + TP2) / 2.0;
            double SLL=NormPrice(TP1 + (TP2 - TP1) * TS / 100 + (OrderType() == OP_BUY? -1: 1) * (15.0 * MarketInfo(OrderSymbol(),MODE_POINT)), OrderSymbol());      // if (TP1 > 0.0)
if (Hour() != tsh && (mode || (! mode && ! ((Minute() - tim_min) % 2) && Seconds() < 5)))
      Print("*** TrailingStop (0) " + OrderTicket()+" - "+OrderSymbol()+" - "+(OrderType()==OP_BUY? "OP_BUY": "OP_SELL")+" - LM: "+DoubleToStr(OrderOpenPrice(),MarketInfo(OrderSymbol(),
   MODE_DIGITS)) + " - SL: " + DoubleToStr(OrderStopLoss(), MarketInfo(OrderSymbol(),MODE_DIGITS)) + " - TP: " + DoubleToStr(OrderTakeProfit(), MarketInfo(OrderSymbol(), MODE_DIGITS)) +
   " - TP1: " + DoubleToStr(TP1, MarketInfo(OrderSymbol(),MODE_DIGITS)) + " - TP2: " + DoubleToStr(TP2, MarketInfo(OrderSymbol(),MODE_DIGITS)) + " - SLL: " + DoubleToStr(SLL,
   MarketInfo(OrderSymbol(), MODE_DIGITS)) + " - (1-global) " + (OrderType() == OP_BUY? NormPrice(MarketInfo(OrderSymbol(),MODE_BID) - OrderStopLoss(),OrderSymbol()) > NormPrice(OffsetPoints *
   MarketInfo(OrderSymbol(), MODE_POINT), OrderSymbol()) && (((tst1=0) && NormPrice(MarketInfo(OrderSymbol(),MODE_BID), OrderSymbol()) > TP1) || (tst2=(NormPrice(MarketInfo(OrderSymbol(),MODE_BID),
   OrderSymbol()) > TP1 + (TP2 - TP1) * TS / 100))): NormPrice(OrderStopLoss() - MarketInfo(OrderSymbol(),MODE_ASK),OrderSymbol()) > NormPrice(OffsetPoints * MarketInfo(OrderSymbol(),MODE_POINT),
   OrderSymbol()) && (((tst1=0) && NormPrice(MarketInfo(OrderSymbol(),MODE_ASK), OrderSymbol()) < TP1) || (tst2=(NormPrice(MarketInfo(OrderSymbol(),MODE_ASK),OrderSymbol()) < TP1+(TP2-TP1)* TS / 100)))) +
   " -1-g " + (OrderType() == OP_BUY? NormPrice(MarketInfo(OrderSymbol(),MODE_BID) - OrderStopLoss(),OrderSymbol()): NormPrice(OrderStopLoss() - MarketInfo(OrderSymbol(),MODE_ASK),OrderSymbol())) + " -1-d " +
   NormPrice(OffsetPoints * MarketInfo(OrderSymbol(),MODE_POINT),OrderSymbol()) + " - (tst2) " + (OrderType()==OP_BUY? (tst2=(NormPrice(MarketInfo(OrderSymbol(),MODE_BID),OrderSymbol()) > TP1+(TP2-TP1)*TS/100)):
   (tst2=(NormPrice(MarketInfo(OrderSymbol(),MODE_ASK), OrderSymbol()) < TP1 + (TP2 - TP1) * TS / 100))) + " -2-g " + (OrderType() == OP_BUY? NormPrice(MarketInfo(OrderSymbol(),MODE_BID), OrderSymbol()):
   NormPrice(MarketInfo(OrderSymbol(),MODE_ASK), OrderSymbol())) + " -2-d " + NormPrice(TP1 + (TP2 - TP1) * TS / 100, OrderSymbol()) + " -TS: " + IntegerToString(TS) + " ***");
if (Hour() != tsh || (OrderType()==OP_BUY && NormPrice(MarketInfo(OrderSymbol(),MODE_BID)-OrderStopLoss(),OrderSymbol()) > NormPrice(OffsetPoints*MarketInfo(OrderSymbol(),MODE_POINT),OrderSymbol()) &&
(((tst1=0) && NormPrice(MarketInfo(OrderSymbol(),MODE_BID), OrderSymbol()) > TP1) || (tst2=(NormPrice(MarketInfo(OrderSymbol(),MODE_BID), OrderSymbol()) > TP1 + (TP2 - TP1) * TS / 100)))) ||
(OrderType() == OP_SELL && NormPrice(OrderStopLoss() - MarketInfo(OrderSymbol(),MODE_ASK),OrderSymbol()) > NormPrice(OffsetPoints * MarketInfo(OrderSymbol(),MODE_POINT),OrderSymbol()) &&
(((tst1=0) && NormPrice(MarketInfo(OrderSymbol(),MODE_ASK), OrderSymbol()) < TP1) || (tst2=(NormPrice(MarketInfo(OrderSymbol(),MODE_ASK), OrderSymbol()) < TP1 + (TP2 - TP1) * TS / 100)))))
   if (mode || (! mode && ! ((Minute() - tim_min) % 2) && Seconds() < 5)) { tst4 = true;
      Print("*** TrailingStop (1) " + OrderTicket()+" - "+OrderSymbol()+" - "+(OrderType()==OP_BUY? "OP_BUY": "OP_SELL")+" - LM: "+DoubleToStr(OrderOpenPrice(),MarketInfo(OrderSymbol(),
   MODE_DIGITS)) + " - SL: " + DoubleToStr(OrderStopLoss(), MarketInfo(OrderSymbol(),MODE_DIGITS)) + " - TP: " + DoubleToStr(OrderTakeProfit(), MarketInfo(OrderSymbol(), MODE_DIGITS)) +
   " - TP1: " + DoubleToStr(TP1, MarketInfo(OrderSymbol(),MODE_DIGITS)) + " - TP2: " + DoubleToStr(TP2, MarketInfo(OrderSymbol(),MODE_DIGITS)) + " - SLL: " + DoubleToStr(SLL,
   MarketInfo(OrderSymbol(), MODE_DIGITS)) + " - (1-global) " + (OrderType() == OP_BUY? NormPrice(MarketInfo(OrderSymbol(),MODE_BID) - OrderStopLoss(),OrderSymbol()) > NormPrice(OffsetPoints *
   MarketInfo(OrderSymbol(), MODE_POINT), OrderSymbol()) && (((tst1=0) && NormPrice(MarketInfo(OrderSymbol(),MODE_BID), OrderSymbol()) > TP1) || (tst2=(NormPrice(MarketInfo(OrderSymbol(),MODE_BID),
   OrderSymbol()) > TP1 + (TP2 - TP1) * TS / 100))): NormPrice(OrderStopLoss() - MarketInfo(OrderSymbol(),MODE_ASK),OrderSymbol()) > NormPrice(OffsetPoints * MarketInfo(OrderSymbol(),MODE_POINT),
   OrderSymbol()) && (((tst1=0) && NormPrice(MarketInfo(OrderSymbol(),MODE_ASK), OrderSymbol()) < TP1) || (tst2=(NormPrice(MarketInfo(OrderSymbol(),MODE_ASK),OrderSymbol()) < TP1+(TP2-TP1)* TS / 100)))) +
   " -1-g " + (OrderType() == OP_BUY? NormPrice(MarketInfo(OrderSymbol(),MODE_BID) - OrderStopLoss(),OrderSymbol()): NormPrice(OrderStopLoss() - MarketInfo(OrderSymbol(),MODE_ASK),OrderSymbol())) + " -1-d " +
   NormPrice(OffsetPoints * MarketInfo(OrderSymbol(),MODE_POINT),OrderSymbol()) + " - (tst2) " + (OrderType()==OP_BUY? (tst2=(NormPrice(MarketInfo(OrderSymbol(),MODE_BID),OrderSymbol()) > TP1+(TP2-TP1)*TS/100)):
   (tst2=(NormPrice(MarketInfo(OrderSymbol(),MODE_ASK), OrderSymbol()) < TP1 + (TP2 - TP1) * TS / 100))) + " -2-g " + (OrderType() == OP_BUY? NormPrice(MarketInfo(OrderSymbol(),MODE_BID), OrderSymbol()):
   NormPrice(MarketInfo(OrderSymbol(),MODE_ASK), OrderSymbol())) + " -2-d " + NormPrice(TP1 + (TP2 - TP1) * TS / 100, OrderSymbol()) + " -TS: " + IntegerToString(TS) + " ***"); }
            if (OrderType() == OP_BUY && NormPrice(MarketInfo(OrderSymbol(),MODE_BID) - OrderStopLoss(),OrderSymbol()) > NormPrice(OffsetPoints * MarketInfo(OrderSymbol(),MODE_POINT),OrderSymbol()) &&
            (((tst1=0) && NormPrice(MarketInfo(OrderSymbol(),MODE_BID), OrderSymbol()) > TP1) || (tst2=(NormPrice(MarketInfo(OrderSymbol(),MODE_BID), OrderSymbol()) > TP1 + (TP2 - TP1) * TS / 100)))) {
Alert(temp=("*** TrailingStop (2) " + OrderTicket() + " - " + OrderSymbol() + " - OP: " + DoubleToStr(OrderOpenPrice(), MarketInfo(OrderSymbol(),MODE_DIGITS)) + " - SL: " +
   DoubleToStr(OrderStopLoss(), MarketInfo(OrderSymbol(),MODE_DIGITS)) + " - TP: " + DoubleToStr(OrderTakeProfit(), MarketInfo(OrderSymbol(),MODE_DIGITS)) + " - TP1: " +
   DoubleToStr(TP1, MarketInfo(OrderSymbol(),MODE_DIGITS)) + " - TP2: " + DoubleToStr(TP2, MarketInfo(OrderSymbol(),MODE_DIGITS)) + " - SLL: " +
   DoubleToStr(SLL, MarketInfo(OrderSymbol(),MODE_DIGITS)) + " - " + tst1 + " - " + tst2 + " ***"));
               if (TP2 > TP1 && OrderModify(OrderTicket(), OrderOpenPrice(), tst1 && ! tst2? NormPrice(MarketInfo(OrderSymbol(),MODE_BID) - OffsetPoints * MarketInfo(OrderSymbol(),MODE_POINT), OrderSymbol()):
                  tst2? (SL2=NormPrice(MarketInfo(OrderSymbol(),MODE_BID) - OffsetPoints * MarketInfo(OrderSymbol(),MODE_POINT),OrderSymbol())) > SLL? SL2: SLL:
                  OrderStopLoss(), OrderTakeProfit(),OrderExpiration(),clrNONE) == false) Alert("Cannot modify the SL due to: ", ErrorDescription(GetLastError()));
               else { tst3 = TRUE;#ifdef o_real        Mail_Alerts(1, temp + " - OFF: " + IntegerToString(OffsetPoints) + " - TS: " + IntegerToString(TS) + " ***", OrderTicket());#endif } }
            else if (OrderType() == OP_SELL && NormPrice(OrderStopLoss() - MarketInfo(OrderSymbol(),MODE_ASK),OrderSymbol()) > NormPrice(OffsetPoints * MarketInfo(OrderSymbol(),MODE_POINT),OrderSymbol()) &&
            (((tst1=0) && NormPrice(MarketInfo(OrderSymbol(),MODE_ASK), OrderSymbol()) < TP1) || (tst2=(NormPrice(MarketInfo(OrderSymbol(),MODE_ASK), OrderSymbol()) < TP1 + (TP2 - TP1) * TS / 100)))) {
Alert(temp=("*** TrailingStop (3) " + OrderTicket() + " - " + OrderSymbol() + " - OP: " + DoubleToStr(OrderOpenPrice(), MarketInfo(OrderSymbol(),MODE_DIGITS)) + " - SL: " +
   DoubleToStr(OrderStopLoss(), MarketInfo(OrderSymbol(),MODE_DIGITS)) + " - TP: " + DoubleToStr(OrderTakeProfit(), MarketInfo(OrderSymbol(),MODE_DIGITS)) + " - TP1: " +
   DoubleToStr(TP1, MarketInfo(OrderSymbol(),MODE_DIGITS)) + " - TP2: " + DoubleToStr(TP2, MarketInfo(OrderSymbol(),MODE_DIGITS)) + " - SLL: " +
   DoubleToStr(SLL, MarketInfo(OrderSymbol(),MODE_DIGITS)) + " - " + tst1 + " - " + tst2 + " ***"));
               if (TP2<TP1 && TP2>0.0 && OrderModify(OrderTicket(),OrderOpenPrice(), tst1 && ! tst2? NormPrice(MarketInfo(OrderSymbol(),MODE_ASK) + OffsetPoints * MarketInfo(OrderSymbol(),MODE_POINT),OrderSymbol()):
                  tst2? (SL2=NormPrice(MarketInfo(OrderSymbol(),MODE_ASK) + OffsetPoints * MarketInfo(OrderSymbol(),MODE_POINT),OrderSymbol())) < SLL? SL2: SLL:
                  OrderStopLoss(), OrderTakeProfit(),OrderExpiration(),clrNONE) == false) Alert("Cannot modify the SL due to: ", ErrorDescription(GetLastError()));
               else { tst3 = TRUE;#ifdef o_real        Mail_Alerts(1, temp + " - OFF: " + IntegerToString(OffsetPoints) + " - TS: " + IntegerToString(TS) + " ***", OrderTicket());#endif } } } } }

   LimitDollars = 210.0;         OffsetDollars = 30.0;      // StringFind(AccountCompany(), "Global") < 0? : 25.0;     (StringSubstr(AccountCompany(),0,5) == "Eight")
   if (E_Balance == 0.0 && GlobalVariableCheck("E_Bal_Max")) E_Balance = GlobalVariableGet("E_Bal_Max");
//      for (i = OrdersTotal() - 1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES) && OrderType() < 2) E_Bal += OrderProfit();
   if (! tst3) { LimitDollars *= AccountBalance() / 25000.00;           LimitDollars *= fmax(RM, 0.3) / 0.3;
      OffsetDollars *= AccountBalance() / 25000.00;                     OffsetDollars *= fmax(RM, 0.3) / 0.3;
//      if (E_Balance < AccountEquity() - AccountBalance()) E_Balance = AccountEquity() - AccountBalance();
      if (E_Balance < E_Bal) { E_Balance = E_Bal;           GlobalVariableSet("E_Bal_Max", E_Balance); }
if (Hour() != tsh && (mode || (! mode && ! ((Minute() - tim_min) % 2) && Seconds() < 5))) Print("*** TrailingStop (0) - E_Balance: "+DoubleToStr(E_Balance,2)+
   " - (1-global) " + (E_Balance - E_Bal > OffsetDollars && (tst2=(E_Balance > LimitDollars))) + " -1-g " + DoubleToStr(E_Balance - E_Bal, 2) +
   " -1-d " + DoubleToStr(OffsetDollars, 2) + " - (tst2) " + (E_Balance > LimitDollars) + " -2-g " + DoubleToStr(E_Balance, 2) + " -2-d " +
   DoubleToStr(LimitDollars, 2) + " -acc_f " + DoubleToStr(AccountBalance() / 25000.00, 1) + " -rm_f " + DoubleToStr(RM / 0.3, 1) + " ***");
if (Hour() != tsh || (E_Balance - E_Bal > OffsetDollars && (tst2=(E_Balance > LimitDollars))))
   if (mode || (! mode && ! ((Minute() - tim_min) % 2) && Seconds() < 5)) { tst4 = true;
      Print("*** TrailingStop (1) - E_Balance: " + DoubleToStr(E_Balance, 2) + " - (1-global) " +
   (E_Balance - E_Bal > OffsetDollars && (tst2=(E_Balance > LimitDollars))) + " -1-g " + DoubleToStr(E_Balance - E_Bal, 2) + " -1-d " +
   DoubleToStr(OffsetDollars, 2) + " - (tst2) " + (E_Balance > LimitDollars) + " -2-g " + DoubleToStr(E_Balance, 2) + " -2-d " +
   DoubleToStr(LimitDollars, 2) + " -acc_f " + DoubleToStr(AccountBalance() / 25000.00, 1) + " -rm_f " + DoubleToStr(RM / 0.3, 1) + " ***"); }
      if (E_Balance - E_Bal > OffsetDollars && (tst2=(E_Balance > LimitDollars))) {// Close_All_Trades(0);
Alert("*** TrailingStop (2) - E_Balance: " + DoubleToStr(E_Balance, 2) + " - " + DoubleToStr(E_Bal, 2) + " - " + tst2 + " ***"); } }
   if (tst4) tsh = Hour();
   if (mode) { if (GlobalVariableCheck("Equity_Max")) Equ_Max = GlobalVariableGet("Equity_Max");
      if (GlobalVariableCheck("Balance_Max")) Bal_Max = GlobalVariableGet("Balance_Max");
      if (AccountBalance() > Bal_Max) { GlobalVariableSet("Balance_Max", AccountBalance());
         GlobalVariableSet("Balance_Time", TimeCurrent());     Max_Time = TimeCurrent(); }
      if (AccountEquity() > Equ_Max) GlobalVariableSet("Equity_Max", AccountEquity()); }
}

double RM=0.33, TV;/*
double lot_define(double LM,double SL,string Symb) { double mlot,tlots=0,E_Bal=0,H_Bal=0,E_Bal2=0,H_Bal2=0;    // 15 trades perdant à $-83.33 (83.33 / 25000 = 0.33 / 100), 15 * 83.33 = 1249.95 = 5 % 25000
   if (! Max_Time && GlobalVariableCheck("Balance_Time")) Max_Time = GlobalVariableGet("Balance_Time");           string temp="";
   if (StringFind(AccountCompany(), "Global") < 0) for (int i=OrdersTotal() - 1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) tlots += OrderLots();
   for (i = OrdersTotal() - 1; i >= 0; i --) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES) && OrderMagicNumber() == mgc_num) E_Bal += OrderProfit();
   for (i=OrdersHistoryTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) && OrderMagicNumber() == mgc_num && Max_Time < OrderCloseTime()) H_Bal += OrderProfit();
   for (i = OrdersTotal() - 1; i >= 0; i --) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) E_Bal2 += OrderProfit();
   for (i=OrdersHistoryTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) && Max_Time < OrderCloseTime()) H_Bal2 += OrderProfit();
Print("******* lot_define() : " + DoubleToStr(LM, Digits()) + " - " + DoubleToStr(SL, Digits()) + " - " + DoubleToStr(E_Bal, 2) + " - " + DoubleToStr(MarketInfo(Symb, MODE_TICKVALUE), Digits()) + " *******");
   int cpt=0;        TV = MarketInfo(Symb, MODE_TICKVALUE);       while(TV == 0.0 && cpt < 7) { Sleep(PAUSE);     TV = MarketInfo(Symb, MODE_TICKVALUE);    cpt ++; }      cpt = 0;
   if (TV == 0.0) if (Digits() > 2) { string tmp=StringSubstr(Symb, 3, 3);    if (tmp != AccountCurrency()) { tmp += AccountCurrency();
            TV = MarketInfo(Symb_Check(tmp, LM), MODE_BID); }        else TV = 1.0; }        else TV = 1.0;       if (TV == 0.0) TV = 1.25;
   double TS=MarketInfo(Symb, MODE_TICKSIZE);         if (TS == 0.0) TS = Point();           while(TS == 0.0 && cpt < 7) { Sleep(PAUSE);     TS = Point();     cpt ++; }
   if (TS == 0.0) TS = Point();           mlot = TS > 0.0 && LM != SL ? floor((RM * AccountBalance()) / (fabs(LM - SL) / TS * TV)) / 100.0 : 0.0;
Alert("******* lot_define(1) : "+DoubleToStr(fabs(LM-SL),Digits())+" - "+DoubleToStr(RM*AccountBalance()/100,2)+" - "+DoubleToStr(fabs(LM-SL)/TS*TV,2)+" - "+DoubleToStr(mlot,2)+" - "+DoubleToStr(TV,Digits())+" *******");
   bool tst=true;       if ((E_Bal + (H_Bal < 0? H_Bal: 0.0)) < -0.02 * AccountBalance() || (E_Bal2 + (H_Bal2 < 0? H_Bal2: 0.0)) < -0.02 * AccountBalance()) {
Alert(temp=("******* lot_define(2) : " + DoubleToStr(LM, Digits()) + " - " + DoubleToStr(SL, Digits()) + " - " + DoubleToStr(E_Bal, 2) + " - " + DoubleToStr(H_Bal, Digits()) + " *******"));
      if ((E_Bal + (H_Bal < 0? H_Bal: 0.0)) < -0.02 * AccountBalance() && (E_Bal2 + (H_Bal2 < 0? H_Bal2: 0.0)) < -0.02 * AccountBalance() && StringFind(AccountCompany(), "Global") < 0) {
         tst = false;      mlot = 0.0; }     else  mlot /= 2.0; }       if (tst && mlot < 0.01) mlot = 0.01;      //   if (mlot > 1.5 * 25000.0 / AccountBalance()) mlot = 1.5 * 25000.0 / AccountBalance();
#ifdef o_real   if (temp != "") Mail_Alerts(3, temp + " - MT: " + TimeToStr(Max_Time, TIME_MINUTES) + " - AB: " + DoubleToStr(AccountBalance(), 2) + " ***", OrderTicket());   temp = "";#endif
   double req_margin=0.0;        cpt = 0;       while(req_margin == 0.0 && cpt < 7) { Sleep(PAUSE);     req_margin = MarketInfo(Symb, MODE_MARGINREQUIRED);     cpt ++; }
   double mlot_=mlot;      if (req_margin > 0.0) { if (mlot > AccountFreeMargin() / req_margin) { mlot = AccountFreeMargin() / req_margin;
         Print(temp=("******* lot_define(*) : " + DoubleToStr(mlot_, 2) + " - " + DoubleToStr(mlot, 2) + " *******")); } }       else { mlot = fmin(1.3, mlot);
         Print(temp=("******* lot_define(**) : " + DoubleToStr(mlot_, 2) + " - " + DoubleToStr(mlot, 2) + " *******")); }
      if (StringFind(AccountCompany(), "Global") < 0 && tlots + mlot > round(AccountBalance() / 1000) / 10) { mlot = round(AccountBalance() / 1000) / 10 - tlots;
         Print(temp=("******* lot_define(***) : " + DoubleToStr(mlot_, 2) + " - " + DoubleToStr(mlot, 2) + " *******")); }
#ifdef o_real   if (temp != "") Mail_Alerts(4, temp + " - RM: " + DoubleToStr(req_margin, 2) + " - AM: " + DoubleToStr(AccountFreeMargin(), 2) + " ***", OrderTicket());#endif
   return(mlot); } */
