/*#import "user32.dll"
  void keybd_event(int bVk,int bScan,int dwFlags,int dwExtraInfo);
#import */
enum options_signaux {Harmonic_Scanner=0, Harm_Scan_ATS=1, Harm_Scan_Cash_Power=2, Cash_Power_ATS=3};
extern options_signaux Option_Signaux = Cash_Power_ATS;
extern bool Order_TickStop = false;

double ExtOpenBuffer[], ExtCloseBuffer[]/*, ExtLowHighBuffer[], ExtHighLowBuffer[]*/, haOpen, haClose, haHigh, haLow, Exp_Ind[100][21], Exp_Ind2[3][3], Exp_Ind3[3][3],
   sup_trend, EPP_Max_, EPP_Min_, EPP_Max=0.0, EPP_Min=WindowPriceMax(), SL3, TP3, d_PBk, d_PBk2, d_EppCl=0.002, d_PBk3, R1, S1, maxProf=0.0, maxBal=0.0,
   TS=MarketInfo(Symbol(), MODE_TICKSIZE), TV=MarketInfo(Symbol(), MODE_TICKVALUE), TS_=MarketInfo("USDCHF", MODE_TICKSIZE), TV_=MarketInfo("USDCHF", MODE_TICKVALUE), TsTv;//=(TS*TV) / (TS_*TV_);
bool Buy, Sell, t_Rsi515=false, t_Adx=false, t_Send=false, t_exp, t_exp2, t_exp3, t_exp4, t_box, t_box2, t_box3=false, t_box4, t_CPClose=false, t_CPClos2=false,
   t_BH=false, t_BH2=false, t_P60=false, t_P60b=false, t_Time=false, t_Wt2=false, t_Wt3=false, tst4b=false, t_Pass, Bull, t_Sent=false, t_O240=false, st_bull, st_bull_,
   t_O24_=true, t_EppCl=false, Buy3, Sell3, t_EPcl=false, OP_ST, t_Star5, t_Adx2, t_Atr, t_Rsi, t_nSTO=false, OTS=Order_TickStop, t_CPEP2, t_CPRvrs=false, t_CPEP=false,
   t_CPEP3=false, t_ATSEP=false, t_ATSEP2=false, t_CPEPA, t_PBkx2, t_VtPBk, t_STCr1=false, t_STCr2=false, t_VtRtn, t_STCr3, t_MP, t_PBk1, t_PBk2, t_PBk3, t_MP2, t_PBk4,
   t_Rng1, t_Rng2, t_DrDn, t_DrUp, t_Nxt3=false, t_ST=true, t_STCr4=false;
int option=Option_Signaux, nBars=500, ticket=0, t_cpt, ticket_, maxcand, tim_min, tim_min_, tim_mn_b, t_BS, i_sec, tick_m, t_PBk, tick_st, tick_pb, tick_pb2, ticket_b, tickt2=0, i_ST=0, i_bar;
datetime CP_tims[6], tim_exp, tim_ex2, tim_box, tim_box2, t_BxClo=0, tim_BH, tim1, tmp_saved, tim4, tim5, tim6, EP_tim1, tim_OPST, tim_Star5, tim_Str5b, tim_Str5c, tim_Str5d,
   tim_PBk, CP_tim1, tim_Adx2, tim_Atr, tim_Rsi, tim_PBk2, tim_VtPBk, tim_STCrt, tim_VtRt, tim_STCr3, tim_MP, tim_MP2, tim_Rng, tim_STCr4, nxt_tim=0, tim_Hst;       string namBox;       //s[50][2];

int OnInit() {// EventSetTimer(60);
//   ChartSetSymbolPeriod(0, SymbolName(pos, false), 0);         pos ++;
//   FileMove("New_Symbol_OK_off.txt", FILE_COMMON, "New_Symbol_OK_on.txt", FILE_COMMON);

   maxcand = Period() < 30? Symbol() == "XAUUSD" || Symbol() == "USDJPY"? 500: Symbol() == "US30"? 3000: Symbol() == "FRA40"? 1000: 200:
      Symbol() == "US30"? 15000: Symbol() == "USOUSD" || Symbol() == "FRA40"? 5000: 1000;          t_Pass = false;
   ArrayResize(ExtOpenBuffer, nBars);     ArrayResize(ExtCloseBuffer, nBars);       HA_Buffers();
   if (! OrdersTotal()) tim1 = 0;         Exp_Inds();
   if (GlobalVariableCheck(Symbol() + "_tim_Balance")) tim_Hst = GlobalVariableGet(Symbol() + "_tim_Balance");
   else { tim_Hst = TimeCurrent();        GlobalVariableSet(Symbol() + "_tim_Balance", tim_Hst); }

   GlobalVariableSet("t-"+ Symbol() + "_M5_tim1_", 0);         GlobalVariableSet("t-"+ Symbol() + "_M5_tim1", 0);
   GlobalVariableSet("t-"+ Symbol() + "_M5_tim2_", 0);         GlobalVariableSet("t-"+ Symbol() + "_M5_tim2", 0);
   GlobalVariableSet("t-"+ Symbol() + "_M5_Buy", 0);           GlobalVariableSet("t-"+ Symbol() + "_M5_Sell", 0);
   GlobalVariableSet("t-"+ Symbol() + "_M5_Previous", 0);      GlobalVariableSet("t-"+ Symbol() + "_Order_240", 0);
   GlobalVariableSet("t-"+ Symbol() + "_H4_tim1", 0);          GlobalVariableSet("t-"+ Symbol() + "_H4_Buy", 0);
   GlobalVariableSet("t-"+ Symbol() + "_H4_tim2", 0);          GlobalVariableSet("t-"+ Symbol() + "_H4_Sell", 0);

   if (! TS_) TS_ = 0.00001;     if (! TV_) TV_ = 1.115;       TsTv = TV / TV_;
   return(INIT_SUCCEEDED); }

void OnTick() { double dProfit=f_Profit(0), dtmp;         if (dProfit > maxProf) maxProf = dProfit;
   if (GlobalVariableGet(Symbol() + "_Balance") > maxBal) maxBal = GlobalVariableGet(Symbol() + "_Balance");
   if (ticket && OrderSelect(ticket,SELECT_BY_TICKET) && ! OrderCloseTime()) { if ((GlobalVariableGet(Symbol() + "_Day_Balance") + OrderProfit()) <= -5.7 * TsTv ||
      OrderProfit() <= -5.7 * TsTv || dProfit <= -5.7 * TsTv) { Close_All_Trades(false);           nxt_tim = TimeCurrent() + (Period() == PERIOD_M5? 6: 3) * 12 * Period() * 60;
Alert("******* END! (1) : " + GlobalVariableGet(Symbol() + "_Day_Balance") + " - " + OrderProfit() + " - " + dProfit + " - " + f_Profit(0) + " - " + t_DrDn + " *******");
/*         GlobalVariableSet(Symbol() + "_Day_Balance", 0.0);*/          if (OrdersTotal() && f_Profit(0) <= -5.8 * TsTv) f_End_EA(0); }
      if (dProfit > 0.0) GlobalVariableSet(Symbol() + "_Day_Balance", 0.0);
      if (OrdersTotal() > 2 && dProfit > 2.5 * TsTv && maxProf - dProfit > 0.15 * maxProf) { Close_All_Trades(true);
         nxt_tim = TimeCurrent() + (Period() == PERIOD_M5? 6: 3) * 12 * Period() * 60;
Alert("******* END! (2) : " + GlobalVariableGet(Symbol() + "_Day_Balance") + " - " + maxProf + " - " + dProfit + " - " + f_Profit(0) + " - " + t_DrDn + " *******");
         GlobalVariableSet(Symbol() + "_Day_Balance", 0.0);          if (OrdersTotal()) f_End_EA(0);           maxProf = 0.0; }
      if (maxBal - GlobalVariableGet(Symbol() + "_Balance") - dProfit > 25.0 * TsTv && (iCustom(NULL, 0, "ind Profil Marché (de CMA).ex4", 0, 1) > 60.0 ||
      iCustom(NULL, 0, "ind Profil Marché (de CMA).ex4", 2, 1) > 65.0)) { Close_All_Trades(true);              CreateVLine(TimeCurrent(), Period(), false, 2);
         nxt_tim = TimeCurrent() + 24 * 3600;         while(TimeDayOfWeek(nxt_tim)) nxt_tim += 24 * 3600;//         CreateVLine(nxt_tim, Period(), true, 2);
Alert("******* END! (3) : " + GlobalVariableGet(Symbol() + "_Balance") + " - " + maxBal + " - " + dProfit + " - " + f_Profit(1) + " - " + TimeToStr(nxt_tim, TIME_DATE) + " *******");
         maxBal = GlobalVariableGet(Symbol() + "_Balance");       if (OrdersTotal()) f_End_EA(0);        maxProf = 0.0;       t_Nxt3 = true; }  //       keybd_event(19, 0, 0, 0);
      if (t_Nxt3 && TimeCurrent() >= nxt_tim) { CreateVLine(nxt_tim, Period(), true, 2);           t_Nxt3 = false; }
if (! (Minute() % 20)) Alert("******* TEST END! : " + GlobalVariableGet(Symbol() + "_Day_Balance") + " - " + GlobalVariableGet(Symbol() + "_Balance") + " - " +
   f_Profit(1) + " - " + maxBal + " - " + (maxBal - GlobalVariableGet(Symbol() + "_Balance")) + " - " + TimeToStr(nxt_tim, TIME_DATE) + " - " + t_Nxt3 + " - " +
   TsTv + " - " + (25.0 * TsTv) + " - " + TV_ + " - " + TV + " *******");
/*      if ((GlobalVariableGet(Symbol() + "_Day_Balance") + OrderProfit()) >= 12.0 * TsTv) { Close_All_Trades();             nxt_tim = TimeCurrent() + 24 * 3660; }
if (Day() == 5 && Hour() >= 16) Alert("******* Day_Balance! : " + GlobalVariableGet(Symbol() + "_Day_Balance") + " - " + OrderProfit() + " - " + t_DrDn + " *******");*/ }

   if (! (TimeCurrent() % 60)) { if ((Hour() == 23 || Hour() < 2) && ! (Minute() % 5)) { GlobalVariableSet(Symbol() + "_Day_Balance", 0.0);
         t_DrDn = false;         t_DrUp = false;         if (nxt_tim && ! t_Nxt3) nxt_tim = 0;           maxProf = 0.0; }
   if (t_DrDn && ! nxt_tim) nxt_tim = TimeCurrent() + (Period() == PERIOD_M5? 6: 3) * 12 * Period() * 60;
   if ((dtmp=f_Profit(1)) != GlobalVariableGet(Symbol() + "_Balance")) GlobalVariableSet(Symbol() + "_Balance", dtmp);
//   if (t_DrUp && ! nxt_tim) nxt_tim = TimeCurrent() + 24 * 3660;
/*   if (TimeCurrent() < nxt_tim) return; }

void OnDeinit(const int reason) {
   EventKillTimer(); }

void OnTimer() {*/ bool tst=false, tst5;       datetime CP_tim, EP_tim, EPc_tim;
   t_EppCl = t_EppCl? t_EppCl: ticket && OrderSelect(ticket,SELECT_BY_TICKET) && ! OrderCloseTime() && OrderProfit() > d_EppCl*OrderLots()*OrderOpenPrice() / TS * TV;
   if (ticket && OrderSelect(ticket,SELECT_BY_TICKET) && ! OrderCloseTime() && OrderProfit() > 0.5) {
      if (tick_m && OrderSelect(tick_m, SELECT_BY_TICKET) && OrderCloseTime()) tick_m = 0;         Entry_Points_Clo(); }
/*   for (int obj=0; obj < ObjectsTotal(); obj ++) { string name=ObjectName(obj);
      if (StringFind(name, "BCD") > 0 && ObjectType(name) == OBJ_TRIANGLE && pos)
         if (ObjectGet(name, OBJPROP_TIME3) > Time[10] && ObjectGet(name, OBJPROP_TIME3) - ObjectGet(name, OBJPROP_TIME1) > 15 * Period() * 60) {
            for (int ob=0; ob < ObjectsTotal() && ! tst; ob ++) { string name2=ObjectName(ob);
               tst = ObjectType(name2) == OBJ_RECTANGLE && ObjectGet(name2, OBJPROP_TIME2) > ObjectGet(name, OBJPROP_TIME3); }         if (! tst) {
Alert("**1* TRIANGLE - " + ChartSymbol() + " - " + SymbolName(pos - 1, false) + " - " + TimeToStr(ObjectGet(name, OBJPROP_TIME3), TIME_MINUTES) + " ***");   break; }
Alert("******* FIN - " + ChartSymbol() + " - " + SymbolName(pos-1, false) + " - " + TimeToStr(ObjectGet(name, OBJPROP_TIME3), TIME_MINUTES) + " *******");
            GlobalVariableSet("Current_Symbol", pos - (alt? 0: 1));        ExpertRemove();         EventKillTimer();      return; }            else
Alert("**2* TRIANGLE - " + ChartSymbol() + " - " + SymbolName(pos - 1, false) + " - " + TimeToStr(ObjectGet(name, OBJPROP_TIME3), TIME_MINUTES) + " ***"); } */

   if (option > 1) { CP_tim1 = CP_tims[1];      CP_tim = Get_Cash_Power(0);      CP_tims[5] = CP_tim;//         int k=0;          ArrayInitialize(CP_tims, 0);
//   ObjectsDelete(0, "EA_vert-");       ObjectsDelete(0, "EA_X-Line_");        ObjectsDelete(0, "EA_Chck2-");
      if (((CP_tim == Time[1] && ((Sell && iCustom(NULL, 0, "New folder\\Manual Trade Cashpower Lifetime.ex4", 0, 1) > 0.0) ||
      (Buy && iCustom(NULL, 0, "New folder\\Manual Trade Cashpower Lifetime.ex4", 1, 1) > 0.0))) || (CP_tims[0] != CP_tim && CP_tims[3] < Time[0])) && OrderSelect(ticket, SELECT_BY_TICKET) &&
      ((OrderType() && Buy) || (! OrderType() && Sell)) && ! OrderCloseTime() && ((OrderType() < 2 && mOrderClose(ticket, OrderLots(), Sell? Bid: Ask, 5, clrNONE))/* ||
         OrderDelete(ticket, clrNONE)*/)) { ticket_ = ticket;       ticket = 0;       CP_tim = 0;       EP_tim = 0;    if (t_CPClose) { t_CPClos2 = true;     Order_Send(Time[0], Sell); }
         t_BH2 = false;       t_box = true;        t_P60b = false;   //         t_P60 = false;
Alert("*** CashPower Close - " + TimeToStr(CP_tims[0], TIME_DATE|TIME_MINUTES) + " ***"); }
      if ((CP_tims[0] && CP_tim && CP_tims[0] != CP_tim) || t_exp) Exp_Inds();
      if (! ticket) EP_tim = Get_Entry_Point();             else  EPc_tim = Get_Entry_Point();                 if (ticket) ticket_b = ticket;

      if (ticket && OrderSelect(ticket, SELECT_BY_TICKET) && ! OrderCloseTime() && EPc_tim && ((OrderType() && Buy3) || (! OrderType() && Sell3))) {
         for (int obj=0; obj < ObjectsTotal() && ! tst; obj ++) { string name=ObjectName(obj);
            tst = StringFind(name, "BoxLine") > 0 && ObjectType(name) == OBJ_TREND && ObjectGet(name, OBJPROP_TIME2) > OrderOpenTime()/* &&
               ObjectGet(name, OBJPROP_TIME1) < OrderOpenTime()*/; }                               // * croisement de super-trend après BoxLine *
         t_EPcl = t_EPcl? t_EPcl: tst &&/* EPc_tim > ObjectGet(name, OBJPROP_TIME2) &&*/ ((iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 0) != 2147483647.0 &&
            Buy3 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 0) > ObjectGet(name, OBJPROP_PRICE1)) || (iCustom(NULL, 0, "super-trend_.ex4",
            10, 4.0, 0, 0) != 2147483647.0 && Sell3 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 0) < ObjectGet(name, OBJPROP_PRICE1))); }

      if (t_EPcl && ((Buy3 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 2) != 2147483647.0 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 2) > ObjectGet(name, OBJPROP_PRICE1) &&
      iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 1) != 2147483647.0 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 1) < ObjectGet(name, OBJPROP_PRICE1)) ||
      (Sell3 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 2) != 2147483647.0 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 2) < ObjectGet(name, OBJPROP_PRICE1) &&
      iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 1) != 2147483647.0 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 1) > ObjectGet(name, OBJPROP_PRICE1))) &&
      mOrderClose(ticket, OrderLots(), Sell? Ask: Bid, 5, clrNONE)) { ticket_ = ticket;       ticket = 0;          CP_tim = 0;          EP_tim = 0;
         t_box = true;           t_P60 = true;           t_EPcl = false;
Alert("*** Entry Point Pro Close - " + TimeToStr(EPc_tim, TIME_DATE|TIME_MINUTES) + " ***"); }                    int itmp=ticket;

      if ((! ticket || (OrderSelect(ticket, SELECT_BY_TICKET) && OrderCloseTime())) && (t_EppCl || t_EPcl)) { t_EppCl = false;         t_EPcl = false; }

      if (ticket && OrderSelect(ticket, SELECT_BY_TICKET) && OrderType() > 3 && ((tim_OPST && Time[0] > tim_OPST + 5 * Period() * 60) ||
      (OrderExpiration() && TimeCurrent() > OrderExpiration()))) { if (OrderDelete(ticket, clrNONE)) {}       tim_OPST = 0;
         tick_st = ticket;          ticket = 0;          CP_tim = 0;          EP_tim = 0;          t_nSTO = false; }
      if (! t_nSTO && ((OP_ST && tim_OPST && Time[0] > tim_OPST) || (t_PBk && tim_PBk && Time[0] > tim_PBk))) {
         if (t_PBk && ((Sell && (SL3 > iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 7, 0)) || SL3 < (iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 7, 0)) +
         iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, 12, 0))) / 2.0)) || (Buy && (SL3 < iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, 7, 0)) ||
         SL3 > (iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, 7, 0)) + iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 12, 0))) / 2.0))))
            SL3 = Sell? (iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 7, 0)) + iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, 12, 0))) / 2.0:
               (iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, 7, 0)) + iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 12, 0))) / 2.0;
         dtmp = Sell? iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, 12, 0)) - (iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 7, 0)) -
            iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, 12, 0))) / 2.0: iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 12, 0)) +
            (iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 12, 0)) - iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, 7, 0))) / 2.0;
         if (t_PBk) TP3 = Sell? fmin(TP3, dtmp): fmax(TP3, dtmp);
         ticket = mOrderSend(Symbol(), Sell + 4, 0.01, (Sell? iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, 12, 0)): iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 12, 0))) +
            (Sell? -1.0: 1.0) * 22 * Point(), 5, SL3, TP3, NULL, 0, Time[0] + 4 * Period() * 60, clrNONE);
         if (ticket > 0) { CP_tims[0] = CP_tim? CP_tim: Time[0];        CP_tims[4] = 0;      t_box = true;        OP_ST = false;
            tim1 = TimeCurrent();         t_Sent = true;       Bull = ! Sell;       if (t_box4) { t_box = false;        t_box4 = false; }
            if (Period() <= 60 && OrderSelect(ticket, SELECT_BY_TICKET) && fabs(OrderTakeProfit() - OrderOpenPrice()) < 0.0125 * OrderOpenPrice()) {
               dtmp = OrderOpenPrice() + (OrderTakeProfit() - OrderOpenPrice()) * 2.0;        if (OrderModify(ticket, OrderOpenPrice(), OrderStopLoss(), (TP3=(! t_PBk?
                  Sell? fmax(0.9875 * OrderOpenPrice(), dtmp): fmin(1.0125 * OrderOpenPrice(), dtmp): OrderTakeProfit())), 0, clrNONE)) CreateHLine(TP3, true, CP_tim); }
if (CP_tims[2] != CP_tim || itmp != ticket)                                         // attention : expiration retirée ici ^
Alert("*** mOrderSend(st1) OK! " + ticket + " - " + DoubleToStr(Sell? Bid: Ask, Digits()) + " - " + DoubleToStr(TP3, Digits()) + " - " +
   TimeToStr(CP_tim, TIME_DATE|TIME_MINUTES) + " ***");        t_nSTO = true;       if (t_PBk) tick_pb = ticket; }
         if (t_PBk4) { dtmp = (! Sell? iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, 12, 0)): iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 12, 0))) + (! Sell? -1.0: 1.0) * 22 * Point();
            tick_pb2 = mOrderSend(Symbol(), (! Sell) + 4, 0.01, dtmp, 5, (! Sell? iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 1): iCustom(NULL, 0,
               "super-trend_.ex4", 10, 4.0, 0, 1)), dtmp + (! Sell? -1.0: 1.0) * fabs(dtmp - (! Sell? iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 1):
               iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 1))), NULL, 0, Time[0] + 4 * Period() * 60, clrNONE);
if (tick_pb2 > 0) Alert("*** mOrderSend(st1b) OK! " + tick_pb2 + " - " + DoubleToStr(dtmp, Digits()) + " - " + TimeToStr(CP_tim, TIME_DATE|TIME_MINUTES) + " ***"); } }
      if (ticket && OrderSelect(ticket, SELECT_BY_TICKET) && OrderProfit() && ! OrderCloseTime() && tick_pb2 && OrderDelete(tick_pb2, clrNONE)) tick_pb2 = 0;
      if (tick_pb2 && OrderSelect(tick_pb2, SELECT_BY_TICKET) && OrderProfit() && ! OrderCloseTime() && ticket && OrderDelete(ticket, clrNONE)) {
         tick_pb = tick_pb2;           tick_pb2 = 0;           ticket = tick_pb;          Sell = OrderType();           Bull = ! Sell; }
      if (! t_PBk4 && tick_pb && OrderSelect(tick_pb, SELECT_BY_TICKET) && OrderProfit() && ! OrderCloseTime() && tick_pb != ticket) { d_PBk2 = OrderOpenPrice();
         if (ticket && OrderSelect(ticket, SELECT_BY_TICKET) && ((Sell && OrderStopLoss() > d_PBk2) || (Buy && OrderStopLoss() < d_PBk2)) &&
         OrderModify(ticket, OrderOpenPrice(), d_PBk2, OrderTakeProfit(), 0, clrNONE)) tick_pb = 0; }
      if (tim_OPST && (! ticket || ! OrdersTotal())) { tim_OPST = 0;        OP_ST = false;          t_nSTO = false;
         if (ticket && OrderSelect(ticket, SELECT_BY_TICKET) && OrderType() < 2) { ticket_ = ticket;        CP_tim = 0;       EP_tim = 0; }     ticket = 0; }

      if (t_PBk4 && tick_pb && OrderSelect(tick_pb, SELECT_BY_TICKET) && OrderProfit() && ! OrderCloseTime() && ((Sell &&
      iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 1) != 2147483647.0 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 1) >
      (Sell? Bid: Ask)) || (! Sell && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 1) && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 1) <
      (Sell? Bid: Ask))) && NormPrice(OrderStopLoss(), Symbol()) != NormPrice(Sell? iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 1) + 22 * Point():
      iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 1) - 22 * Point(), Symbol()) && OrderModify(ticket, OrderOpenPrice(), Sell? iCustom(NULL, 0,
      "super-trend_.ex4", 10, 4.0, 1, 1) + 22 * Point(): iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 1) - 22 * Point(), f_wBars(OrderOpenTime(),
      TimeCurrent()) > 24? Sell? iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, 24, 0)) + 22 * Point(): iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 24, 0))
      - 22 * Point(): OrderTakeProfit(), 0, clrNONE)) {}
      if (t_PBk4 && tick_pb && OrderSelect(tick_pb, SELECT_BY_TICKET) && OrderProfit() && ! OrderCloseTime() && ((Sell &&
      iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 1) && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 1) < (Sell? Bid: Ask)) ||
      (! Sell && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 1) != 2147483647.0 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 1) >
      (Sell? Bid: Ask))) && mOrderClose(tick_pb, OrderLots(), OrderType()? Ask: Bid, 15, clrNONE)) { tick_pb = 0;        ticket_ = ticket;       ticket = 0;       t_PBk4 = false; }
      if (t_PBk4 && f_wBars(tim_Str5c, TimeCurrent()) > 12) t_PBk4 = false;

      if ((t_PBk == 2 && Ask > d_PBk - 22 * Point()) || (t_PBk == 1 && Bid < d_PBk + 22 * Point())) { Sell = t_PBk == 2;      Buy = t_PBk == 1;
//         if (ticket && OrderSelect(ticket, SELECT_BY_TICKET) && OrderType() > 3 && OrderDelete(ticket, clrNONE)) {}
         ticket = mOrderSend(Symbol(), Sell + 4, 0.01, (Sell? Bid: Ask) + (Sell? -1.0: 1.0) * 22 * Point(), 5, (Sell? Bid * 1.01: Ask * 0.99),
            (Sell? Ask * 0.9855: Bid * 1.0145), NULL, 0, Time[0] + 4 * Period() * 60, clrNONE);
         if (ticket > 0) { CP_tims[0] = CP_tim? CP_tim: Time[0];        CP_tims[4] = 0;      t_box = true;        t_PBk = 0;
            tim1 = TimeCurrent();         t_Sent = true;       Bull = ! Sell;
if (CP_tims[2] != CP_tim || itmp != ticket)
Alert("*** mOrderSend(st2) OK! " + ticket + " - " + DoubleToStr(Sell? Bid: Ask, Digits()) + " - " + DoubleToStr(TP3, Digits()) + " - " +
   TimeToStr(CP_tim, TIME_DATE|TIME_MINUTES) + " ***");        t_nSTO = true; } }
      if (t_PBk && (f_wBars(tim_Str5b, TimeCurrent()) > 5 || (ticket && OrderSelect(ticket, SELECT_BY_TICKET) && OrderType() < 2))) t_PBk = 0;

      if (iCustom(NULL, 0, "ind Signal 5 + (de CMA).ex4", 1, 1) > iCustom(NULL, 0, "ind Signal 5 + (de CMA).ex4", 2, 1) * 1.25 &&
      iCustom(NULL, 0, "ind Signal 5 + (de CMA).ex4", 1, 1) <= iCustom(NULL, 0, "ind Signal 5 + (de CMA).ex4", 2, 1) * 3.0) tim_Star5 = TimeCurrent();
      if (iCustom(NULL, 0, "ind Signal 5 + (de CMA).ex4", 1, 1) > iCustom(NULL, 0, "ind Signal 5 + (de CMA).ex4", 2, 1)) tim_Str5c = TimeCurrent();
      if (iCustom(NULL, 0, "ind Signal 5 + (de CMA).ex4", 1, 1) > iCustom(NULL, 0, "ind Signal 5 + (de CMA).ex4", 2, 1) * 1.25) tim_Str5d = TimeCurrent();
      if (iCustom(NULL, 0, "ind Signal 5 + (de CMA).ex4", 1, 1) > iCustom(NULL, 0, "ind Signal 5 + (de CMA).ex4", 2, 1) * 3.0 && f_wBars(tim_Star5, TimeCurrent()) > 50) {
         t_Star5 = true;         tim_Str5b = TimeCurrent(); }              if (t_Star5 && f_wBars(tim_Str5b, TimeCurrent()) > 5) t_Star5 = false;
      t_Adx2 = iCustom(NULL, 0, "New folder\\ADX.ex4", 14, 0, 1) > 24.0 && iCustom(NULL, 0, "New folder\\ADX.ex4", 14, 1, 1) > 24.0 &&
         iCustom(NULL, 0, "New folder\\ADX.ex4", 14, 2, 1) > 24.0;
      t_Atr = iCustom(NULL, 0, "ATR.ex4", 14, 0, 1) > (iCustom(NULL, 0, "ATR.ex4", 14, 0, 2) + iCustom(NULL, 0, "ATR.ex4", 14, 0, 3) +
         iCustom(NULL, 0, "ATR.ex4", 14, 0, 4) + iCustom(NULL, 0, "ATR.ex4", 14, 0, 5) + iCustom(NULL, 0, "ATR.ex4", 14, 0, 6)) / 5.0 * 1.3;
      t_Rsi = iCustom(NULL, 0, "RSI.ex4", 0, 1) > 69.0 || iCustom(NULL, 0, "RSI.ex4", 0, 1) < 31.0;
      if (t_Adx2) tim_Adx2 = TimeCurrent();              if (t_Atr) tim_Atr = TimeCurrent();             if (t_Rsi) tim_Rsi = TimeCurrent();
/* if (Hour() == 21) Alert("******* " + (iCustom(NULL, 0, "ind Signal 5 + (de CMA).ex4", 1, 1) >               // * 04-05-2022 : 21h 00 *
   iCustom(NULL, 0, "ind Signal 5 + (de CMA).ex4", 2, 1) * 3.0) + " - " + DoubleToStr(iCustom(NULL, 0, "ind Signal 5 + (de CMA).ex4", 0, 1), Digits()) + " - " +   
   DoubleToStr(iCustom(NULL, 0, "ind Signal 5 + (de CMA).ex4", 1, 1), Digits()) + " - " + DoubleToStr(iCustom(NULL, 0, "ind Signal 5 + (de CMA).ex4", 2, 1), Digits()) + " - " +
   t_Star5 + " - " + DoubleToStr(iCustom(NULL, 0, "New folder\\ADX.ex4", 0, 1), 2) + " - " + DoubleToStr(iCustom(NULL, 0, "New folder\\ADX.ex4", 1, 1), 2) + " - " +
   DoubleToStr(iCustom(NULL, 0, "New folder\\ADX.ex4", 2, 1), 2) + " - " + t_Adx2 + " - " + DoubleToStr(iCustom(NULL, 0, "ATR.ex4", 14, 0, 1), Digits()) + " - " +
   DoubleToStr((iCustom(NULL, 0, "ATR.ex4", 14, 0, 2) + iCustom(NULL, 0, "ATR.ex4", 14, 0, 3) +
   iCustom(NULL, 0, "ATR.ex4", 14, 0, 4) + iCustom(NULL, 0, "ATR.ex4", 14, 0, 5) + iCustom(NULL, 0, "ATR.ex4", 14, 0, 6)) / 5.0, Digits()) + " - " + t_Atr + " - " +
   DoubleToStr(iCustom(NULL, 0, "RSI.ex4", 0, 1), 2) + " - " + t_Rsi + " - " + TimeToStr(tim_Star5, TIME_MINUTES) + " - " + f_wBars(tim_Star5, TimeCurrent()) + " *******"); */

      if (t_CPRvrs=(f_wBars(CP_tim1, CP_tim) < 20 && ((iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 2) != 2147483647.0 &&
      Buy && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 2) > iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)) &&
      iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 1) != 2147483647.0 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 1) <
      iClose(NULL, 0, iBarShift(NULL, 0, CP_tim))) || (iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 2) != 2147483647.0 &&
      Sell && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 2) < iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)) &&
      iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 1) != 2147483647.0 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 1) >
      iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)))))) { t_box = true;         t_P60 = true; }//       CreateVLine(Time[0], Period(), Buy, 0);
      if (! ticket && d_EppCl == 0.001) d_EppCl = 0.002;                      // * 04-05-2022 : 2 x AM/PM *
/* if (Hour() == 16 && Minute() < 40) Alert("******* " + f_wBars(CP_tim1, CP_tim) + " - " + iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 2) + " - " +
   iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 1) + " - " + TimeToStr(CP_tim1, TIME_MINUTES)  + " - " + TimeToStr(CP_tim, TIME_MINUTES) + " - " +
   iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)) + " - " + t_CPRvrs + " *******"); */

//      if (CP_tim == Time[1] && CP_tim1 != CP_tim && EP_tim) EP_tim = 0;
      if (t_CPEP=(CP_tim && ((EP_tim && EP_tim > CP_tim) || (EPc_tim && EPc_tim > CP_tim)) && ((t_CPClos2 && ticket_ && OrderSelect(ticket_, SELECT_BY_TICKET) && OrderCloseTime() &&
      f_wBars(OrderCloseTime(), TimeCurrent()) < 7) || f_wBars(CP_tim, TimeCurrent()) < 7))) { t_box = true;      t_P60 = true;//        CreateVLine(Time[0], Period(), Buy, 0);
         if (EPc_tim &&/* t_CPEP3 &&*/ ticket && OrderSelect(ticket, SELECT_BY_TICKET) && ((Buy3 && OrderType()) || (Sell3 && ! OrderType()))) {
            t_Sent = ! mOrderClose(ticket, OrderLots(), OrderType()? Ask: Bid, 15, clrNONE);
            if (! t_Sent) { tst4b = false;         tick_m = 0;       ticket = 0;       tim1 = 0;      t_EppCl = false;        t_CPEP3 = false; } }
         Sell = Sell3;        Buy = Buy3; }              t_CPEP2 = t_CPRvrs || t_CPEP;                // * 20-05-2022 : 10h à 17h *
/* if (Hour() == 10 || Hour() == 13) Alert("******* " + TimeToStr(EP_tim, TIME_MINUTES)  + " - " + TimeToStr(EPc_tim, TIME_MINUTES)  + " - " + TimeToStr(CP_tim, TIME_MINUTES) + " - " +
   f_wBars(CP_tim, TimeCurrent()) + " - " + Buy + " - " + Sell + " - " + Buy3 + " - " + Sell3 + " *******"); */

      if (t_CPEP3 || (f_wBars(CP_tim, EP_tim1) < 7 && CP_tim < EP_tim1)) { tst = false;
         for (obj = 0; obj < ObjectsTotal() && ! tst; obj ++) { name = ObjectName(obj);
            tst = ((Buy3 && (name == "RSLinesS1" || StringFind(name, "liquid_buy") > 0)) || (Sell3 && (name == "RSLinesR1" ||
               StringFind(name, "liquid_sell") > 0))) && ObjectType(name) == OBJ_TREND && ObjectGet(name, OBJPROP_TIME1) > EP_tim1 &&
               ((Buy3 && ObjectGet(name, OBJPROP_PRICE1) < iClose(NULL, 0, iBarShift(NULL, 0, EP_tim1))) ||
               (Sell3 && ObjectGet(name, OBJPROP_PRICE1) > iClose(NULL, 0, iBarShift(NULL, 0, EP_tim1)))); }
         if (tst && ticket && OrderSelect(ticket, SELECT_BY_TICKET) && ((Buy3 && ! OrderType()) || (Sell3 && OrderType())) &&    // * 21-04-2022 : 15h 45 *
//         ((OrderType() && OrderStopLoss() > NormPrice(ObjectGet(name, OBJPROP_PRICE1) + (Sell3? 1.0: -1.0) * 22 * Point(), OrderSymbol())) ||
//         (! OrderType() && OrderStopLoss() < NormPrice(ObjectGet(name, OBJPROP_PRICE1) + (Sell3? 1.0: -1.0) * 22 * Point(), OrderSymbol()))) &&
         OrderModify(ticket, OrderOpenPrice(), ObjectGet(name, OBJPROP_PRICE1) + (Sell3? 1.0: -1.0) * 22 * Point(), OrderTakeProfit(), 0, clrNONE)) {} }
//if (Hour() == 16) Alert("******* " + TimeToStr(CP_tim, TIME_MINUTES)  + " - " + TimeToStr(tim_Star5, TIME_MINUTES) + " - " + TimeToStr(tim_Str5b, TIME_MINUTES) + " - " +
//   TimeToStr(tim_Str5c, TIME_MINUTES) + " - " + TimeToStr(tim_box, TIME_MINUTES) + " - " + t_box3 + " - " + iMA(NULL, 0, 100, 0, MODE_EMA, PRICE_CLOSE, 0) + " *******");

      if (tim_box2 && CP_tim && tim_Str5c > CP_tim && tim_Str5c < tim_box2 && ticket && OrderSelect(ticket, SELECT_BY_TICKET) && ! OrderCloseTime() &&
      ((Sell && OrderType()) || (Buy && ! OrderType())) && ((Sell && OrderOpenPrice() < iClose(NULL, 0, iBarShift(NULL, 0, CP_tim))) ||
      (Buy && OrderOpenPrice() > iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)))) &&
//      ((OrderType() && OrderStopLoss() > NormPrice(iMA(NULL, 0, 100, 0, MODE_EMA, PRICE_CLOSE, 0) + (Sell? 1.0: -1.0) * 22 * Point(), OrderSymbol())) ||
//      (! OrderType() && OrderStopLoss() < NormPrice(iMA(NULL, 0, 100, 0, MODE_EMA, PRICE_CLOSE, 0) + (Sell? 1.0: -1.0) * 22 * Point(), OrderSymbol()))) &&
      OrderModify(ticket, OrderOpenPrice(), iMA(NULL, 0, 100, 0, MODE_EMA, PRICE_CLOSE, 0) + (Sell? 1.0: -1.0) * 22 * Point(), OrderTakeProfit(), 0, clrNONE)) {
         tst = false;         for (obj = 0; obj < ObjectsTotal() && ! tst; obj ++) { name = ObjectName(obj);                  // * 25-04-2022 : 16h 40 *
            tst = ((Sell && (name == "RSLinesS1" || StringFind(name, "liquid_buy") > 0)) || (Buy && (name == "RSLinesR1" ||
               StringFind(name, "liquid_sell") > 0))) && ObjectType(name) == OBJ_TREND && ObjectGet(name, OBJPROP_TIME1) > tim_box2; }
         if (tst &&/* ((OrderType() && OrderStopLoss() > NormPrice(iMA(NULL, 0, 100, 0, MODE_EMA, PRICE_CLOSE, 0) / 2.0 + (Sell3? 1.0: -1.0) * 22 * Point(), OrderSymbol())) ||
         (! OrderType() && OrderStopLoss() < NormPrice(iMA(NULL, 0, 100, 0, MODE_EMA, PRICE_CLOSE, 0) / 2.0 + (Sell3? 1.0: -1.0) * 22 * Point(), OrderSymbol()))) &&*/
         OrderModify(ticket, OrderOpenPrice(), (OrderOpenPrice() + iMA(NULL,0,100,0,MODE_EMA,PRICE_CLOSE,0))/2.0 + (Sell3? 1.0: -1.0) * 22 * Point(), OrderTakeProfit(), 0, clrNONE)) {} }

//if (Hour() >= 20) Alert("******* " + f_wBars(tim_Str5b, TimeCurrent())  + " - " + f_wBars(tim_Adx2, TimeCurrent()) + " - " +
//   f_wBars(tim_Atr, TimeCurrent()) + " - " + f_wBars(tim_Rsi, TimeCurrent()) + " - " + t_Star5 + " - " + t_Adx2 + " - " + t_Atr + " - " + t_Rsi + " *******");
      if (t_ATSEP2 && ! OrdersTotal() && ((Sell && Ask > iCustom(NULL, 0, "Parabolic.ex4", 0, 1)) || (Buy && Bid < iCustom(NULL, 0, "Parabolic.ex4", 0, 1))))
         t_ATSEP2 = false;             else if (! OrdersTotal() && t_ATSEP) { t_ATSEP2 = t_ATSEP;
         if (iCustom(NULL, 0, "RSI.ex4", 0, 1) > 65.0 || iCustom(NULL, 0, "RSI.ex4", 0, 1) < 35.0) t_ATSEP = false; }
      if (t_ATSEP2 && ticket && iCustom(NULL, 0, "New folder\\ADX.ex4", 14, 0, 1) > 45.0 && OrderSelect(ticket, SELECT_BY_TICKET) &&
      ((Sell && OrderStopLoss() > iCustom(NULL, 0, "Parabolic.ex4", 0, 1)) || (Buy && OrderStopLoss() < iCustom(NULL, 0, "Parabolic.ex4", 0, 1))) &&
      OrderModify(ticket, OrderOpenPrice(), iCustom(NULL, 0, "Parabolic.ex4", 0, 1), OrderTakeProfit(), 0, clrNONE)) {}
      if ((EP_tim || EPc_tim) && f_wBars(tim_Str5b, TimeCurrent()) > 7 && f_wBars(tim_Adx2, TimeCurrent()) > 7 && f_wBars(tim_Atr, TimeCurrent()) > 7 &&
      f_wBars(tim_Rsi, TimeCurrent()) > 7) { for (obj = 0; obj < ObjectsTotal() && ! t_ATSEP; obj ++) { name = ObjectName(obj);
            t_ATSEP = ((Buy3 && (name == "RSLinesS1" || StringFind(name, "liquid_buy") > 0)) || (Sell3 &&            // ou neutral
               (name == "RSLinesR1" || StringFind(name, "liquid_sell") > 0))) && ObjectType(name) == OBJ_TREND &&
               (fabs(f_wBars(ObjectGet(name, OBJPROP_TIME1), EP_tim)) < 3 || fabs(f_wBars(ObjectGet(name, OBJPROP_TIME1), EPc_tim)) < 3); }
/*         if (t_ATSEP) { if (ticket && OrderSelect(ticket, SELECT_BY_TICKET) && ((Buy3 && OrderType()) || (Sell3 && ! OrderType()))) {
            t_Sent = ! mOrderClose(ticket, 0.01, OrderType()? Ask: Bid, 15, clrNONE);
            if (! t_Sent) { if (ticket && OrderSelect(ticket, SELECT_BY_TICKET) && OrderOpenTime() >= CP_tim) CP_tim = 0;
               tst4b = false;          tick_m = 0;       ticket = 0;       tim1 = 0;         t_EppCl = false;          t_CPEP3 = false; } }
         Sell = Sell3;        Buy = Buy3; } */ }            t_CPEPA = t_CPEP2 || t_ATSEP || t_ATSEP2;                // * 18-05-2022 : 9h 15 *

      if ((iCustom(NULL, 0, "Parabolic.ex4", 0, 1) > iClose(NULL, 0, 1) && iCustom(NULL, 0, "Parabolic.ex4", 0, 2) < iClose(NULL, 0, 2)) ||
      (iCustom(NULL, 0, "Parabolic.ex4", 0, 2) > iClose(NULL, 0, 2) && iCustom(NULL, 0, "Parabolic.ex4", 0, 1) < iClose(NULL, 0, 1))) {
         tim_PBk2 = TimeCurrent();           d_PBk3 = iCustom(NULL, 0, "Parabolic.ex4", 0, 2); }
      if (f_wBars(tim_PBk2, TimeCurrent()) > 8 && ticket && OrderSelect(ticket, SELECT_BY_TICKET) &&
//    > 12 = StrategyTester (9-tst6b).htm | > 8 = StrategyTester (9-tst6c).htm     <- revoir le 13-05, 19h à 20h
      ((Sell && OrderStopLoss() > iCustom(NULL, 0, "Parabolic.ex4", 0, 1)) || (Buy && OrderStopLoss() < iCustom(NULL, 0, "Parabolic.ex4", 0, 1))) &&
      OrderModify(ticket, OrderOpenPrice(), iCustom(NULL, 0, "Parabolic.ex4", 0, 1), OrderTakeProfit(), 0, clrNONE)) {}          tst = false;
//      if (ticket && OrderSelect(ticket, SELECT_BY_TICKET) && f_wBars(tim_PBk2, TimeCurrent()) < f_wBars(OrderOpenTime(), TimeCurrent()) &&
//      OrderModify(ticket, OrderOpenPrice(), d_PBk3, OrderTakeProfit(), 0, clrNONE)) {}

      if (f_wBars(CP_tim, TimeCurrent()) == 1 && SuperTrend(1) != 2147483647.0 && ((Sell && iCustom(NULL, 0, "Parabolic.ex4", 0, 1) > Ask &&
      iCustom(NULL, 0, "Parabolic.ex4", 0, 1) < SuperTrend(1)) || (Buy && iCustom(NULL, 0, "Parabolic.ex4", 0, 1) < Bid &&
      iCustom(NULL, 0, "Parabolic.ex4", 0, 1) > SuperTrend(1))) && iCustom(NULL, 0, "New folder\\ADX.ex4", 14, 0, 1) < 22 &&
      iCustom(NULL, 0, "New folder\\ADX.ex4", 14, 1, 1) > 15 && iCustom(NULL, 0, "New folder\\ADX.ex4", 14, 2, 1) > 15) {
         for (obj = 0; obj < ObjectsTotal() && ! tst; obj ++) { name = ObjectName(obj);
            tst = ((Buy && StringFind(name, "liquid_buy") > 0) || (Sell && StringFind(name, "liquid_sell") > 0)) &&
               ObjectType(name) == OBJ_TREND && f_wBars(ObjectGet(name, OBJPROP_TIME1), TimeCurrent()) < 3 && (! ObjectGet(name, OBJPROP_TIME2) ||
               ObjectGet(name, OBJPROP_TIME2) >= Time[0]) && ((Buy && ObjectGet(name, OBJPROP_PRICE1) > SuperTrend(1)) ||
               (Sell && ObjectGet(name, OBJPROP_PRICE1) < SuperTrend(1))); }
         t_CPEPA = t_CPEPA || tst;           t_ATSEP = t_ATSEP || tst; }               // * 18-05-2022 : 16h 40 *

      t_PBkx2 = ((! ticket && ! OrdersTotal()) || (ticket && OrderSelect(ticket, SELECT_BY_TICKET) && OrderCloseTime())) &&
         ticket_b && OrderSelect(ticket_b, SELECT_BY_TICKET) && OrderCloseTime() && ((fabs(OrderClosePrice() - iCustom(NULL, 0,
         "Parabolic.ex4", 0, iBarShift(NULL, 0, OrderCloseTime()) + 1)) < 12 * Point() && NormPrice(OrderStopLoss(), OrderSymbol())
         == NormPrice(iCustom(NULL, 0, "Parabolic.ex4", 0, iBarShift(NULL, 0, OrderCloseTime()) + 1), OrderSymbol())) ||
         fabs(OrderClosePrice() - iCustom(NULL, 0, "Parabolic.ex4", 0, iBarShift(NULL, 0, OrderCloseTime()) + 1)) < 35 * Point()) &&
         iBarShift(NULL, 0, CP_tim) > iBarShift(NULL, 0, OrderCloseTime()) && iBarShift(NULL, 0, EP_tim) > iBarShift(NULL, 0,
         OrderCloseTime()) && f_wBars(OrderCloseTime(), TimeCurrent()) < 7 && iCustom(NULL, 0, "New folder\\ADX.ex4", 0,
         iBarShift(NULL, 0, OrderCloseTime()) + 1) > 35.0 && f_wBars(OrderOpenTime(), OrderCloseTime()) > 7;
//    dates multiples : répétition du trade après sortie par stop / parabolique

/*      for (int pos=0; pos <  OrdersTotal(); pos ++) if (OrderSelect(pos, SELECT_BY_POS)) {*/ double SL2;/*
         if (iCustom(OrderSymbol(), 0, "New folder\\ADX.ex4", 14, 0, 1) > 25.0) { int tickt=OrderTicket();     string temp=OrderSymbol();       Sell = OrderType() % 2;
            if (OrderProfit() > fabs(OrderTakeProfit() - OrderOpenPrice()) / TS * TV * 0.0025/* && f_wBars(OrderOpenTime(), TimeCurrent()) > 48/* * 60 / Period()* /) {
               SL2 = NormPrice(Sell? fmin(OrderOpenPrice() + (OrderTakeProfit() - OrderOpenPrice()) * (OrderProfit() > fabs(OrderTakeProfit() - OrderOpenPrice()) / TS * TV * 0.009?
                  0.75: OrderProfit() > fabs(OrderTakeProfit() - OrderOpenPrice()) / TS * TV * 0.007? 0.5: OrderProfit() > fabs(OrderTakeProfit() - OrderOpenPrice()) / TS * TV * 0.0045?
                  0.25: 0.0), iCustom(temp, 0, "Parabolic.ex4", 0, OrderProfit() > fabs(OrderTakeProfit() - OrderOpenPrice()) / TS * TV * 0.0085? 0: 1)):
                  fmax(OrderOpenPrice() + (OrderTakeProfit() - OrderOpenPrice()) * (OrderProfit() > fabs(OrderTakeProfit() - OrderOpenPrice()) / TS * TV * 0.009? 0.75:
                  OrderProfit() > fabs(OrderTakeProfit() - OrderOpenPrice()) / TS * TV * 0.007? 0.5: OrderProfit() > fabs(OrderTakeProfit() - OrderOpenPrice()) / TS * TV
                  * 0.0045? 0.25: -0.2), iCustom(temp, 0, "Parabolic.ex4", 0, OrderProfit() > fabs(OrderTakeProfit() - OrderOpenPrice()) / TS * TV * 0.0085? 0: 1)), temp);
               if (((Sell && OrderStopLoss() > SL2) || (! Sell && OrderStopLoss() < SL2)) && OrderModify(tickt, OrderOpenPrice(), SL2, OrderTakeProfit(), 0, clrNONE))
Alert("******* Modified - " + tickt + " - " + OrderType() + " - " + DoubleToStr(SL2, Digits()) + " - " + DoubleToStr(OrderStopLoss(), Digits()) + " *******"); } } } */

      t_VtPBk = (Sell && Bid < iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, 48, 0) + 22 * Point())) || (Buy && Ask > iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 48, 0)) - 22 * Point());
      if (t_VtPBk) tim_VtPBk = TimeCurrent();         if (f_wBars(tim_VtPBk, TimeCurrent()) > 60) t_VtPBk = false;
/*      if ((! ticket || (OrderSelect(ticket, SELECT_BY_TICKET) && OrderCloseTime())) && t_VtPBk && ((OrderType() && Bid > OrderOpenPrice()) ||
      (! OrderType() && Ask < OrderOpenPrice())) && mOrderSend(Symbol(), OrderType()? 5: 4, 0.01, OrderOpenPrice() + (OrderType()? -1.0: 1.0) * 44 * Point(),
      5, OrderStopLoss(), OrderTakeProfit(), OrderComment() + "-2", OrderMagicNumber(), OrderExpiration()? TimeCurrent() + OrderExpiration() - OrderOpenTime(): 0, clrNONE)) {
         CP_tims[0] = CP_tim? CP_tim: Time[0];        CP_tims[4] = 0;      t_box = true;        tick_st = 0;      t_nSTO = false;
               tim1 = TimeCurrent();         t_Sent = true;       Bull = ! OrderType();         if (t_box4) { t_box = false;        t_box4 = false; } } */

      if (((iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 1) > iClose(NULL, 0, 1) && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 0) != 2147483647.0 &&
      Buy3 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 0) < Bid) || (iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 1) < iClose(NULL, 0, 1) &&
      iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 0) != 2147483647.0 && Sell3 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 0) > Ask)) &&
      ((Buy3 && iMA(NULL, 0, 100, 0, MODE_EMA, PRICE_CLOSE, 0) < Bid && iMA(NULL, 0, 100, 0, MODE_EMA, PRICE_CLOSE, 0) > iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 0)) ||
      (Sell3 && iMA(NULL, 0, 100, 0, MODE_EMA, PRICE_CLOSE, 0) > Ask && iMA(NULL, 0, 100, 0, MODE_EMA, PRICE_CLOSE, 0) < iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 0)))) {
         if (! ticket || (OrderSelect(ticket, SELECT_BY_TICKET) && OrderCloseTime())) t_CPEPA = true;/*            t_ATSEP = true; }
         if (ticket_b && OrderSelect(ticket_b, SELECT_BY_TICKET) && OrderProfit() < 0.5)) */if (Buy3) t_STCr1 = true;   else t_STCr2 = true;       tim_STCrt = TimeCurrent(); }
      if (((! ticket || (OrderSelect(ticket, SELECT_BY_TICKET) && OrderCloseTime())) && ticket_b && OrderSelect(ticket_b, SELECT_BY_TICKET) &&
      OrderProfit() > 0.5 && EP_tim > OrderCloseTime() && ((Buy3 && t_STCr1 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 0) != 2147483647.0 &&
      iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 0) < Bid) || (Sell3 && t_STCr2 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 0) !=    // * 05-05-2022 : 13h à 18h *
      2147483647.0 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 0) > Ask)))/* || ((t_STCr1 || t_STCr2) && OrderCloseTime() > tim_STCrt &&
      OrderOpenTime() < tim_STCrt && ! ticket)*/) t_CPEPA = true;             // * 06-05-2022 : 03h 30 à 05h *
      if (ticket_b && OrderSelect(ticket_b, SELECT_BY_TICKET) && OrderCloseTime() && f_wBars(OrderCloseTime(), TimeCurrent()) > 15) { t_STCr1 = false;      t_STCr2 = false; }
//      if (t_STCr1 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 0) != 2147483647.0 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 0) > iClose(NULL, 0, 1)) t_STCr1 = false;
//      if (t_STCr2 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 0) != 2147483647.0 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 0) < iClose(NULL, 0, 1)) t_STCr2 = false;

      if (OrdersTotal() && ((ticket && OrderSelect(ticket, SELECT_BY_TICKET) && ! OrderCloseTime()) || (ticket_b && OrderSelect(ticket_b, SELECT_BY_TICKET) && ! OrderCloseTime())) &&
      f_wBars(OrderOpenTime(), TimeCurrent()) > 36 && ((iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 1) > iClose(NULL, 0, 1) && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 0)
      != 2147483647.0 && ! OrderType() && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 0) < Bid) || (iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 1) < iClose(NULL, 0, 1) &&
      iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 0) != 2147483647.0 && OrderType() && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 0) > Ask)) &&// Day() == 24 && Hour() < 5 &&
      ((tst=(OrderType() < 2 && mOrderClose(OrderTicket(), OrderLots(), OrderType()? Ask: Bid, 5, clrNONE))) || OrderDelete(ticket, clrNONE))) {
         if (tst) { ticket_ = ticket;           CP_tim = 0;          EP_tim = 0; }        ticket = 0; }

      dtmp = Exp_Ind[0][20] == Time[0] || Exp_Ind[0][20] == Time[1]? Sell? (Exp_Ind[1][6] + Exp_Ind[1][9]) * 5.0 /
         (Exp_Ind[2][6]+Exp_Ind[2][9]+Exp_Ind[3][6]+Exp_Ind[3][9]+Exp_Ind[4][6]+Exp_Ind[4][9]+Exp_Ind[5][6]+Exp_Ind[5][9]+Exp_Ind[6][6]+Exp_Ind[6][9]):
         (Exp_Ind[1][5] + Exp_Ind[1][8]) * 5.0 /
         (Exp_Ind[2][5]+Exp_Ind[2][8]+Exp_Ind[3][5]+Exp_Ind[3][8]+Exp_Ind[4][5]+Exp_Ind[4][8]+Exp_Ind[5][5]+Exp_Ind[5][8]+Exp_Ind[6][5]+Exp_Ind[6][8]):
         Sell? (Exp_Ind[0][6] + Exp_Ind[0][9]) * 5.0 /
         (Exp_Ind[1][6]+Exp_Ind[1][9]+Exp_Ind[2][6]+Exp_Ind[2][9]+Exp_Ind[3][6]+Exp_Ind[3][9]+Exp_Ind[4][6]+Exp_Ind[4][9]+Exp_Ind[5][6]+Exp_Ind[5][9]):
         (Exp_Ind[0][5] + Exp_Ind[0][8]) * 5.0 /
         (Exp_Ind[1][5]+Exp_Ind[1][8]+Exp_Ind[2][5]+Exp_Ind[2][8]+Exp_Ind[3][5]+Exp_Ind[3][8]+Exp_Ind[4][5]+Exp_Ind[4][8]+Exp_Ind[5][5]+Exp_Ind[5][8]);
      t_VtRtn = ((Exp_Ind[0][5]+Exp_Ind[0][8] > 350 || Exp_Ind[1][5]+Exp_Ind[1][8] > 350) && dtmp > 3.0 && f_wBars(fmax(EP_tim, EPc_tim), TimeCurrent()) == 1 &&
      Buy && iClose(NULL, 0, iBarShift(NULL, 0, fmax(EP_tim, EPc_tim)) + 1) > iClose(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 12, 0)) - 45 * Point() && Sell3) ||
      ((Exp_Ind[0][6]+Exp_Ind[0][9] > 350 || Exp_Ind[1][6]+Exp_Ind[1][9] > 350) && dtmp > 3.0 && f_wBars(fmax(EP_tim, EPc_tim), TimeCurrent()) == 1 &&
      Sell && iClose(NULL, 0, iBarShift(NULL, 0, fmax(EP_tim, EPc_tim)) + 1) < iClose(NULL, 0, iLowest(NULL, 0, MODE_LOW, 12, 0)) + 45 * Point() && Buy3);
      if (t_VtRtn) { t_CPEPA = true;         tim_VtRt = TimeCurrent(); }         if (f_wBars(tim_VtRt, TimeCurrent()) > 4) t_VtRtn = false;
/* if (Day() == 9 && Hour() == 18 && Minute() < 20) Alert("******* Exp_Ind[1][5]+Exp_Ind[1][8] - " + (Exp_Ind[0][5]+Exp_Ind[0][8]) + " - " +       // * 09-05-2022 : 18h *
   (Exp_Ind[1][5]+Exp_Ind[1][8]) + " - " + dtmp + " - " + fmin(f_wBars(EP_tim, TimeCurrent()), f_wBars(EPc_tim, TimeCurrent())) + " - " + ticket +
   " - " + t_PBkx2 + " - " + t_VtRtn + " - " + ticket_b + " - " + OrderSelect(ticket_b, SELECT_BY_TICKET) + " - " + f_wBars(OrderCloseTime(), TimeCurrent()) + " *******"); */

      t_PBk1 = (iCustom(NULL, 0, "Parabolic.ex4", 0, 0) && iCustom(NULL, 0, "Parabolic.ex4", 0, 0) < Bid);
      t_PBk2 = (iCustom(NULL, 0, "Parabolic.ex4", 0, 0) != 2147483647.0 && iCustom(NULL, 0, "Parabolic.ex4", 0, 0) > Ask);
      t_STCr3 = ((t_MP=(iCustom(NULL, 0, "ind Profil Marché (de CMA).ex4", 0, 1) < 50 &&
      iCustom(NULL, 0, "ind Profil Marché (de CMA).ex4", 1, 1) < iCustom(NULL, 0, "ind Profil Marché (de CMA).ex4", 4, 1) &&
      iCustom(NULL, 0, "ind Profil Marché (de CMA).ex4", 2, 1) < iCustom(NULL, 0, "ind Profil Marché (de CMA).ex4", 4, 1) &&
      iCustom(NULL, 0, "ind Profil Marché (de CMA).ex4", 3, 1) < iCustom(NULL, 0, "ind Profil Marché (de CMA).ex4", 4, 1))) &&
      (t_STCr4=(((iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 1) > iClose(NULL, 0, 1) && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 2)     // * maj bougie *
      != 2147483647.0 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 0) < Bid) || (iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 1) < iClose(NULL, 0, 1) &&
      iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 1) != 2147483647.0 /* ** */ && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 0) > Ask)) ||
      ((iCustom(NULL, 0, "Parabolic.ex4", 0, 1) != 2147483647.0 && iCustom(NULL, 0, "Parabolic.ex4", 0, 1) > iClose(NULL, 0, 1) && t_PBk1) ||
      (iCustom(NULL, 0, "Parabolic.ex4", 0, 1) && iCustom(NULL, 0, "Parabolic.ex4", 0, 1) < iClose(NULL, 0, 1) && t_PBk2)))));
      if (t_STCr3) { t_CPEPA = true;         tim_STCr3 = TimeCurrent(); }        if (f_wBars(tim_STCr3, TimeCurrent()) > 4) t_STCr3 = false;    // * 06-05-2022 : 3h 50 *
/* if (Day() == 6 && Hour() == 5) Alert("******* ind Profil Marché (de CMA) - " + iCustom(NULL, 0, "ind Profil Marché (de CMA).ex4", 0, 1) + " - " +
   iCustom(NULL, 0, "ind Profil Marché (de CMA).ex4", 1, 1) + " - " + iCustom(NULL, 0, "ind Profil Marché (de CMA).ex4", 2, 1) + " - " +
   iCustom(NULL, 0, "ind Profil Marché (de CMA).ex4", 3, 1) + " - " + iCustom(NULL, 0, "ind Profil Marché (de CMA).ex4", 4, 1) + " *******"); */

      if (t_PBk3 && ticket && OrderSelect(ticket, SELECT_BY_TICKET) && ! OrderCloseTime() && ((OrderType() && t_PBk1) || (! OrderType() && t_PBk2)) &&
      mOrderClose(ticket, OrderLots(), OrderType()? Ask: Bid, 5, clrNONE)) { ticket_ = ticket;      ticket = 0;    t_PBk3 = false; }//       CP_tim = 0;       EP_tim = 0;

      if (t_MP2 && iCustom(NULL, 0, "ind Profil Marché (de CMA).ex4", 0, 1) < 55.0) tim_MP2 = TimeCurrent();
      if (iCustom(NULL, 0, "ind Profil Marché (de CMA).ex4", 0, 1) > 60.0) { t_MP2 = true;           tim_MP = TimeCurrent(); }
      if (t_MP2 && tim_MP2 && f_wBars(tim_MP2, TimeCurrent()) > 0) { t_MP2 = false;             tim_MP2 = 0; }
/* if (Hour() == 9) Alert("******* ind Profil Marché (de CMA) - " + iCustom(NULL, 0, "ind Profil Marché (de CMA).ex4", 0, 1) + " - " +
   TimeToStr(tim_MP, TIME_MINUTES) + " - " + TimeToStr(tim_MP2, TIME_MINUTES) + " - " + t_MP2 + " *******"); */

      if (ticket && OrderSelect(ticket, SELECT_BY_TICKET) && ! OrderCloseTime() && EP_tim >= OrderOpenTime() && ((OrderType() && Buy3) ||       // * 11-05-2022 : 12h 20 *
      (! OrderType() && Sell3)) && iCustom(NULL, 0, "New folder\\ADX.ex4", 14, 0, 1) > 35.0 && mOrderClose(ticket, OrderLots(), Sell? Ask: Bid, 5, clrNONE)) {}

      if (ticket && OrderSelect(ticket, SELECT_BY_TICKET) && ! OrderCloseTime() && CP_tim >= OrderOpenTime() && ((OrderType() && Buy) ||        // * 11-05-2022 : 15h 35 *
      (! OrderType() && Sell)) && fabs(f_wBars(tim_Str5c, CP_tim)) < 2 && mOrderClose(ticket, OrderLots(), Sell? Ask: Bid, 5, clrNONE)) {}
/* if (Hour() == 15) Alert("******* ind Signal 5 + (de CMA) - " + iCustom(NULL, 0, "ind Signal 5 + (de CMA).ex4", 1, 1) + " - " + iCustom(NULL, 0, "ind Signal 5 + (de CMA).ex4", 2, 1) +
   " - " + TimeToStr(CP_tim, TIME_MINUTES) + " - " + TimeToStr(tim_Str5c, TIME_MINUTES) + " - " + f_wBars(tim_Str5c, CP_tim) + " *******"); */

      t_Rng1 = false;      t_Rng2 = false;      tst = false;      double R2=0.0, R3=0.0, S2=0.0, S3=0.0;       R1 = 0.0;      S1 = 0.0;
      for (obj = 0; obj < ObjectsTotal() && ! tst && ! t_Rng1 && ! t_Rng2; obj ++) { name = ObjectName(obj);
         if (name == "RSLinesS1") S1 = ObjectGet(name, OBJPROP_PRICE1);       if (name == "RSLinesS2") S2 = ObjectGet(name, OBJPROP_PRICE1);
         if (name == "RSLinesS3") S3 = ObjectGet(name, OBJPROP_PRICE1);       if (name == "RSLinesR1") R1 = ObjectGet(name, OBJPROP_PRICE1);
         if (name == "RSLinesR2") R2 = ObjectGet(name, OBJPROP_PRICE1);       if (name == "RSLinesR3") R3 = ObjectGet(name, OBJPROP_PRICE1);
         t_Rng1 = (R1 && R2 && R3 && R1 == R2 && R2 == R3);          t_Rng2 = (S1 && S2 && S3 && S1 == S2 && S2 == S3);
         tst = R1 && R2 && R3 && S1 && S2 && S3 ; }
      if (t_Rng1 || t_Rng2) { if (! tim_Rng) tim_Rng = TimeCurrent(); }       else  tim_Rng = 0;

      if ((iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 1) > iClose(NULL, 0, 1) && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 2)     // * maj bougie *
      != 2147483647.0 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 0) < Bid) || (iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 1) < iClose(NULL, 0, 1) &&
      iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 1) != 2147483647.0 /* ** */ && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 0) > Ask)) tim_STCr4 = TimeCurrent();

      if (Period() == 60) { if (((t_ST=((Sell && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 1) > iClose(NULL, 0, 1) && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 2)    // * maj bougie *
         != 2147483647.0) || (Buy && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 1) < iClose(NULL, 0, 1) && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 1)))) || ! t_Pass) &&
         (! ticket || (OrderSelect(ticket, SELECT_BY_TICKET) && OrderCloseTime())) && ((i_ST < 5 && t_STCr4) || i_ST < 8)) {
            if (! t_Pass) Sell = iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 1) > iClose(NULL, 0, 1) && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 2) != 2147483647.0;
            ticket = mOrderSend(Symbol(), Sell + 4, 0.01, (Sell? Bid: Ask) + (Sell? -1.0: 1.0) * 44 * Point(), 5, (Sell? Bid * 1.01: Ask * 0.99),
               (Sell? Ask * 0.985: Bid * 1.015), NULL, 0, TimeCurrent() + 7 * Period() * 60, clrNONE);
            tickt2 = mOrderSend(Symbol(), Sell + 2, 0.01, (Sell? Bid: Ask) + (Sell? 1.0: -1.0) * 44 * Point(), 5, (Sell? Bid * 1.01: Ask * 0.99),
               (Sell? Ask * 0.985: Bid * 1.015), NULL, 0, TimeCurrent() + 7 * Period() * 60, clrNONE);
            if (ticket > 0 && tickt2 > 0) i_ST ++; }                    if (i_bar < Time[0]) i_ST = 0;

         if (tickt2 && OrderSelect(tickt2, SELECT_BY_TICKET) && OrderProfit() && ! OrderCloseTime() && ticket && OrderDelete(ticket, clrNONE)) {
            ticket = tickt2;           tickt2 = 0;           Sell = OrderType();           Bull = ! Sell;
Alert("*** OrderDelete(tickt2) - " + TimeToStr(CP_tims[0], TIME_DATE|TIME_MINUTES) + " ***"); }

         if (ticket && OrderSelect(ticket, SELECT_BY_TICKET) && ! OrderCloseTime() &&
         ((Buy && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 1) > iClose(NULL, 0, 1) && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 2)    // * maj bougie *
         != 2147483647.0) || (Sell && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 1) < iClose(NULL, 0, 1) && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 1))) &&
         ((OrderType() < 2 && OrderClose(ticket, OrderLots(), Sell? Bid: Ask, 15, clrNONE)) || OrderDelete(ticket, clrNONE))) ticket = 0; }

      if (ticket && OrderSelect(ticket, SELECT_BY_TICKET) && ! OrderCloseTime()/* && ! t_box3 && ! t_CPClos2*/) { if (Period() >= 240) { bool tst2;
            tst = false;      for (obj = 0; obj < ObjectsTotal() && ! tst && ! tst2; obj ++) { name = ObjectName(obj);
               tst2 = ((Sell && (name == "RSLinesS1" || name == "RSLinesS2" || name == "RSLinesS3")) ||
                  (Buy && (name == "RSLinesR1" || name == "RSLinesR2" || name == "RSLinesR3"))) &&
                  ((Sell && ObjectGet(name, OBJPROP_PRICE1) > OrderTakeProfit() && ObjectGet(name, OBJPROP_PRICE1) < OrderOpenPrice()) ||
                  (Buy && ObjectGet(name, OBJPROP_PRICE1) < OrderTakeProfit() && ObjectGet(name, OBJPROP_PRICE1) > OrderOpenPrice())) &&
                  fabs(ObjectGet(name, OBJPROP_PRICE1) - OrderOpenPrice()) < fabs((Sell? iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim) + 1):
                  iLow(NULL, 0, iBarShift(NULL, 0, CP_tim) + 1)) - OrderOpenPrice()) && ObjectGet(name, OBJPROP_TIME2) > Time[1];
               tst = (tst2 || (Sell && name == "RSLinesS1") || (Buy && name == "RSLinesR1")) && ObjectType(name) == OBJ_TREND;
               if (tst) { tst = ((iBarShift(NULL, 0, CP_tims[0]) > 7 && f_wBars(CP_tims[0], ObjectGet(name, OBJPROP_TIME1)) > 7/* * Period() * 60*/ &&
                     CP_tims[0] && ! CP_tims[4]) || (iBarShift(NULL, 0, CP_tims[4]) > 7 && f_wBars(CP_tims[4], ObjectGet(name, OBJPROP_TIME1)) >
                     7/* * Period() * 60*/ && CP_tims[4])) && f_wBars(ObjectGet(name, OBJPROP_TIME1), ObjectGet(name, OBJPROP_TIME2)) > 5/* * Period() * 60*/
                     && ! t_box3 && ! t_CPClos2;
                  if (! tst) { for (int ob=0; ob < ObjectsTotal() && ! tst; ob ++) { string name2=ObjectName(ob);
                        tst = (StringFind(name2, "BoxLine") > 0 && ObjectGet(name2, OBJPROP_TIME2) == Time[1] &&
                           f_wBars(ObjectGet(name2, OBJPROP_TIME1), ObjectGet(name2, OBJPROP_TIME2)) > 2/* * Period() * 60*/ &&
                           ObjectGet(name, OBJPROP_TIME1) < ObjectGet(name2, OBJPROP_TIME1)) && (tst2 ||
                           f_wBars(ObjectGet(name, OBJPROP_TIME1), ObjectGet(name2, OBJPROP_TIME1)) < 5/* * Period() * 60*/); }
                     if (tst) { t_BxClo = Time[0];       tst = false;      name = name2;
                        for (ob = 0; ob < ObjectsTotal() && ! tst; ob ++) { name2 = ObjectName(ob);
                           tst = StringFind(name2, "rect") > 0 && ObjectType(name2) == OBJ_RECTANGLE && ObjectGet(name2, OBJPROP_TIME2) ==
                              ObjectGet(name, OBJPROP_TIME2) && StringSubstr(name, StringFind(name, "BoxLine") + 7, 16) ==
                              StringSubstr(name2, StringFind(name2, "rect") + 4, 16); }
                        double SL=(Sell? ObjectGet(name2, OBJPROP_PRICE1): ObjectGet(name2, OBJPROP_PRICE2)) + (Sell? 1.0: -1.0) * 22 * Point(); } } }
               tst2 = ((Sell && StringFind(name, "liquid_buy") > 0) || (Buy && StringFind(name, "liquid_sell") > 0)) &&
                  ObjectType(name) == OBJ_TREND && ((ObjectGet(name, OBJPROP_TIME1) > CP_tims[0] && CP_tims[0] && ! CP_tims[4]) ||
                  (ObjectGet(name, OBJPROP_TIME1) > CP_tims[4] && CP_tims[4])) && ! t_box3 && ! t_CPClos2;              if (tst || tst2) {
               if (t_BxClo && SL && ((Sell && SL > Ask) || (Buy && SL < Bid)) && OrderModify(ticket, OrderOpenPrice(), SL, OrderTakeProfit(), 0, clrNONE))
Alert("*** " + (tst? "RSLinesRS1": "liquid_line") + " Modify(1) - " + name + " - " + DoubleToStr(ObjectGet(name, OBJPROP_PRICE1), Digits()) + " - " +
   TimeToStr(CP_tims[0], TIME_DATE|TIME_MINUTES) + " - " + TimeToStr(CP_tims[4], TIME_DATE|TIME_MINUTES) + " - " + TimeToStr(ObjectGet(name, OBJPROP_TIME1), TIME_DATE|TIME_MINUTES) + " ***");
               if (! (t_BxClo && SL && ((Sell && SL > Ask) || (Buy && SL < Bid))) && mOrderClose(ticket, OrderLots(), Sell? Ask: Bid, 5, clrNONE)) {
                  ticket_ = ticket;          ticket = 0;          CP_tim = 0;          EP_tim = 0;
Alert("*** " + (tst? "RSLinesRS1": "liquid_line") + " Close - " + name + " - " + DoubleToStr(ObjectGet(name, OBJPROP_PRICE1), Digits()) + " - " +/* ObjectGet(name, OBJPROP_COLOR) + " - " +*/
   TimeToStr(CP_tims[0], TIME_DATE|TIME_MINUTES) + " - " + TimeToStr(CP_tims[4], TIME_DATE|TIME_MINUTES) + " - " + TimeToStr(ObjectGet(name, OBJPROP_TIME1), TIME_DATE|TIME_MINUTES) + " ***"); } } }
            tst = false;      for (obj = 0; obj < ObjectsTotal() && ! tst && ! t_box3 && ! t_CPClos2; obj ++) { name = ObjectName(obj);
               tst = ((Buy && (name == "RSLinesS1" || StringFind(name, "liquid_buy") > 0)) || (Sell &&
                  (name == "RSLinesR1" || StringFind(name, "liquid_sell") > 0))) && ObjectType(name) == OBJ_TREND &&
                  ObjectGet(name, OBJPROP_TIME1) > CP_tims[0] && CP_tims[4]; }               if (tst)
               if (OrderModify(ticket, OrderOpenPrice(), ObjectGet(name, OBJPROP_PRICE1) + (Sell? 1.0: -1.0) * 22 * Point(), OrderTakeProfit(), 0, clrNONE))
Alert("*** " + (tst? "RSLinesRS1": "liquid_line") + " Modify(2) - " + name + " - " + DoubleToStr(ObjectGet(name, OBJPROP_PRICE1), Digits()) + " - " + t_box2 + " - " +
   TimeToStr(CP_tims[0], TIME_DATE|TIME_MINUTES) + " - " + TimeToStr(CP_tims[4], TIME_DATE|TIME_MINUTES) + " - " + TimeToStr(ObjectGet(name, OBJPROP_TIME1), TIME_DATE|TIME_MINUTES) + " ***"); }

         else { TS = MarketInfo(Symbol(), MODE_TICKSIZE);   TV = MarketInfo(Symbol(), MODE_TICKVALUE);/*         double SL2;*/          t_P60 = true;
            if (t_BH && OrderProfit() > fabs(OrderTakeProfit() - OrderOpenPrice()) / TS * TV * 0.0005) { SL2 = NormPrice(OrderOpenPrice(), Symbol());
               if (((Sell && OrderStopLoss() > SL2) || (Buy && OrderStopLoss() < SL2)) && OrderModify(ticket, OrderOpenPrice(), SL2, OrderTakeProfit(), 0, clrNONE)) { t_BH2 = true;
Alert("*** OrderModify(1) - " + Buy + " - " + Sell + " - " + DoubleToStr(SL2, Digits()) + " - " + DoubleToStr(OrderStopLoss(), Digits()) + " - " + TimeToStr(CP_tim, TIME_DATE|TIME_MINUTES) + " ***"); } }
            if (OrderProfit() > fabs(OrderTakeProfit() - OrderOpenPrice()) / TS * TV * 0.0045 && f_wBars(OrderOpenTime(), TimeCurrent()) > 48/* * 60 / Period()*/) {
               SL2 = NormPrice(OrderOpenPrice() + (OrderTakeProfit() - OrderOpenPrice()) * 0.25, Symbol());
               if (((Sell && OrderStopLoss() > SL2) || (Buy && OrderStopLoss() < SL2)) && OrderModify(ticket, OrderOpenPrice(), SL2, OrderTakeProfit(), 0, clrNONE)) { t_BH2 = true;
Alert("*** OrderModify(2) - " + Buy + " - " + Sell + " - " + DoubleToStr(SL2, Digits()) + " - " + DoubleToStr(OrderStopLoss(), Digits()) + " - " + TimeToStr(CP_tim, TIME_DATE|TIME_MINUTES) + " ***"); } }
            if (OrderProfit() > fabs(OrderTakeProfit() - OrderOpenPrice()) / TS * TV * 0.007) { SL2 = NormPrice(OrderOpenPrice() + (OrderTakeProfit() - OrderOpenPrice()) * 0.5, Symbol());
               if (((Sell && OrderStopLoss() > SL2) || (Buy && OrderStopLoss() < SL2)) && OrderModify(ticket, OrderOpenPrice(), SL2, OrderTakeProfit(), 0, clrNONE)) { t_BH2 = true;
Alert("*** OrderModify(3) - " + Buy + " - " + Sell + " - " + DoubleToStr(SL2, Digits()) + " - " + DoubleToStr(OrderStopLoss(), Digits()) + " - " + TimeToStr(CP_tim, TIME_DATE|TIME_MINUTES) + " ***"); } }
            if (OrderProfit() > fabs(OrderTakeProfit() - OrderOpenPrice()) / TS * TV * 0.009) { SL2 = NormPrice(OrderOpenPrice() + (OrderTakeProfit() - OrderOpenPrice()) * 0.75, Symbol());
               if (((Sell && OrderStopLoss() > SL2) || (Buy && OrderStopLoss() < SL2)) && OrderModify(ticket, OrderOpenPrice(), SL2, OrderTakeProfit(), 0, clrNONE)) { t_BH2 = true;
Alert("*** OrderModify(4) - " + Buy + " - " + Sell + " - " + DoubleToStr(SL2, Digits()) + " - " + DoubleToStr(OrderStopLoss(), Digits()) + " - " + TimeToStr(CP_tim, TIME_DATE|TIME_MINUTES) + " ***"); } }
            bool tst1=OrderProfit() < -1.0 * fabs(OrderStopLoss() - OrderOpenPrice()) / TS * TV * 0.0025, tst3=(Sell && OrderStopLoss() >
               iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 48, iBarShift(NULL, 0, OrderOpenTime()))) + 22 * Point()) || (Buy && OrderStopLoss() <
               iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, 48, iBarShift(NULL, 0, OrderOpenTime()))) - 22 * Point());
            tst2 = OrderProfit() < -1.0 * fabs((Sell?iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 48, iBarShift(NULL, 0, OrderOpenTime()))):
               iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, 48, iBarShift(NULL, 0, OrderOpenTime())))) - OrderOpenPrice()) / TS * TV * 0.003;
            if (((tst3 && tst2) || (! tst3 && tst1 && tst2)) && f_wBars(OrderOpenTime(), TimeCurrent()) > 24/* * 60/Period()*/) tim_BH = TimeCurrent();
            t_BH = (t_BH? t_BH: (t_BH2=(((tst3 && tst2) || (! tst3 && tst1 && tst2)) && f_wBars(OrderOpenTime(), TimeCurrent()) > 24/* * 60/Period()*/))); } }
      else if (f_wBars(tim_BH, TimeCurrent()) > 24/* * Period() * 60*/ || (ticket_ && OrderSelect(ticket_, SELECT_BY_TICKET) && OrderCloseTime() > tim_BH &&
      f_wBars(OrderCloseTime(), TimeCurrent()) > 5/* * Period() * 60*/)) t_BH = false; }
//if (Day() == 19 && Month() == 4 && Hour() == 15) f_End_EA(0);

   tst = false;         for (obj = 0; obj < ObjectsTotal() && ! tst; obj ++) { name = ObjectName(obj);
      if (StringFind(name, "BoxLine") > 0 && ObjectGet(name, OBJPROP_TIME2) == Time[1] && ((Sell &&
      ObjectGet(name, OBJPROP_PRICE1) < iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim))) || (Buy && ObjectGet(name, OBJPROP_PRICE1) >
      iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)))) && f_wBars(CP_tims[0], ObjectGet(name, OBJPROP_TIME1)) > 7/* * Period() * 60*/ && CP_tims[0]) {
         for (ob = 0; ob < ObjectsTotal() && ! tst; ob ++) { name2 = ObjectName(ob);
            tst = StringFind(name2, "rect") > 0 && ObjectType(name2) == OBJ_RECTANGLE && ObjectGet(name2, OBJPROP_TIME2) ==
               ObjectGet(name, OBJPROP_TIME2) && StringSubstr(name, StringFind(name, "BoxLine") + 7, 16) ==
               StringSubstr(name2, StringFind(name2, "rect") + 4, 16); }
         if (tst) { if (! t_box && ! t_box2) { t_box2 = (ObjectGet(name2, OBJPROP_COLOR) != 5789784);          tim_box = TimeCurrent();
Alert("*** t_box - " + name + " - " + ChartSymbol() + " - " + Symbol() + " - " + name2 + " - " + TimeToStr(CP_tims[0], TIME_DATE|TIME_MINUTES) + " - " + t_box2 + " - " + ObjectGet(name2, OBJPROP_COLOR) + " ***");
             }       tim_box2 = TimeCurrent(); } } }

   t_box3 = (t_box2 && f_wBars(tim_box, TimeCurrent()) > 7/*(7 + (DayOfWeek() < TimeDayOfWeek(tim_box)? 48 * 60 / Period(): 0)) * Period() * 60*/);
   if (ticket && OrderSelect(ticket, SELECT_BY_TICKET) && ! OrderCloseTime() && t_box3 &&
   f_wBars(OrderOpenTime(), TimeCurrent()) > 7/*(7 + (DayOfWeek() < TimeDayOfWeek(tim_box)? 48 * 60 / Period(): 0)) * Period() * 60*/ &&
   f_wBars(tim_box, TimeCurrent()) > 7/*(7 + (DayOfWeek() < TimeDayOfWeek(tim_box)? 48 * 60 / Period(): 0)) * Period() * 60*/) { t_box2 = false;    t_box3 = false; }
   if (ticket && OrderSelect(ticket, SELECT_BY_TICKET) && ! OrderCloseTime() && t_CPClos2 && f_wBars(OrderOpenTime(), TimeCurrent()) > 7
   /*(7 + (DayOfWeek() < TimeDayOfWeek(tim_box)? 48 * 60 / Period(): 0)) * Period() * 60*/) { t_CPClose = false;      t_CPClos2 = false; }
   if (ticket < 0 || (! OrdersTotal() && ticket)) { ticket_ = ticket;            ticket = 0;/*     activation de la ligne suivante ??
      if (ticket && OrderSelect(ticket, SELECT_BY_TICKET) && OrderOpenTime() >= CP_tim) CP_tim = 0;      if (OrderOpenTime() >= EP_tim) EP_tim = 0;*/ }
//Alert: **0* CP - ATS Expansion Index V4.0aei_3 - 2022.05.09 16:55 - 2022.05.09 16:55 - 0.00000 - 2022.05.09 18:10 - 1970.01.01 00:00 - 1 - 0 - 0 - 59 - 0 - 0 - 1 - 2022.05.09 18:08 - 59 - 1 - 1 ***
/* if (Day() == 9 && Hour() == 18 && Minute() < 20)
Alert("**0* CP - " + name + " - " + TimeToStr(CP_tim, TIME_DATE|TIME_MINUTES) + " - " + TimeToStr(CP_tims[0], TIME_DATE|TIME_MINUTES) + " - " +
   DoubleToStr(ObjectGet(name, OBJPROP_PRICE1), Digits()) + " - " + TimeToStr(ObjectGet(name, OBJPROP_TIME1), TIME_DATE|TIME_MINUTES) + " - " +
   TimeToStr(ObjectGet(name, OBJPROP_TIME2), TIME_DATE|TIME_MINUTES) + " - " + t_box + " - " + t_box2 + " - " + t_box3 + " - " + ticket_ + " - " + ticket + " - " +
   OrdersTotal() + " - " + OrderSelect(ticket_, SELECT_BY_TICKET) + " - " + TimeToStr(OrderCloseTime(), TIME_DATE|TIME_MINUTES) + " - " + t_PBkx2 + " - " +
   t_VtRtn + " - " + ticket_b + " - " + OrderSelect(ticket_b, SELECT_BY_TICKET) + " - " + f_wBars(OrderCloseTime(), TimeCurrent()) + " ***"); */
   double atr_m1=500000.0, atr_m2=0.0;       for (int bar=0; bar < 500; bar ++)
      if (iCustom(NULL, 0, "ATR.ex4", 14, 0, bar) < atr_m1) atr_m1 = iCustom(NULL, 0, "ATR.ex4", 14, 0, bar);
      else if (iCustom(NULL, 0, "ATR.ex4", 14, 0, bar) > atr_m2) atr_m2 = iCustom(NULL, 0, "ATR.ex4", 14, 0, bar);
   if (option == 1 || option == 3) { t_Adx = (iCustom(NULL, 0, "New folder\\ADX.ex4", 7, 0, iBarShift(NULL, 0, CP_tim)) > 25.0 ||
            iCustom(NULL, 0, "New folder\\ADX.ex4", 14, 0, iBarShift(NULL, 0, CP_tim)) > 25.0) &&
            iCustom(NULL, 0, "ATR.ex4", 14, 0, iBarShift(NULL, 0, CP_tim)) > 1.0 / 3.0 * (atr_m1 + atr_m2) / 2.0;
         t_Rsi515 = m3_RSI(0, iBarShift(NULL, 0, CP_tim), 2) > 31 && m3_RSI(0, iBarShift(NULL, 0, CP_tim), 2) < 69;
         for (obj = 0; obj < ObjectsTotal(); obj ++) { name = ObjectName(obj);
            t_P60b = ! t_BH && ((tst5=((EP_tim && ((Buy && Buy3) || (Sell && Sell3)) && fabs(f_wBars(EP_tim, CP_tim)) < 15) || t_CPEPA)) || t_BH2 || t_P60);
            if (((StringFind(name, "liquid_") > 0 || StringFind(name, "BoxLine") > 0) && ObjectType(name) == OBJ_TREND/* && (! t_Rsi515 || t_Adx)*/) || t_CPEPA)        // && pos
               if (option == 3 && ((fabs(ObjectGet(name, OBJPROP_TIME1) - CP_tim) < 15 * Period() * 60 && CP_tims[2] != CP_tim) || ((StringFind(name, "BoxLine") > 0 || tst5) &&
               (f_wBars(CP_tim, ObjectGet(name, OBJPROP_TIME1)) < 50/* * Period() * 60*/ || t_box || t_box3 || t_P60b))) && ((Buy && StringFind(name, "liquid_buy") > 0) ||      // && (! t_Rsi515 || t_Adx)
               (Sell && StringFind(name, "liquid_sell") > 0) || ((Period() >= 240 || t_P60b) && ((StringFind(name, "BoxLine") > 0 && (f_wBars(ObjectGet(name, OBJPROP_TIME2), CP_tim) < 3/* * Period() * 60*/ ||
               (! t_P60b && (t_box || t_box3) && ObjectGet(name, OBJPROP_TIME1) > CP_tims[0]))) || tst5))) && ! ticket && ! OrdersTotal() && (! t_PBkx2 || t_VtRtn)) { tst = false;
                  t_box4 = StringFind(name, "BoxLine") > 0;          if (Period() >= 240 && t_box && ! t_box4 && ! ticket) t_box = false;
                  if (t_P60b && (t_BH2 || ! ticket_ || (OrderSelect(ticket_, SELECT_BY_TICKET) && ((Sell && ObjectGet(name, OBJPROP_PRICE1) > OrderClosePrice()) ||
                  (Buy && ObjectGet(name, OBJPROP_PRICE1) < OrderClosePrice()))/* && f_wBars(OrderCloseTime(), TimeCurrent()) < 15/* * Period() * 60*/))) {
                     for (ob = 0; ob < ObjectsTotal() && ! tst; ob ++) { name2 = ObjectName(ob);
                        tst = StringFind(name2, "rect") > 0 && ObjectType(name2) == OBJ_RECTANGLE && ObjectGet(name2, OBJPROP_TIME2) ==
                           ObjectGet(name, OBJPROP_TIME2) && StringSubstr(name, StringFind(name, "BoxLine") + 7, 16) ==
                           StringSubstr(name2, StringFind(name2, "rect") + 4, 16); }      if (tst) namBox = name2;         t_P60b = tst; }         // && ObjectGet(name2, OBJPROP_COLOR) != 5789784);
                  t_P60b = (tst && (ObjectGet(name, OBJPROP_TIME2) == Time[1] || (ticket_ && OrderSelect(ticket_, SELECT_BY_TICKET) && OrderCloseTime() > CP_tims[5]))) || t_CPEPA;       // || tst5;
                  if ((t_Send=(ObjectGet(name, OBJPROP_TIME1) == Time[1] || (tst && ObjectGet(name, OBJPROP_TIME1) < Time[0] && ObjectGet(name, OBJPROP_TIME2)
                  == Time[1]) || (CP_tim == Time[1] && ((Sell && iCustom(NULL, 0, "New folder\\Manual Trade Cashpower Lifetime.ex4", 0, 1) > 0.0) ||
                  (Buy && iCustom(NULL, 0, "New folder\\Manual Trade Cashpower Lifetime.ex4", 1, 1) > 0.0))) || t_CPEPA)) &&
                  (Period() >= 240 || t_P60b || ! ticket_ || (OrderSelect(ticket_, SELECT_BY_TICKET) && OrderCloseTime() &&
                  (f_wBars(OrderCloseTime(), TimeCurrent()) > 3 || f_wBars(OrderOpenTime(), OrderCloseTime()) > 40)))) {
                     CreateVLine(t_box && ! ticket && ObjectGet(name, OBJPROP_TIME1) > CP_tims[0]? ObjectGet(name, OBJPROP_TIME2): CP_tim, Period(), Buy, 0);
                     if (t_ST) Order_Send(CP_tim, t_VtRtn || t_STCr3? ! t_STCr3 || (! t_PBk1 && ! t_PBk2)? Sell3: t_PBk2: t_MP? t_PBk2: Sell);
if (CP_tims[2] != CP_tim || t_box || t_box2 || t_VtRtn || t_STCr3 || t_MP) { CP_tims[2] = CP_tim;
Alert("*** CP - " + name + " - " + ChartSymbol() + " - " + Symbol() + " - " + TimeToStr(CP_tim, TIME_DATE|TIME_MINUTES) + " - " + tst + " - " + t_box + " - " + t_box2 + " - " + t_box3 + " - " +
   DoubleToStr(m3_RSI(0, iBarShift(NULL, 0, CP_tim), 2), 2) + " - " + DoubleToStr(iCustom(NULL, 0, "New folder\\ADX.ex4", 7, 0, iBarShift(NULL, 0, CP_tim)), 2) + " - " +
   DoubleToStr(iCustom(NULL, 0, "New folder\\ADX.ex4", 14, 0, iBarShift(NULL, 0, CP_tim)), 2) + " - " + DoubleToStr(iCustom(NULL, 0, "ATR.ex4", 14, 0, iBarShift(NULL, 0, CP_tim)), Digits()) +
   (t_VtRtn? " - " + Buy + " - " + Buy3 + " - " + Sell + " - " + Sell3: "") +  " ***"); }       break; } } } }
//      double TV=MarketInfo(Symbol(), MODE_TICKVALUE), TS=MarketInfo(Symbol(), MODE_TICKSIZE);            TV = TV < 0.1? 1.0: TV;
 }       t_exp = (tim_exp != Time[0]);/*

if (OrderSelect(0, SELECT_BY_POS, MODE_HISTORY) && OrderProfit() < -0.5 && OrderSelect(1, SELECT_BY_POS, MODE_HISTORY) && OrderProfit() < -0.5) f_End_EA(1);*/
   t_Pass = true;          i_sec = Seconds();         i_bar = Time[0];
   if (Hour() == 23 && OrdersTotal() > 2) { Close_All_Trades(true);        ticket_ = ticket;       ticket = 0;       EP_tim = 0; } }

void OnDeinit(const int reason) { GlobalVariableDel(Symbol() + "_tim_Balance"); }

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

int f_wBars(datetime Tim1,datetime Tim2) { int wbars=0;
   if (DayOfWeek() < TimeDayOfWeek(Tim1)) wbars = 60 * 48 / Period();
   if (floor(Tim2/(60*Period())) - floor(Tim1/(60*Period())) > 60 * 168 / Period())
      wbars = 2 * 60 * 48 / Period();
   return(floor(Tim2/(60*Period())) - floor(Tim1/(60*Period())) - wbars); }

int copy_file_(string filename,string temp) { int handle, it=0;
   bool tst=false;//         filename = StringSubstr(filename, 0, StringFind(filename, ".")) + ".txt";
   while (! tst && it < 7) { if (! FileIsExist(filename, FILE_COMMON)) handle = FileOpen (filename, FILE_TXT|FILE_WRITE|FILE_COMMON);
      else  handle = FileOpen (filename, FILE_TXT|FILE_READ|FILE_WRITE|FILE_COMMON);
      if (handle != INVALID_HANDLE) { if (FileSize(handle)) FileSeek(handle, FileSize(handle), 0);
         tst = FileWrite(handle, temp);
         if (! tst) Print ("Problème : FileWrite(handle, ("+it+" - "+IntegerToString(GetLastError())+") / "+Symbol()+" ***");
         FileClose(handle); }
      else Print ("Problème : handle == INVALID_HANDLE. ("+it+" - "+IntegerToString(GetLastError())+") / "+Symbol()+" ***");     it ++; }
   return(handle); }

int copy_file(string tmp,int item) { int handle, it=0, t=0;     string str, temp="";
/*   MqlDateTime t;    TimeLocal(t);*/     bool tst=false;      ulong cmpl_size;
   string Symb=StringFind(Symbol(), ".")? StringSubstr(Symbol(), 0, StringFind(Symbol(), ".")): Symbol(),
      filename=item? item==3? "suivi_paramètres.log": "Entry_Points_Pro_file_" + Symb + (item==1? ".log": ".txt"): "Entry_Points_Pro_file_order_" + Symb + ".csv";
   while (! tst && it < 7) { if (! FileIsExist(filename)) handle = FileOpen (filename, FILE_TXT|FILE_WRITE);
      else  handle = FileOpen (filename, FILE_TXT|FILE_READ|FILE_WRITE);
      if (handle != INVALID_HANDLE) { if ((cmpl_size=FileSize(handle)) > 0) FileSeek(handle, FileSize(handle), 0);
         if (item && (myHour() == 11 || myHour() == 23) && cmpl_size > 10000000 && tmp_saved > 0 && TimeCurrent() - tmp_saved > 150) {
            FileSeek(handle, -20480, SEEK_CUR);    while(! tst && t < 5000) { FileSeek(handle, -10240, SEEK_CUR);    FileReadString(handle);
               str = FileReadString(handle);          str = StringSubstr(str, 11, 2);        t ++;          tst = StrToInteger(str) < 23; }
            if (! tst) { if (cmpl_size > 0) FileSeek(handle, FileSize(handle), 0);           break; }
            while(! FileIsEnding(handle)) temp += (temp != "" ? "\r\n" : "") + FileReadString(handle);
            temp += "\r\n - - - - - - -";       FileClose(handle);         FileCopy(filename, 0, filename + "2", 0);
            Sleep(100);       FileDelete(filename, 0);      Sleep(100);    handle = FileOpen (filename, FILE_TXT|FILE_WRITE);
            FileWrite(handle, temp); }
         tst = FileWrite(handle, TimeToStr(TimeCurrent(), item? TIME_DATE|TIME_SECONDS: TIME_SECONDS) + " | " + tmp);
         if (! tst) Print ("Problème : FileWrite(handle, ("+it+" - "+IntegerToString(GetLastError())+") / "+Symbol()+" ***"); }
      else Print ("Problème : handle == INVALID_HANDLE. ("+it+" - "+IntegerToString(GetLastError())+") / "+Symbol()+" ***");
   FileClose(handle);      it ++; }       tmp_saved = TimeCurrent();
   return(handle); }

datetime Get_Entry_Point() { bool Buy_=Buy3, Sel_=Sell3, tst=false;     datetime secs=TimeCurrent();      int j=0, k=0;
   Buy3 = false;     Sell3 = false;       for (int bar=0; bar < 200 && ! tst; bar ++) {// Comment("* bar = " + IntegerToString(bar) + " *");
      if (tst=((Sell3=(iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 3, bar) > 0.0)) ||
      (Buy3=(iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 2, bar) > 0.0)))) { CreateVLine(Time[bar], Period(), Buy3, 1);
if (EP_tim1 != Time[bar])
Alert("*** Entry Point Pro -> " + Symbol() + " - " + (Buy3? "Buy": "Sell") + " - " + IntegerToString(bar) + " - " + TimeToStr(Time[bar], TIME_DATE|TIME_MINUTES) + "! ***"); }
      Sleep(50);        if (bar > 10 && (TimeCurrent() - secs) / bar >= 3.0) break; }           if (/*bar == 1 || */! tst) { Buy3 = Buy_;        Sell3 = Sel_; }
   return(tst? (EP_tim1=Time[bar-1]): 0); }

datetime Get_Cash_Power(int mode) { bool Buy_=Buy, Sel_=Sell, tst=false;      datetime secs=TimeCurrent();      int j=0, k=0;
   Buy = false;   Sell = false;     for (int bar=0; bar < 200 && (! tst || mode); bar ++) {// Comment("* bar = " + IntegerToString(bar) + " *");
      if (tst=((Sell=(iCustom(NULL, 0, "New folder\\Manual Trade Cashpower Lifetime.ex4", 0, bar) > 0.0)) ||
      (Buy=(iCustom(NULL, 0, "New folder\\Manual Trade Cashpower Lifetime.ex4", 1, bar) > 0.0)))) {// CreateVLine(Time[bar], Period(), Buy, 0);
if (CP_tims[1] != Time[bar]) { tim4 = TimeCurrent();           ticket_ = 0;         t_box = true;        t_P60 = true;                    // * 19-04-2022 : 12h à 19h *
Alert("*** Manual Trade Cashpower Lifetime -> " + Symbol() + " - " + (Buy? "Buy": "Sell") + " - " + IntegerToString(bar) + " - " + TimeToStr(Time[bar], TIME_DATE|TIME_MINUTES) + "! ***");
/*         if (mode) { CP_tims[k][0] = Time[bar];       CP_tims[k][1] = Sell;         j = k;         k ++; }*/       if (bar < 3) CP_tims[3] = Time[bar]; } }
      Sleep(50);        if (bar > 10 && (TimeCurrent() - secs) / bar >= 3.0) break; }           if (bar == 1 || (! tst && ! mode)) { Buy = Buy_;         Sell = Sel_; }
/*   if (tst || (mode && CP_tims[j][0])) Comment("* bar = " + IntegerToString(bar) + " / wa=" + ((mode && j) || bar? "a+": "w") + "&sb=" + Symbol() + "&tf=" + IntegerToString(Period()) +
         "&tp=" + (Buy? "Buy": "Sell") + "&stm=" + TimeToStr(mode? CP_tims[j][0]: Time[bar], TIME_DATE|TIME_MINUTES) + "&tim=" + IntegerToString(Time[bar]) + " *");
   else  Comment("*** Rien trouvé ! ***");*/         return(mode? 0: tst? (CP_tims[1]=Time[bar-1]): 0); }

void CreateVLine(datetime Ltim,int Per,bool Buy2,int Epp) {
   string LineName="EA_vert-" + IntegerToString(Ltim) + (Epp > 1? "-"+IntegerToString(Epp): "");
   ObjectCreate(0, LineName, OBJ_VLINE, 0, Ltim > 0? Ltim: Time[0], 0);
   ObjectSetInteger(0, LineName, OBJPROP_COLOR, Epp < 2? Buy2? clrGreen: clrPurple: Buy2? clrYellowGreen: clrLightPink);
   ObjectSetInteger(0, LineName, OBJPROP_STYLE, STYLE_DOT);
   ObjectSetInteger(0, LineName, OBJPROP_WIDTH, /*Per==PERIOD_M5*/Epp? Epp==1? 1: 3: 2); }

bool CreateHLine(double price,bool Buy2,datetime tim) { ResetLastError();
   string LineName="EA_X-Line_" + (Buy2? "Buy": "Sell") + "_" + DoubleToStr(price, Digits()) + "_" + IntegerToString(tim);
   if (! ObjectCreate(0, LineName, OBJ_TREND, 0, tim, price, tim + (5+(TimeDayOfWeek(tim+5*Period()*60)==6? 48*60/Period(): 0))*Period()*60, price) &&
   GetLastError() == 4200) return(false);
//Print(__FUNCTION__, ": failed to create a Line! Error code = ", GetLastError());
   ObjectSetInteger(0, LineName, OBJPROP_RAY_RIGHT, false);
   ObjectSetInteger(0, LineName, OBJPROP_COLOR, Buy2? clrGreen: clrPurple);
   ObjectSetInteger(0, LineName, OBJPROP_STYLE, STYLE_DOT);
   ObjectSetInteger(0, LineName, OBJPROP_WIDTH, 7);
   ObjectSetInteger(0, LineName, OBJPROP_FILL, false);
   ObjectSetInteger(0, LineName, OBJPROP_BACK, false);
//   ObjectSetInteger(0, LineName, OBJPROP_HIDDEN, true);
   ObjectSetInteger(0, LineName, OBJPROP_ZORDER, 0);
   LineName = "EA_X-Line_" + (Buy2? "Buy": "Sell") + "2_" + IntegerToString(tim);
   if (! ObjectCreate(0, LineName, OBJ_TREND, 0, tim, price, tim + (5+(TimeDayOfWeek(tim+5*Period()*60)==6? 48*60/Period(): 0))*Period()*60, price))
Print(__FUNCTION__, ": failed to create a Line! Error code = ", GetLastError());
   ObjectSetInteger(0, LineName, OBJPROP_RAY_RIGHT, false);
   ObjectSetInteger(0, LineName, OBJPROP_COLOR, Buy2? clrYellowGreen: clrLightPink);
   ObjectSetInteger(0, LineName, OBJPROP_STYLE, STYLE_DOT);
   ObjectSetInteger(0, LineName, OBJPROP_WIDTH, 2);
   ObjectSetInteger(0, LineName, OBJPROP_FILL, false);
   ObjectSetInteger(0, LineName, OBJPROP_BACK, false);
//   ObjectSetInteger(0, LineName, OBJPROP_HIDDEN, true);
   ObjectSetInteger(0, LineName, OBJPROP_ZORDER, 0);
   return(true); }

void ObjectsDelete(int P, string str) {
   int obj_total=ObjectsTotal(), i=0, j=0;      string name;
   for (int obj=0; obj < obj_total; obj ++) { name = ObjectName(obj);
     if (obj && ((str!="" && StringSubstr(name, 0, StringLen(str)) == 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 ++;  obj --; } } }
   if (P) Print (obj, " objects, DELETED: ", i, " / ", j, " / ", obj_total);
   return; }

double t_res=0.0;       int _k=-1, exp_up=0, exp_dn=0;
void Order_Send(datetime CP_tim,bool Sel2) { if (TimeCurrent() < nxt_tim) return;
   double SL, TP, SpTr, min2=500000.0;       int min=5000000;        string x_obj, x_obj2="";
   if (t_box || t_box3 || t_CPClos2 || Period() <= 60) { if (! ticket) { if (Period() >= 240 && OrderSelect(ticket_, SELECT_BY_TICKET)) {
         bool tst=false;      for (int obj=0; obj < ObjectsTotal() && ! tst; obj ++) { string name=ObjectName(obj);
            tst = ((Sell && (name == "RSLinesS1" || StringFind(name, "liquid_buy") > 0)) || (Buy &&
               (name == "RSLinesR1" || StringFind(name, "liquid_sell") > 0))) && ObjectType(name) == OBJ_TREND &&
               ObjectGet(name, OBJPROP_TIME1) > CP_tims[0] && CP_tims[0]; }
            if (tst) SL = ObjectGet(name, OBJPROP_PRICE1) + (Sel2? 1.0: -1.0) * 22 * Point();

            if ((Sel2 && Bid < TP) || (! Sel2 && Ask > TP)) TP = (Sel2? Bid: Ask) + OrderTakeProfit() - OrderOpenPrice();
            if ((Sel2 && Ask > SL) || (! Sel2 && Bid < SL)) SL = (Sel2? Ask: Bid) + OrderStopLoss() - OrderOpenPrice(); }

         if (Period() >= 240 && (t_box3 || t_CPClos2)) { SL = (Sel2? Bid: Ask) * (Sel2? 1.01: 0.99) + (Sel2? 1.0: -1.0) * 22 * Point();
            TP = (Sel2? Bid: Ask) * (Sel2? 0.985: 1.015) - (Sel2? 1.0: -1.0) * 22 * Point();/*     t_box2 = false;*/ }
         double dtmp=Exp_Ind[0][20] == Time[0] || Exp_Ind[0][20] == Time[1]? Sel2? (Exp_Ind[1][6] + Exp_Ind[1][9]) * 5.0 /
            (Exp_Ind[2][6]+Exp_Ind[2][9]+Exp_Ind[3][6]+Exp_Ind[3][9]+Exp_Ind[4][6]+Exp_Ind[4][9]+Exp_Ind[5][6]+Exp_Ind[5][9]+Exp_Ind[6][6]+Exp_Ind[6][9]):
            (Exp_Ind[1][5] + Exp_Ind[1][8]) * 5.0 /
            (Exp_Ind[2][5]+Exp_Ind[2][8]+Exp_Ind[3][5]+Exp_Ind[3][8]+Exp_Ind[4][5]+Exp_Ind[4][8]+Exp_Ind[5][5]+Exp_Ind[5][8]+Exp_Ind[6][5]+Exp_Ind[6][8]):
            Sel2? (Exp_Ind[0][6] + Exp_Ind[0][9]) * 5.0 /
            (Exp_Ind[1][6]+Exp_Ind[1][9]+Exp_Ind[2][6]+Exp_Ind[2][9]+Exp_Ind[3][6]+Exp_Ind[3][9]+Exp_Ind[4][6]+Exp_Ind[4][9]+Exp_Ind[5][6]+Exp_Ind[5][9]):
            (Exp_Ind[0][5] + Exp_Ind[0][8]) * 5.0 /
            (Exp_Ind[1][5]+Exp_Ind[1][8]+Exp_Ind[2][5]+Exp_Ind[2][8]+Exp_Ind[3][5]+Exp_Ind[3][8]+Exp_Ind[4][5]+Exp_Ind[4][8]+Exp_Ind[5][5]+Exp_Ind[5][8]);
Alert("*** Exp_Ind - " + DoubleToStr(Exp_Ind[0][5]+Exp_Ind[0][8], 3) + " - " + DoubleToStr(Exp_Ind[0][6]+Exp_Ind[0][9], 3) + " - " +
   DoubleToStr(Exp_Ind[1][5]+Exp_Ind[1][8], 3) + " - " + DoubleToStr(Exp_Ind[1][6]+Exp_Ind[1][9], 3) + " - " + DoubleToStr(dtmp, 2) + " - " +
   (Sel2? "dn": "up") + " - " + TimeToStr(Exp_Ind[0][20], TIME_DATE|TIME_MINUTES) + " - " + TimeToStr(Time[0], TIME_DATE|TIME_MINUTES) + " ***");
         if (Period() >= 240 && (! t_BxClo || f_wBars(t_BxClo, TimeCurrent()) > 2/* * Period() * 60*/) && ((Sel2 && Bid > TP && Bid < SL) || (! Sel2 && Ask > SL && Ask < TP))) {
            if (dtmp < 4.5) { ticket = mOrderSend(Symbol(), Sel2, 0.01, Sel2? Bid: Ask, 5, SL, TP, NULL, 0, 0, clrNONE);
               CreateHLine(SL, false, Time[0]);             CreateHLine(TP, true, Time[0]);
               CP_tims[4] = Time[0]; }       else  tim_ex2 = Time[0];         t_box = false;       t_Send = false; } }
      if (Period() >= 240 || (dtmp > 4.5 && (! t_CPEPA || dtmp > 8.5))) return;           // * 11-05-2022 : 15h 50 (-> 8.5) *
      else if (! t_CPEPA) { int k, k1, k2, k3, k4, k5, k6;     k1 = exp_up? exp_up - 1: 2;      k2 = exp_up == 2? 0: exp_up + 1;       k3 = exp_up;
         k4 = exp_dn? exp_dn - 1: 2;         k5 = exp_dn == 2? 0: exp_dn + 1;          k6 = exp_dn;
         if ((Exp_Ind2[k1][0] > 4.5 && fabs((Bid + Ask) / 2.0 - (Sel2? iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, iBarShift(NULL, 0, Exp_Ind2[k1][1]) + 5, 0)):
         iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, iBarShift(NULL, 0, Exp_Ind2[k1][1]) + 5, 0)))) < (iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH,
         iBarShift(NULL, 0, Exp_Ind2[k1][1]) + 5)) - iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, iBarShift(NULL, 0, Exp_Ind2[k1][1]) + 5))) / 5.0 &&
         f_wBars(Exp_Ind2[k1][1], TimeCurrent()) < 7 * 24/* * Period() * 60*/ && Buy) ||
         (Exp_Ind2[k2][0] > 4.5 && fabs((Bid + Ask) / 2.0 - (Sel2? iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, iBarShift(NULL, 0, Exp_Ind2[k2][1]) + 5, 0)):
         iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, iBarShift(NULL, 0, Exp_Ind2[k2][1]) + 5, 0)))) < (iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH,
         iBarShift(NULL, 0, Exp_Ind2[k2][1]) + 5)) - iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, iBarShift(NULL, 0, Exp_Ind2[k2][1]) + 5))) / 5.0 &&
         f_wBars(Exp_Ind2[k2][1], TimeCurrent()) < 7 * 24/* * Period() * 60*/ && Buy) ||
         (Exp_Ind2[k3][0] > 4.5 && fabs((Bid + Ask) / 2.0 - (Sel2? iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, iBarShift(NULL, 0, Exp_Ind2[k3][1]) + 5, 0)):
         iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, iBarShift(NULL, 0, Exp_Ind2[k3][1]) + 5, 0)))) < (iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH,
         iBarShift(NULL, 0, Exp_Ind2[k3][1]) + 5)) - iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, iBarShift(NULL, 0, Exp_Ind2[k3][1]) + 5))) / 5.0 &&
         f_wBars(Exp_Ind2[k3][1], TimeCurrent()) < 7 * 24/* * Period() * 60*/ && Buy) ||
         (Exp_Ind3[k4][0] > 4.5 && fabs((Bid + Ask) / 2.0 - (Sel2? iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, iBarShift(NULL, 0, Exp_Ind3[k4][1]) + 5, 0)):
         iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, iBarShift(NULL, 0, Exp_Ind3[k4][1]) + 5, 0)))) < (iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH,
         iBarShift(NULL, 0, Exp_Ind3[k4][1]) + 5)) - iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, iBarShift(NULL, 0, Exp_Ind3[k4][1]) + 5))) / 5.0 &&
         f_wBars(Exp_Ind3[k4][1], TimeCurrent()) < 7 * 24/* * Period() * 60*/ && Sell) ||
         (Exp_Ind3[k5][0] > 4.5 && fabs((Bid + Ask) / 2.0 - (Sel2? iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, iBarShift(NULL, 0, Exp_Ind3[k5][1]) + 5, 0)):
         iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, iBarShift(NULL, 0, Exp_Ind3[k5][1]) + 5, 0)))) < (iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH,
         iBarShift(NULL, 0, Exp_Ind3[k5][1]) + 5)) - iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, iBarShift(NULL, 0, Exp_Ind3[k5][1]) + 5))) / 5.0 &&
         f_wBars(Exp_Ind3[k5][1], TimeCurrent()) < 7 * 24/* * Period() * 60*/ && Sell) ||
         (Exp_Ind3[k6][0] > 4.5 && fabs((Bid + Ask) / 2.0 - (Sel2? iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, iBarShift(NULL, 0, Exp_Ind3[k6][1]) + 5, 0)):
         iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, iBarShift(NULL, 0, Exp_Ind3[k6][1]) + 5, 0)))) < (iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH,
         iBarShift(NULL, 0, Exp_Ind3[k6][1]) + 5)) - iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, iBarShift(NULL, 0, Exp_Ind3[k6][1]) + 5))) / 5.0 &&
         f_wBars(Exp_Ind3[k6][1], TimeCurrent()) < 7 * 24/* * Period() * 60*/ && Sell)/*) && ! tst5) &&
         ((Buy && fmax(Exp_Ind2[k1][0], fmax(Exp_Ind2[k2][0], Exp_Ind2[k3][0])) > fmax(Exp_Ind3[k4][0], fmax(Exp_Ind3[k5][0], Exp_Ind3[k6][0]))) ||
         (Sell && fmax(Exp_Ind2[k1][0], fmax(Exp_Ind2[k2][0], Exp_Ind2[k3][0])) < fmax(Exp_Ind3[k4][0], fmax(Exp_Ind3[k5][0], Exp_Ind3[k6][0]))))*/) {
Alert("*** Exp_Ind (2) -k1" + (Exp_Ind2[k1][0] > 4.5? "(*) ": " ")+k1+" - "+ DoubleToStr(Exp_Ind[k1][5]+Exp_Ind[k1][8],3) +" - "+ DoubleToStr(Exp_Ind[k1][6]+Exp_Ind[k1][9],3)+" - "+
   DoubleToStr(Exp_Ind2[k1][0], 2) + " - " + ((k=Exp_Ind2[k1][2])>0? k==2? "dn": "up": "°") + " - " + TimeToStr(Exp_Ind2[k1][1], TIME_DATE|TIME_MINUTES) + " -k2" +
   (Exp_Ind2[k2][0] > 4.5? "(*) ": " ") + k2 + " - " + DoubleToStr(Exp_Ind[k2][5]+Exp_Ind[k2][8], 3) + " - " + DoubleToStr(Exp_Ind[k2][6]+Exp_Ind[k2][9], 3) + " - " +
   DoubleToStr(Exp_Ind2[k2][0], 2) + " - " + ((k=Exp_Ind2[k2][2])>0? k==2? "dn": "up": "°") + " - " + TimeToStr(Exp_Ind2[k2][1], TIME_DATE|TIME_MINUTES) + " -k3" +
   (Exp_Ind2[k3][0] > 4.5? "(*) ": " ") + k3 + " - " + DoubleToStr(Exp_Ind[k3][5]+Exp_Ind[k3][8], 3) + " - " + DoubleToStr(Exp_Ind[k3][6]+Exp_Ind[k3][9], 3) + " - " +
   DoubleToStr(Exp_Ind2[k3][0], 2) + " - " + ((k=Exp_Ind2[k3][2])>0? k==2? "dn": "up": "°") + " - " + TimeToStr(Exp_Ind2[k3][1], TIME_DATE|TIME_MINUTES) + " -k4" +     //: " -up : vide") +
   (Exp_Ind3[k4][0] > 4.5? "(*) ": " ") + k4 + " - " + DoubleToStr(Exp_Ind[k4][5]+Exp_Ind[k4][8], 3) + " - " + DoubleToStr(Exp_Ind[k4][6]+Exp_Ind[k4][9], 3) + " - " +
   DoubleToStr(Exp_Ind3[k4][0], 2) + " - " + ((k=Exp_Ind3[k4][2])>0? k==2? "dn": "up": "°") + " - " + TimeToStr(Exp_Ind3[k4][1], TIME_DATE|TIME_MINUTES) + " -k5" +
   (Exp_Ind3[k5][0] > 4.5? "(*) ": " ") + k5 + " - " + DoubleToStr(Exp_Ind[k5][5]+Exp_Ind[k5][8], 3) + " - " + DoubleToStr(Exp_Ind[k5][6]+Exp_Ind[k5][9], 3) + " - " +
   DoubleToStr(Exp_Ind3[k5][0], 2) + " - " + ((k=Exp_Ind3[k5][2])>0? k==2? "dn": "up": "°") + " - " + TimeToStr(Exp_Ind3[k5][1], TIME_DATE|TIME_MINUTES) + " -k6" +
   (Exp_Ind2[k6][0] > 4.5? "(*) ": " ") + k6 + " - " + DoubleToStr(Exp_Ind[k6][5]+Exp_Ind[k6][8], 3) + " - " + DoubleToStr(Exp_Ind[k6][6]+Exp_Ind[k6][9], 3) + " - " +
   DoubleToStr(Exp_Ind3[k6][0], 2) + " - " + ((k=Exp_Ind3[k6][2])>0? k==2? "dn": "up": "°") + " - " + TimeToStr(Exp_Ind3[k6][1], TIME_DATE|TIME_MINUTES) + " -M " +     //" -dn : vide") +
   DoubleToStr(fmax(Exp_Ind2[k1][0],fmax(Exp_Ind2[k2][0],Exp_Ind2[k3][0])),3)+" - "+DoubleToStr(fmax(Exp_Ind3[k4][0],fmax(Exp_Ind3[k5][0],Exp_Ind3[k6][0])),3) + " - " +
   TimeToStr(Time[0], TIME_DATE|TIME_MINUTES) + " ***");             return; }/*         else
Alert("*** Exp_Ind (-) -k1 " + k1 + " - " + DoubleToStr(Exp_Ind2[k1][0], 2) + " - " + ((k=Exp_Ind2[k1][2])>0?k==2?"dn":"up":"°") + " -k2 " + k2 + " - " + DoubleToStr(Exp_Ind2[k2][0], 2) +
   " - " + ((k=Exp_Ind2[k2][2])>0? k==2? "dn": "up": "°") + " -k3 " + k3 + " - " + DoubleToStr(Exp_Ind2[k3][0], 2) + " - " + ((k=Exp_Ind2[k3][2])>0? k==2? "dn": "up": "°") +
   " -k4 " + k4 + " - " + DoubleToStr(Exp_Ind3[k4][0], 2) + " - " + ((k=Exp_Ind3[k4][2])>0? k==2? "dn": "up": "°") + " -k5 " + k5 + " - " + DoubleToStr(Exp_Ind3[k5][0], 2) + " - " +
   ((k=Exp_Ind3[k5][2])>0? k==2? "dn": "up": "°") + " -k6 " + k6 + " - " + DoubleToStr(Exp_Ind3[k6][0], 2) + " - " + ((k=Exp_Ind3[k6][2])>0? k==2? "dn": "up": "°") + " ***");*/ } }
   if (t_CPClose) t_CPClose = false;

   if ((t_exp3 && Sell) || (t_exp4 && Buy)) { t_exp3 = false;        t_exp4 = false; }
   if ((t_exp3 && Buy) || (t_exp4 && Sell) || (t_exp3=(Exp_Inds2() && ((Sel2 && Sell) || (! Sel2 && Buy)))) || f_wBars(tim_ex2, TimeCurrent()) < 2/* * Period() * 60*/) {
Alert("******* Exp_Inds2 - " + t_exp3 + " - " + t_exp4 + " - " + Buy + " - " + Sell + " *******");
      t_exp4 = t_exp3 && Sell;         t_exp3 = t_exp3 && Buy;       return; }

   int cpt=0;     while((SpTr=SuperTrend(iBarShift(NULL, 0, CP_tim) + cpt)) == 2147483647) cpt ++;
   cpt = 0;       while(((Sel2 && SpTr < SuperTrend(iBarShift(NULL, 0, CP_tim) - cpt - 2)) ||
   (! Sel2 && SpTr > SuperTrend(iBarShift(NULL, 0, CP_tim) - cpt - 2)) || SpTr == 2147483647) &&
   cpt < iBarShift(NULL, 0, CP_tim)) { SpTr = SuperTrend(iBarShift(NULL, 0, CP_tim) - cpt);
      cpt ++; }         SpTr = SuperTrend(iBarShift(NULL, 0, CP_tim) - cpt);
   if (ticket < 0 || (! OrdersTotal() && ticket)) { ticket_ = ticket;         ticket = 0; }

   for (obj = 0; obj < ObjectsTotal(); obj ++) { name = ObjectName(obj);
      if (((Sel2 && StringFind(name, "liquid_Sell") > 0) || (! Sel2 && StringFind(name, "liquid_buy") > 0)) &&
      CP_tim - ObjectGet(name, OBJPROP_TIME1) < min && CP_tim > ObjectGet(name, OBJPROP_TIME1)) {
         min = CP_tim - ObjectGet(name, OBJPROP_TIME1);              x_obj = name; } }

   SL = ((Sel2 && ObjectGet(x_obj, OBJPROP_PRICE1) > SpTr) || (! Sel2 && ObjectGet(x_obj, OBJPROP_PRICE1) < SpTr)?
      ObjectGet(x_obj, OBJPROP_PRICE1): SpTr) + (Sel2? 1.0: -1.0) * 22 * Point();
   if (ObjectGet(x_obj, OBJPROP_TIME2) < CP_tim) SL = Sel2? iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 
      iBarShift(NULL, 0, ObjectGet(x_obj, OBJPROP_TIME2)) - iBarShift(NULL, 0, CP_tim), iBarShift(NULL, 0, CP_tim))):
      iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, iBarShift(NULL, 0, ObjectGet(x_obj, OBJPROP_TIME2)) -
      iBarShift(NULL, 0, CP_tim), iBarShift(NULL, 0, CP_tim))) + (Sel2? 1.0: -1.0) * 22 * Point();
   if (fabs((Sel2? Bid: Ask) - SL) > 0.01495 * (Sel2? Bid: Ask)) SL = (Sel2? Bid: Ask) * (Sel2? 1.01495: 0.98505);
   CreateHLine(SL, false, CP_tim);        //if (! ) return;

   bool tst1, tst2, tst4;     min = 5000000;       string x_objs[];     ArrayResize(x_objs, ObjectsTotal() / 2);        cpt = 0;
   for (obj = 0; obj < ObjectsTotal(); obj ++) { name = ObjectName(obj);
      if (((ObjectGet(name, OBJPROP_PRICE1) < SpTr && ObjectGet(name, OBJPROP_PRICE1) < iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)) -
      22 * Point() && Sel2 && (StringFind(name, "liquid_buy") > 0 || (StringFind(name, "BoxLine") > 0 &&
      f_wBars(ObjectGet(name, OBJPROP_TIME1), CP_tim) > 24/* * Period() * 60*/ && ObjectGet(name, OBJPROP_PRICE1) < iLow(NULL,
      0, iBarShift(NULL, 0, CP_tim)) - 22 * Point()))) || (! Sel2 && (StringFind(name, "liquid_Sell") > 0 ||
      (StringFind(name, "BoxLine") > 0 && f_wBars(ObjectGet(name, OBJPROP_TIME1), CP_tim) > 24/* * Period() * 60*/ &&
      ObjectGet(name, OBJPROP_PRICE1) > iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)))) &&
      ObjectGet(name, OBJPROP_PRICE1) > iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)) + 22 * Point() &&
      ObjectGet(name, OBJPROP_PRICE1) > SpTr)) && ((tst1=(CP_tim - ObjectGet(name, OBJPROP_TIME1) < min)) ||
      ((tst2=((Sel2 && iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)) - ObjectGet(name, OBJPROP_PRICE1) < min2) ||
      (! Sel2 && ObjectGet(name, OBJPROP_PRICE1) - iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)) < min2))))) &&
      CP_tim > ObjectGet(name, OBJPROP_TIME1)) { if (tst1) min = CP_tim - ObjectGet(name, OBJPROP_TIME1);
         if (tst2) min2 = (Sel2? iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)) - ObjectGet(name, OBJPROP_PRICE1):
            ObjectGet(name, OBJPROP_PRICE1) - iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)));      x_objs[cpt] = x_obj2;
         if ((tst2 || (tst1 && ((Sel2 && iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)) - ObjectGet(name, OBJPROP_PRICE1) <
         iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)) - ObjectGet(x_objs[cpt], OBJPROP_PRICE1)) || (! Sel2 && ObjectGet(name,
         OBJPROP_PRICE1) - iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)) < ObjectGet(x_objs[cpt], OBJPROP_PRICE1) - iHigh(NULL, 0,
         iBarShift(NULL, 0, CP_tim))) || x_objs[cpt] == "" || StringFind(name, "BoxLine") > 0))) &&
         (ObjectGet(name, OBJPROP_TIME2) >= CP_tim || StringFind(name, "BoxLine") > 0)) { x_obj2 = name;       cpt ++; } } }
if (CP_tims[2] != CP_tim)
Alert("**1* " + x_obj2 + " - " + DoubleToStr(TP, Digits()) + " - " + DoubleToStr(ObjectGet(x_obj2, OBJPROP_PRICE1), Digits()) + " - " + TimeToStr(ObjectGet(x_obj2, OBJPROP_TIME1), TIME_DATE|TIME_MINUTES) + " - " +
   TimeToStr(ObjectGet(x_obj2, OBJPROP_TIME2), TIME_DATE|TIME_MINUTES) + " - " + TimeToStr(CP_tim, TIME_DATE|TIME_MINUTES) + " - " + tst1 + " - " + tst2 + " - " + tst4 + " ***");

   double TP2;       bool alt2=false, tst3=false;        string tmp="";       tst = false;
   TP = (TP2=ObjectGet(x_obj2, OBJPROP_PRICE1)) + (Sel2? 1.0: -1.0) * 12 * Point();
   while((tst4=(fabs(TP - iClose(NULL, 0, iBarShift(NULL, 0, CP_tim))) < 0.75 * fabs(SpTr - iClose(NULL, 0, iBarShift(NULL, 0, CP_tim))) ||
   (Sel2 && Bid < TP + 12 * Point()) || (! Sel2 && Ask > TP - 12 * Point()))) && cpt) { min2 = 500000.0;
      if (alt2) { for (int ob=0; ob < ArraySize(x_objs); ob ++) if (StringFind(tmp, IntegerToString(ob) + "|") < 0 &&
         ! (fabs(TP - iClose(NULL, 0, iBarShift(NULL, 0, CP_tim))) < 0.75 * fabs(SpTr - iClose(NULL, 0, iBarShift(NULL, 0, CP_tim))) ||
         (tst=((Sel2 && Bid < TP + 12 * Point()) || (! Sel2 && Ask > TP - 12 * Point()))))) { tst3 = tst || tst3? true: false;
            name = x_objs[ob];      if ((Sel2 && iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)) - ObjectGet(name, OBJPROP_PRICE1) < min2) ||
            (! Sel2 && ObjectGet(name, OBJPROP_PRICE1) - iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)) < min2)) {
               tmp += IntegerToString(ob) + "|";      min2 = (Sel2? iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)) - ObjectGet(name, OBJPROP_PRICE1):
                  ObjectGet(name, OBJPROP_PRICE1) - iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)));         cpt = ob; } }        x_obj2 = x_objs[cpt]; }
      TP = (alt2? (TP2=ObjectGet(x_objs[cpt], OBJPROP_PRICE1)) + (Sel2? 1.0: -1.0) * 12 * Point(): TP2);       if (! alt2) cpt --;
      alt2 = alt2? false: true; }               if (tst || tst3) { tst = false;
      for (ob = 0; ob < ObjectsTotal() && ! tst; ob ++) { string name2=ObjectName(ob);
         tst = StringFind(name2, "rect") > 0 && ObjectType(name2) == OBJ_RECTANGLE && ObjectGet(name2, OBJPROP_TIME2) ==
            ObjectGet(x_obj2, OBJPROP_TIME2) && StringSubstr(x_obj2, StringFind(x_obj2, "BoxLine") + 7, 16) ==
            StringSubstr(name2, StringFind(name2, "rect") + 4, 16)/* && ObjectGet(name2, OBJPROP_COLOR) != 5789784*/; }
      if (tst) TP = (Sell? ObjectGet(name2, OBJPROP_PRICE1): ObjectGet(name2, OBJPROP_PRICE2)) + (Sel2? 1.0: -1.0) * 12 * Point(); }
   else if (alt2) TP += (Sel2? 1.0: -1.0) * 12 * Point();         min2 = 500000.0;        tst = false;         tst3 = false;
   for (ob = 0; ob < ObjectsTotal()/* && ! tst*/; ob ++) { name2 = ObjectName(ob);
      tst = StringFind(name2, "BoxLine") > 0 && ObjectType(name2) == OBJ_TREND && ObjectGet(name2, OBJPROP_TIME1) > ObjectGet(x_obj2, OBJPROP_TIME1) &&
         ObjectGet(name2, OBJPROP_TIME1) < CP_tim && ! ((Sel2 && Bid < ObjectGet(name2, OBJPROP_PRICE1) + 12 * Point()) ||
         (! Sel2 && Ask > ObjectGet(name2, OBJPROP_PRICE1) - 12 * Point())) && fabs(ObjectGet(name2, OBJPROP_PRICE1) - iClose(NULL, 0,
         iBarShift(NULL, 0, CP_tim))) < fabs(ObjectGet(x_obj2, OBJPROP_PRICE1) - iClose(NULL, 0, iBarShift(NULL, 0, CP_tim))) &&
         fabs(ObjectGet(name2, OBJPROP_PRICE1) - iClose(NULL, 0, iBarShift(NULL, 0, CP_tim))) > (t_Adx? 0.4: 0.75) * fabs(SpTr - iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)));
      if (tst && fabs(ObjectGet(name2, OBJPROP_PRICE1) - iClose(NULL, 0, iBarShift(NULL, 0, CP_tim))) < min2) { x_obj2 = name2;
         min2 = fabs(ObjectGet(name2, OBJPROP_PRICE1) - iClose(NULL, 0, iBarShift(NULL, 0, CP_tim))); }        tst3 = tst || tst3? true: false; }
   if (tst || tst3) { tst = false;           for (ob = 0; ob < ObjectsTotal() && ! tst; ob ++) { name2 = ObjectName(ob);
         tst = StringFind(name2, "rect") > 0 && ObjectType(name2) == OBJ_RECTANGLE && ObjectGet(name2, OBJPROP_TIME2) ==
            ObjectGet(x_obj2, OBJPROP_TIME2) && StringSubstr(x_obj2, StringFind(x_obj2, "BoxLine") + 7, 16) ==
            StringSubstr(name2, StringFind(name2, "rect") + 4, 16)/* && ObjectGet(name2, OBJPROP_COLOR) != 5789784*/; }
      if (tst) TP = (Sell? ObjectGet(name2, OBJPROP_PRICE1): ObjectGet(name2, OBJPROP_PRICE2)) + (Sel2? 1.0: -1.0) * 12 * Point(); }//      CreateHLine(TP, true, CP_tim);
/*      if ((Sel2 && TP < iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, 160, iBarShift(NULL, 0, CP_tim)))) ||
      (! Sel2 && TP > iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 160, iBarShift(NULL, 0, CP_tim))))) TP = (Sel2? iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, 160, iBarShift(NULL, 0, CP_tim))):
            iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 160, iBarShift(NULL, 0, CP_tim)))) + (Sel2? 1.0: -1.0) * 12 * Point();         CreateHLine(TP, true, CP_tim); */
//if (StringFind(TimeToStr(CP_tim, TIME_DATE|TIME_MINUTES), "04.06 04:00") > 0)
if (CP_tims[2] != CP_tim)
Alert("**2* " + x_obj2 + " - " + DoubleToStr(TP, Digits()) + " - " + DoubleToStr(ObjectGet(x_obj2, OBJPROP_PRICE1), Digits()) + " - " + TimeToStr(ObjectGet(x_obj2, OBJPROP_TIME1), TIME_DATE|TIME_MINUTES) + " - " +
   TimeToStr(ObjectGet(x_obj2, OBJPROP_TIME2), TIME_DATE|TIME_MINUTES) + " - " + TimeToStr(CP_tim, TIME_DATE|TIME_MINUTES) + " - " + tst1 + " - " + tst2 + " - " + tst4 + " ***");

   if ((Sel2 && TP > Bid) || (! Sel2 && TP < Ask)) TP = iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)) + (Sel2? -0.01: 0.01) * iClose(NULL, 0, iBarShift(NULL, 0, CP_tim));
   if ((Sel2 && SL < Ask) || (! Sel2 && SL > Bid)) SL = iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)) - (Sel2? -0.01: 0.01) * iClose(NULL, 0, iBarShift(NULL, 0, CP_tim));
   if ((Sel2 && SL < Ask) || (! Sel2 && SL > Bid) || (Sel2 && TP > Bid) || (! Sel2 && TP < Ask)) return;          ResetLastError();          CreateHLine(TP, true, CP_tim);
   if (t_Send && ! ticket) { if (t_P60b && ticket_ && OrderSelect(ticket_, SELECT_BY_TICKET)) { SL = OrderOpenPrice();           TP = OrderTakeProfit();
         dtmp = Sel2? t_P60b? ObjectGet(namBox, OBJPROP_PRICE2) - 12 * Point(): Bid: t_P60b? ObjectGet(namBox, OBJPROP_PRICE1) + 12 * Point(): Ask;
//Alert("*** mOrderSend(0) - " + Buy + " - " + Sell + " - " + Sel2 + " - " + namBox + " - " + t_P60b + " - " + dtmp + " - " + SL + " - " + TP + " - " + TimeToStr(CP_tim, TIME_DATE|TIME_MINUTES) + " ***");
         if ((Sel2 && SL < dtmp) || (! Sel2 && SL > dtmp) || (Sel2 && TP > dtmp) || (! Sel2 && TP < dtmp)) {
            if (t_CPEPA) { dtmp = SL;        SL = TP;          TP = dtmp;           d_EppCl = 0.001; }
            else { t_BH2 = false;         t_P60 = false;         t_P60b = false;         return; } }
         double SL_=SL;       tst = false;      for (obj = 0; obj < ObjectsTotal() && ! tst; obj ++) { name = ObjectName(obj);
            tst = ((Sel2 && name == "RSLinesR1") || (! Sel2 && name == "RSLinesS1")) && ObjectType(name) == OBJ_TREND/* &&
               ObjectGet(name, OBJPROP_TIME1) > CP_tims[0] && CP_tims[0]*/; }
         if (tst) SL = (Sel2? fmax(SL, ObjectGet(name, OBJPROP_PRICE1)): fmin(SL, ObjectGet(name, OBJPROP_PRICE1))) + (Sel2? -1.0: 1.0) * 12 * Point();
         if ((Sel2 && SL < Ask) || (! Sel2 && SL > Bid)) SL = SL_; }             else  dtmp = Sel2? Bid: Ask;              int itmp=ticket;
      if ((! t_MP && ! t_VtRtn && ((Sel2 && StringFind(x_obj2, "liquid_buy") > 0) || (! Sel2 && StringFind(x_obj2, "liquid_sell") > 0))) ||
      (f_wBars(tim_Str5d, TimeCurrent()) > 24 && ((Sel2 && Buy3 && iCustom(NULL, 0, "Parabolic.ex4", 0, 1) < Bid && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 1) &&
      iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 1) < iCustom(NULL, 0, "Parabolic.ex4", 0, 1) && f_wBars(tim_STCr4, TimeCurrent()) < 7) ||
      (! Sel2 && Sell3 && iCustom(NULL, 0, "Parabolic.ex4", 0, 1) > Ask && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 1) != 2147483647.0 &&
      iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 1) > iCustom(NULL, 0, "Parabolic.ex4", 0, 1) && f_wBars(tim_STCr4, TimeCurrent()) < 7)))) {
         Sel2 = ! Sel2;          dtmp = SL;           SL = TP;          TP = dtmp;           d_EppCl = 0.001; }
      if ((Sel2 && TP > dtmp - 22 * Point()) || (! Sel2 && TP < dtmp + 22 * Point())) TP += (Sel2? -1.0: 1.0) * 100 * Point();
      if ((Sel2 && TP > Bid - 22 * Point()) || (! Sel2 && TP < Ask + 22 * Point())) TP += (Sel2? -1.0: 1.0) * fabs(TP - dtmp);
      if ((Sel2 && SL < Ask + 22 * Point()) || (! Sel2 && SL > Bid - 22 * Point())) SL += (Sel2? 1.0: -1.0) * 100 * Point();
      if (t_STCr3) { TP = (Sel2? Bid: Ask) + (Sel2? -1.0: 1.0) * 100 * Point();
         SL = Sel2? iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 1) + 22 * Point(): iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 1) - 22 * Point(); }
      tst = tick_st && OrderSelect(tick_st, SELECT_BY_TICKET) && OrderCloseTime() && f_wBars(OrderCloseTime(), TimeCurrent()) < 15 &&
         ((Sel2 && (OrderType() % 2) > 0) || (! Sel2 && ! (OrderType() % 2))) && ! (t_Star5 && t_Adx2 && t_Atr && t_Rsi) && ! t_PBk && OTS;
// OTS = option d'invalidation des tickets après un Ordre Stop récent -> 04-05-2022 autour de 10h20
      if (((! tst && (! (OP_ST=(((Bid < iCustom(NULL, 0, "Bands.ex4", 2, 0) || t_MP2) && Sel2 && Bid < (iLow(NULL, 0, iLowest(NULL, 0,
      MODE_LOW, 12, 0)) + (iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 12, 0)) - iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, 12, 0))) * (t_Star5 || t_PBk? 0.05: 0.25))) ||
      ((Ask > iCustom(NULL, 0, "Bands.ex4", 1, 0) || t_MP2) && ! Sel2 && Ask > (iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 12, 0)) -        // * 06-05-2022 : 9h 55 *
      (iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 12, 0)) - iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, 12, 0))) * (t_Star5 || t_PBk? 0.05: 0.25))))))) || (t_CPEPA &&
      (! t_MP2 || f_wBars(tim_Str5c, TimeCurrent()) > 1))) && iCustom(NULL, 0, "ind Profil Marché (de CMA).ex4", 0, 1) < 85.0 &&
      iCustom(NULL, 0, "ind Profil Marché (de CMA).ex4", 2, 1) < 55.0 && (! tim_Rng || f_wBars(tim_Str5c, TimeCurrent()) > 1 ||              // * 11-05-2022 : 15h 35 *
      (t_Rng1 && ((Sel2? Bid: Ask) > iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, 48, 0)) + (R1 - iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, 48, 0))) * 3.0 / 4.0 ||
      (Sel2? Bid: Ask) < iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, 48, 0)) + (R1 - iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, 48, 0))) / 4.0)) ||
      (t_Rng2 && ((Sel2? Bid: Ask) > iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 48, 0)) - (iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 48, 0)) - S1) / 4.0 ||
      (Sel2? Bid: Ask) < iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 48, 0)) - (iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 48, 0)) - S1) * 3.0 / 4.0)))) {
        if (t_Star5 && t_Adx2 && t_Atr && t_Rsi) { t_PBk = Sel2 + 1;          d_PBk = SL;       tim_PBk = TimeCurrent();      t_nSTO = false; }          bool tst6=false;
//        if ((Sel2 && iClose(NULL, 0, 1) < iCustom(NULL, 0, "Parabolic.ex4", 0, 1)) || (! Sel2 && iClose(NULL, 0, 1) > iCustom(NULL, 0, "Parabolic.ex4", 0, 1)))
//        if ((Sel2 && Bid < iCustom(NULL, 0, "Parabolic.ex4", 0, 0)) || (! Sel2 && Ask > iCustom(NULL, 0, "Parabolic.ex4", 0, 0)))
        if ((! t_ATSEP && ! t_ATSEP2) || iCustom(NULL, 0, "New folder\\ADX.ex4", 7, 0, 1) > 45.0)
/*      if (((! t_ATSEP && ! t_ATSEP2) || iCustom(NULL, 0, "New folder\\ADX.ex4", 7, 0, 1) > 45.0 || t_STCr3) && (! t_MP ||
        (((((Sel2 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 1) != 2147483647.0 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 1) > Ask) ||
        (! Sel2 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 1) && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 1) < Bid)) &&
        ((Sel2 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 0) != 2147483647.0 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 0) > Ask) ||
        (! Sel2 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 0) && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 0) < Bid))) ||       // * 06-05-2022 : 5h 10 *
        (t_PBk3=(! t_STCr3 && ((Sel2 && iCustom(NULL, 0, "Parabolic.ex4", 0, 1) > Ask) || (! Sel2 && iCustom(NULL, 0, "Parabolic.ex4", 0, 1) < Bid))))) &&
        (! ticket_b || (OrderSelect(ticket_b, SELECT_BY_TICKET) && OrderCloseTime() && f_wBars(OrderCloseTime(), TimeCurrent())))))) */
//      ! t_ATSEP = StrategyTester (9-tst6d).htm | ! t_ATSEP2 = StrategyTester (9-tst6e).htm | (! t_ATSEP && ! t_ATSEP2) = StrategyTester (9-tst6f).htm
         while(! t_PBk && ! tst6) { ticket = mOrderSend(Symbol(), Sel2 + (! t_CPEPA && t_P60b && ((Sel2 && dtmp > Ask) || (! Sel2 && dtmp < Bid))? 2: t_VtPBk? 4: 0), 0.01,
               ! t_CPEPA && t_P60b && ((Sel2 && dtmp > Ask) || (! Sel2 && dtmp < Bid))? dtmp: (Sel2? Bid: Ask) + (t_VtPBk? (Sel2? -1.0: 1.0) * 22 * Point(): 0.0), 5, SL, TP + (! t_CPEPA &&
               t_P60b? Sel2? -1.0: 1.0: 0.0) * fabs(TP-dtmp), NULL, 0, ! t_CPEPA && t_P60b && ((Sel2 && dtmp > Ask) || (! Sel2 && dtmp < Bid))? Time[0] + 7*Period() * 60: 0, clrNONE);
            if (ticket > 0) { CP_tims[0] = CP_tim? CP_tim: Time[0];     CP_tims[4] = 0;      t_box = true;        tick_st = 0;      t_nSTO = false;
               tim1 = TimeCurrent();         t_Sent = true;       Bull = ! Sel2;       if (t_box4) { t_box = false;        t_box4 = false; }
               if (Period() <= 60 && OrderSelect(ticket, SELECT_BY_TICKET) && fabs(OrderTakeProfit() - OrderOpenPrice()) < 0.0125 * OrderOpenPrice()) {
                  dtmp = OrderOpenPrice() + (OrderTakeProfit() - OrderOpenPrice()) * 2.0;          if (OrderModify(ticket, OrderOpenPrice(), OrderStopLoss(),
                     (TP=Sel2? fmax(0.9875 * OrderOpenPrice(), dtmp): fmin(1.0125 * OrderOpenPrice(), dtmp)), 0, clrNONE)) CreateHLine(TP, true, CP_tim); }
               if (Period() <= 60 && OrderSelect(ticket, SELECT_BY_TICKET) && iCustom(NULL, 0, "ind Profil Marché (de CMA).ex4", 0, 1) > 75.0) {
                  TP = Sel2? iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, 12, 0)) + 22 * Point(): iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 12, 0)) - 22 * Point();
                  if (OrderModify(ticket, OrderOpenPrice(), OrderOpenPrice() + (Sel2? 1.0: -1.0) * fabs(OrderOpenPrice() - TP), TP, 0, clrNONE)) {} }
               if (t_ATSEP2 && iCustom(NULL, 0, "New folder\\ADX.ex4", 14, 0, 1) > 45.0 && OrderSelect(ticket, SELECT_BY_TICKET) &&
               OrderModify(ticket, OrderOpenPrice(), iCustom(NULL, 0, "Parabolic.ex4", 0, 1), OrderTakeProfit(), 0, clrNONE)) {}
               tst6 = true;            if (t_CPEP2) d_EppCl = 0.001;       if (t_CPEP) t_CPEP3 = true;               if (CP_tims[2] != CP_tim || itmp != ticket)
Alert("*** mOrderSend() OK! " + ticket + " - " + x_obj2 + " - " + DoubleToStr(Sel2? Bid: Ask, Digits()) + " - " + DoubleToStr(TP, Digits()) + " - " + TimeToStr(ObjectGet(x_obj2, OBJPROP_TIME1),
   TIME_DATE|TIME_MINUTES) + " - " + TimeToStr(ObjectGet(x_obj2, OBJPROP_TIME2), TIME_DATE|TIME_MINUTES) + " - " + TimeToStr(CP_tim, TIME_DATE|TIME_MINUTES) + " ***"); }
            else { Alert("******* mOrderSend() NO! " + GetLastError() + " - " + Buy + " - " + Sell + " - " + Sel2 + " - " + namBox + " - " + t_PBk + " - " + tst + " - " +
   t_P60b + " - " + dtmp + " - " + SL + " - " + TP + " - " + TimeToStr(CP_tim, TIME_DATE|TIME_MINUTES) + " *******");         if (! t_PBk)/*           ObjectsDelete(0, "EA_X-Line_");*/
         if ((Sel2 && SL < Bid + 15 * Point()) || (! Sel2 && SL > Ask - 15 * Point) || (Sel2 && TP > Bid - 15 * Point()) || (! Sel2 && TP < Ask + 15 * Point()) || t_VtPBk) {
Alert("******* mOrderSend() INV! (1) - " + namBox + " - " + SL + " - " + TP + " - " + TimeToStr(CP_tim, TIME_DATE|TIME_MINUTES) + " *******");    // * 03-05-2022 : 03h 40 *
            break;/*         Sel2 = ! Sel2;          dtmp = SL;           SL = TP;          TP = dtmp;*/           d_EppCl = 0.001; }      else {
//Alert: ******* mOrderSend() INV! (2) - ATS V4.0rect2022.05.03 08:10 - 0.97681 - 0.97563 - 2022.05.03 12:40 - 0 - 1 - 0.97763 - 0.97672 *******
Alert("******* mOrderSend() INV! (2) - " + namBox + " - " + SL + " - " + TP + " - " + TimeToStr(CP_tim, TIME_DATE|TIME_MINUTES) + " - " +
   (! t_CPEPA && t_P60b && ((Sel2 && dtmp > Ask) || (! Sel2 && dtmp < Bid))) + " - " + Sel2 + " - " +
   DoubleToStr(dtmp, Digits()) + " - " + DoubleToStr(Sel2? Bid: Ask, Digits()) + " *******");            break;/*f_End_EA(2);*/ } } } }
      else if (! tst && ! t_PBk) { tim_OPST = Time[0];      SL3 = SL;      TP3 = TP + (t_P60b? Sel2? -1.0: 1.0: 0.0) * fabs(TP - dtmp);
            t_PBk4 = (! t_Star5 && f_wBars(tim_Str5b, TimeCurrent()) > 12 && ! t_PBk && t_MP2 && f_wBars(tim_Str5c, TimeCurrent()) < 2); } }

   t_Send = false;         min = 5000000;          string x_obj3="";          tst = false;
   for (obj = 0; obj < ObjectsTotal(); obj ++) { name = ObjectName(obj);
      if (StringFind(name, "BoxLine") > 0 && ObjectType(name) == OBJ_TREND && ObjectGet(name, OBJPROP_TIME1) - CP_tim < min &&
      CP_tim < ObjectGet(name, OBJPROP_TIME1)) {/* for (ob = 0; ob < ObjectsTotal() && ! tst; ob ++) { string name2=ObjectName(ob);
            tst = StringFind(name2, "rect") > 0 && ObjectType(name2) == OBJ_RECTANGLE && ObjectGet(name2, OBJPROP_TIME2) ==
               ObjectGet(name, OBJPROP_TIME2) && StringSubstr(name, StringFind(name, "BoxLine") + 7, 16) ==
               StringSubstr(name2, StringFind(name2, "rect") + 4, 16) && ObjectGet(name2, OBJPROP_COLOR) != 5789784; }
         if (tst) {*/ min = ObjectGet(name, OBJPROP_TIME1) - CP_tim;         x_obj3 = name; } }// }
   if (ticket > 0 && ! t_PBk) t_CPClose = true;             if (CP_tims[2] != CP_tim)
Alert("*** BoxLine - " + x_obj3 + " - " + DoubleToStr(ObjectGet(x_obj3, OBJPROP_PRICE1), Digits()) + " - " +/* ObjectGet(name2, OBJPROP_COLOR) + " - " +*/
   TimeToStr(ObjectGet(x_obj3, OBJPROP_TIME1), TIME_DATE|TIME_MINUTES) + " - " + TimeToStr(ObjectGet(x_obj3, OBJPROP_TIME2), TIME_DATE|TIME_MINUTES) + " ***");

   double res;       tst = false;      tst1 = false;        tst2 = false;//        bool tst3;
   for (int bar=0; bar < fmin(300, iBarShift(NULL, 0, CP_tim)) && ! tst; bar ++) {
/*      if (! tst4 && (tst=((Sel2 && (iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim) - bar) > SL || iLow(NULL, 0, iBarShift(NULL, 0, CP_tim) - bar) < TP)) ||
      (! Sel2 && (iLow(NULL, 0, iBarShift(NULL, 0, CP_tim) - bar) < SL || iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim) - bar) > TP)))))
         res = (tst1=((Sel2 && iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim) - bar) > SL) ||
         (! Sel2 && iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim) - bar) > TP)))? (Sel2? 1.0: -1.0) * iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)) -
         (Sel2? 1.0: -1.0) * (Sel2? SL: TP): (tst2=((! Sel2 && iLow(NULL, 0, iBarShift(NULL, 0, CP_tim) - bar) < SL) ||
         (Sel2 && iLow(NULL, 0, iBarShift(NULL, 0, CP_tim) - bar) < TP)))? (Sel2? 1.0: -1.0) * iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)) -
         (Sel2? 1.0: -1.0) * (Sel2? TP: SL): 0.0;
      else */if (! tst4 && (tst=(tst3=((Sel2 && iCustom(NULL, 0, "New folder\\Manual Trade Cashpower Lifetime.ex4", 1, iBarShift(NULL, 0, CP_tim) - bar) > 0.0) ||
      (! Sel2 && iCustom(NULL, 0, "New folder\\Manual Trade Cashpower Lifetime.ex4", 0, iBarShift(NULL, 0, CP_tim) - bar) > 0.0))))) {
         res = (iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)) - iClose(NULL, 0, iBarShift(NULL, 0, CP_tim) - bar)) * (Sel2? 1.0: -1.0);

         if (OrderSelect(ticket, SELECT_BY_TICKET) && ((! OrderCloseTime() && ((OrderType() < 2 && mOrderClose(ticket, OrderLots(), Sel2? Bid: Ask, 5, clrNONE)) ||
         OrderDelete(ticket, clrNONE))) || OrderCloseTime())) { ticket_ = ticket;         ticket = 0;       CP_tim = 0;
Alert("*** CP tst3 Close - " + (iBarShift(NULL, 0, CP_tim) - bar) + " - " + TimeToStr(Time[iBarShift(NULL, 0, CP_tim) - bar], TIME_DATE|TIME_MINUTES) + " ***"); } }

      /*else */if (x_obj3 != "" && x_obj3 != NULL && (tst=(HA_Reverse(Sel2, iBarShift(NULL, 0, CP_tim) - bar) || (((Sel2 && iClose(NULL, 0, iBarShift(NULL, 0, CP_tim) - bar) > SpTr) ||
      (! Sel2 && iClose(NULL, 0, iBarShift(NULL, 0, CP_tim) - bar) < SpTr)) && bar) || (Time[iBarShift(NULL, 0, CP_tim) - bar] == ObjectGet(x_obj3, OBJPROP_TIME2) && CP_tim &&
      CP_tim < ObjectGet(x_obj3, OBJPROP_TIME1) && f_wBars(ObjectGet(x_obj3, OBJPROP_TIME2), TimeCurrent()) < 5/* * Period() * 60*/ &&
      ((bar > 1.5 * (iBarShift(NULL, 0, ObjectGet(x_obj, OBJPROP_TIME1)) - iBarShift(NULL, 0, CP_tim)) && bar > 14) || bar > 23))))) {
         res = (iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)) - iClose(NULL, 0, iBarShift(NULL, 0, CP_tim) - bar)) * (Sel2? 1.0: -1.0);
         SL = (Time[iBarShift(NULL, 0, CP_tim) - bar] == ObjectGet(x_obj3, OBJPROP_TIME2)?
            Sel2? iHigh(NULL, 0, iBarShift(NULL, 0, ObjectGet(x_obj3, OBJPROP_TIME2))):
            iLow(NULL, 0, iBarShift(NULL, 0, CP_tim) - bar): SpTr) + (Sel2? 1.0: -1.0) * 22 * Point();        bar --;

         ResetLastError();
         if (OrderSelect(ticket, SELECT_BY_TICKET) && ((! OrderCloseTime() && ((OrderType() < 2 && mOrderClose(ticket, OrderLots(), Sel2? Bid: Ask, 5, clrNONE)) ||
         OrderDelete(ticket, clrNONE))) || OrderCloseTime())) { ticket_ = ticket;         ticket = 0;       CP_tim = 0;
Alert("*** BoxLine Close - " + x_obj3 + " - " + DoubleToStr(ObjectGet(x_obj3, OBJPROP_PRICE1), Digits()) + " - " + TimeToStr(ObjectGet(x_obj3, OBJPROP_TIME2), TIME_DATE|TIME_MINUTES) + " ***"); }/*

         if (OrderSelect(ticket, SELECT_BY_TICKET) && ! OrderCloseTime() && OrderModify(ticket, OrderOpenPrice(), SL, OrderTakeProfit(), 0, clrNONE)) {}
         else  if (OrderSelect(ticket, SELECT_BY_TICKET) && OrderCloseTime()) ticket = 0;*/
         else if (GetLastError() == 138) { 
Alert("*** BoxLine Close (138) - " + x_obj3 + " - " + DoubleToStr(ObjectGet(x_obj3, OBJPROP_PRICE1), Digits()) + " - " + TimeToStr(ObjectGet(x_obj3, OBJPROP_TIME2), TIME_DATE|TIME_MINUTES) + " ***");
/*            f_End_EA(3);*/ } } }

/*   if (tst) { DrawArrow_chck(tst3 || (!tst1 && !tst2 && !tst3)? iClose(NULL, 0, iBarShift(NULL, 0, CP_tim) - (bar-1)): (! Sel2 && tst1) || (Sel2 && tst2)? TP: SL,
         iBarShift(NULL, 0, CP_tim) - (bar-1), ((! Sel2 && tst1) || (Sel2 && tst2) || (tst3 || (! tst1 && ! tst2 && ! tst3))) && res > 0.0, k);
      _k = k;        t_res += res;           if (res < 0.0) { ExpertRemove();             EventKillTimer();
      double TV=MarketInfo(Symbol(), MODE_TICKVALUE), TS=MarketInfo(Symbol(), MODE_TICKSIZE);            TV = TV < 0.1? 1.0: TV;
Alert("**2* RESULTAT " + (res > 0.0? "POSITIF, HOURA": "NEGATIF") + " ! - " + DoubleToStr(res, Digits()) + " - " + DoubleToStr(res / TS * TV * 0.01, Digits()) + " - " +
   DoubleToStr(SpTr, Digits()) + " - " + TimeToStr(Time[iBarShift(NULL, 0, CP_tim) - (bar-1)], TIME_DATE|TIME_MINUTES) + " - " + tst1 + " - " + tst2 + " - " + tst3 + " - " + tst4 +
   " - " + DoubleToStr(iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)), Digits()) + " - " + DoubleToStr(iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)), Digits()) +
   " - " + DoubleToStr(iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)), Digits()) + " - " + DoubleToStr(iClose(NULL, 0, iBarShift(NULL, 0, CP_tim) - bar+1), Digits()) +
   " - " + DoubleToStr(SL, Digits()) + " - " + DoubleToStr(TP, Digits()) + " ***"); } }*/ }

bool HA_Reverse(bool Sel2,int vBar) { int j=0, k=0;         return(false);
   bool ha1=HA_Bull(iOpen(NULL, 0, vBar), iClose(NULL, 0, vBar), iHigh(NULL, 0, vBar), iLow(NULL, 0, vBar), vBar),
      ha2=HA_Bull(iOpen(NULL, 0, vBar+1), iClose(NULL, 0, vBar+1), iHigh(NULL, 0, vBar+1), iLow(NULL, 0, vBar+1), vBar+1),
      ha3=HA_Bull(iOpen(NULL, 0, vBar+2), iClose(NULL, 0, vBar+2), iHigh(NULL, 0, vBar+2), iLow(NULL, 0, vBar+2), vBar+2),
      ha4=HA_Bull(iOpen(NULL, 0, vBar+3), iClose(NULL, 0, vBar+3), iHigh(NULL, 0, vBar+3), iLow(NULL, 0, vBar+3), vBar+3),
      ha5=HA_Bull(iOpen(NULL, 0, vBar+4), iClose(NULL, 0, vBar+4), iHigh(NULL, 0, vBar+4), iLow(NULL, 0, vBar+4), vBar+4),
      ha6=HA_Bull(iOpen(NULL, 0, vBar+5), iClose(NULL, 0, vBar+5), iHigh(NULL, 0, vBar+5), iLow(NULL, 0, vBar+5), vBar+5);
   if (! ha1) j ++;     if (! ha2) j ++;     if (! ha3) j ++;     if (! ha4) j ++;     if (! ha5) j ++;     if (! ha6) j ++;
   if (ha1) k ++;       if (ha2) k ++;       if (ha3) k ++;       if (ha4) k ++;       if (ha5) k ++;       if (ha6) k ++;
   return(((! Sel2 && ((! ha1 && ! ha2 && ! ha3 && ! ha4) || j > 4)) || (Sel2 && ((ha1 && ha2 && ha3 && ha4) || k > 4)))); }

bool HA_Bull(double vOpen, double vClose, double vHigh, double vLow, int vBar) {
   haOpen = vBar >= nBars - 1? vOpen: ExtOpenBuffer[nBars - vBar-1];
   haClose = vBar >= nBars - 1? vClose: ExtCloseBuffer[nBars - vBar-1];
   haHigh = MathMax(vHigh, MathMax(haOpen, haClose));
   haLow = MathMin(vLow, MathMin(haOpen, haClose));

/*   if (ha_Shw && vBar < 17) { DrawArrow_HA(haOpen, vBar, 3, (haOpen < haClose));  //, vChart);
      DrawArrow_HA(haClose, vBar, 3, (haOpen < haClose));   //, vChart);
      DrawArrow_HA(haHigh, vBar, 2, (haOpen < haClose));    //, vChart);
      DrawArrow_HA(haLow, vBar, 1, (haOpen < haClose)); }   //, vChart); } //*/

   return(haOpen < haClose); }

void DrawArrow_HA(double LinePrice,int BarNum,int Code,bool Bullish) {
   string ArrowName = "H-A_Test_Arr"+(Bullish?"-Up_":"-Down_")+IntegerToString(Code)+"-"+IntegerToString(Time[BarNum])+"-"+LinePrice;
   ObjectCreate(ArrowName,OBJ_ARROW,0,Time[BarNum],LinePrice);
   ObjectSet(ArrowName, OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet(ArrowName, OBJPROP_ARROWCODE, Code);
   ObjectSet(ArrowName, OBJPROP_COLOR, Bullish? clrLime: clrDeepPink);
   ObjectSet(ArrowName, OBJPROP_SELECTABLE, 0);
   ObjectSet(ArrowName, OBJPROP_SELECTED, 0);
   ObjectSet(ArrowName, OBJPROP_WIDTH, 2);
}

void HA_Buffers() {
   ExtOpenBuffer[0] = iOpen(NULL,0,nBars-1);
   ExtCloseBuffer[0] = iClose(NULL,0,nBars-1);

   for (int i=1; i < nBars; i ++) {    // Bars
      haOpen = (ExtOpenBuffer[i-1] + ExtCloseBuffer[i-1]) / 2;
      haClose = (iOpen(NULL,0,nBars-i-1)+iHigh(NULL,0,nBars-i-1)+iLow(NULL,0,nBars-i-1)+iClose(NULL,0,nBars-i-1))/4;
      ExtOpenBuffer[i] = haOpen;
      ExtCloseBuffer[i] = haClose;              /* if (i > Bars-10) {

      Print("** ExtOpenBuffer[i-2] ",ExtOpenBuffer[i-2]," ExtOpenBuffer[i-1] ",ExtOpenBuffer[i-1]," ExtOpenBuffer[i] ",ExtOpenBuffer[i]," | ",i," ... ");
      Print(" (suite) ExtCloseBuffer[i-2] ",ExtCloseBuffer[i-2]," ExtCloseBuffer[i-1] ",ExtCloseBuffer[i-1]," ExtCloseBuffer[i] ",ExtCloseBuffer[i]," ... ");
      Print(" (suite) iOpen(Bars-i-1) ",iOpen(NULL,0,Bars-i-1)," iHigh(Bars-i-1) ",iHigh(NULL,0,Bars-i-1)," iLow(Bars-i-1) ",iLow(NULL,0,Bars-i-1)," iClose(Bars-i-1) ",iClose(NULL,0,Bars-i-1)," ... ");
      Print(" (suite) iOpen(Bars-i) ",iOpen(NULL,0,Bars-i)," iHigh(Bars-i) ",iHigh(NULL,0,Bars-i)," iLow(Bars-i) ",iLow(NULL,0,Bars-i)," iClose(Bars-i) ",iClose(NULL,0,Bars-i)," ... ");
      Print(" (suite) iOpen(Bars-i+1) ",iOpen(NULL,0,Bars-i+1)," iHigh(Bars-i+1) ",iHigh(NULL,0,Bars-i+1)," iLow(Bars-i+1) ",iLow(NULL,0,Bars-i+1)," iClose(Bars-i+1) ",iClose(NULL,0,Bars-i+1)," ... ");
      Print(" (suite) TimeToStr(Bars-i-1) ",TimeToStr(iTime(NULL,0,Bars-i-1),TIME_DATE|TIME_MINUTES)," TimeToStr(Bars-i) ",TimeToStr(iTime(NULL,0,Bars-i),TIME_DATE|TIME_MINUTES),
         " TimeToStr(Bars-i+1) ",TimeToStr(iTime(NULL,0,Bars-i+1),TIME_DATE|TIME_MINUTES)," **"); } */ }
   return; }

void DrawArrow_chck(double LinePrice,int BarNum,bool Pos,int k) {
   string ArrowName="EA_Chck2-"+IntegerToString(Pos)+"_"+IntegerToString(BarNum)+" "+IntegerToString(Time[BarNum]);
   if (! ObjectCreate(ArrowName,OBJ_ARROW,0,Time[BarNum],LinePrice + (Bid < 0.5? 40.0: 80.0) * Point()))
      Print("*** ObjectCreate Error : "+IntegerToString(GetLastError())+" / "+DoubleToStr(LinePrice,5)+" - "+IntegerToString(BarNum)+" ***");
   ObjectSet(ArrowName, OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet(ArrowName, OBJPROP_ARROWCODE, Pos? 252: 251);
   ObjectSet(ArrowName, OBJPROP_COLOR, Pos? clrGold: clrSilver);
   ObjectSet(ArrowName, OBJPROP_SELECTABLE, 0);
   ObjectSet(ArrowName, OBJPROP_SELECTED, 0);
//   ObjectSet(ArrowName, OBJPROP_YDISTANCE, 55);
   ObjectSet(ArrowName, OBJPROP_WIDTH, 3);

   ArrowName = "EA_Chck2-"+IntegerToString(Pos)+"b_"+IntegerToString(BarNum)+" "+IntegerToString(Time[BarNum]);
   if (! ObjectCreate(ArrowName,OBJ_ARROW,0,Time[BarNum-2],LinePrice + (Bid < 0.5? 37.0: 77.0) * Point()))
      Print("*** ObjectCreate Error : "+IntegerToString(GetLastError())+" / "+DoubleToStr(LinePrice,5)+" - "+IntegerToString(BarNum)+" ***");
   ObjectSet(ArrowName, OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet(ArrowName, OBJPROP_ARROWCODE, 129 + k);
   ObjectSet(ArrowName, OBJPROP_COLOR, Pos? clrGold: clrSilver);
   ObjectSet(ArrowName, OBJPROP_SELECTABLE, 0);
   ObjectSet(ArrowName, OBJPROP_SELECTED, 0);
//   ObjectSet(ArrowName, OBJPROP_YDISTANCE, 55);
   ObjectSet(ArrowName, OBJPROP_WIDTH, 1); }

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

double SuperTrend(int bar) { return(iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, bar) == 2147483647?
      iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, bar) == 2147483647? 2147483647:
      iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, bar): iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, bar)); }

void f_End_EA(int I) { int zero=0;     Alert("******* f_End_EA(" + I + ") *******");
   Print(1 / zero); }

void Exp_Inds() { int cpt=0;        double dtmp;         ArrayInitialize(Exp_Ind, 0.0);
//   for (int pos=300; pos/* && ! tst*/; pos --) { dtmp = 0.0;       Comment("* pos = " + IntegerToString(pos) + " *");
   for (int pos=0; pos < 300/* && ! tst*/; pos ++) { dtmp = 0.0;        t_exp = false;
      if ((dtmp=iCustom(NULL, 0, "ATS Expansion Index V4.0.ex4", 0, pos)) != 0.0 &&
      dtmp != 2147483647.0) { Exp_Ind[cpt][0] = dtmp;       Exp_Ind[cpt][10] = Time[pos];//       t_exp = true;
if (0) Alert("******* 0 - " + DoubleToStr(dtmp, Digits()) + " - " + IntegerToString(cpt) + " *******"); }
      if ((dtmp=iCustom(NULL, 0, "ATS Expansion Index V4.0.ex4", 1, pos)) != 0.0 &&
      dtmp != 2147483647.0) { Exp_Ind[cpt][1] = dtmp;       Exp_Ind[cpt][11] = Time[pos];//       t_exp = true;
if (0) Alert("******* 1 - " + DoubleToStr(dtmp, Digits()) + " - " + IntegerToString(cpt) + " *******"); }
      if ((dtmp=iCustom(NULL, 0, "ATS Expansion Index V4.0.ex4", 2, pos)) != 0.0 &&
      dtmp != 2147483647.0) { Exp_Ind[cpt][2] = dtmp;       Exp_Ind[cpt][12] = Time[pos];//       t_exp = true;
if (0) Alert("******* 2 - " + DoubleToStr(dtmp, Digits()) + " - " + IntegerToString(cpt) + " *******"); }
      if ((dtmp=iCustom(NULL, 0, "ATS Expansion Index V4.0.ex4", 3, pos)) != 0.0 &&
      dtmp != 2147483647.0) { Exp_Ind[cpt][3] = dtmp;       Exp_Ind[cpt][13] = Time[pos];//       t_exp = true;
if (0) Alert("******* 3 - " + DoubleToStr(dtmp, Digits()) + " - " + IntegerToString(cpt) + " *******"); }
      if ((dtmp=iCustom(NULL, 0, "ATS Expansion Index V4.0.ex4", 4, pos)) != 0.0 &&
      dtmp != 2147483647.0) { Exp_Ind[cpt][4] = dtmp;       Exp_Ind[cpt][14] = Time[pos];//       t_exp = true;
if (0) Alert("******* 4 - " + DoubleToStr(dtmp, Digits()) + " - " + IntegerToString(cpt) + " *******"); }
      if ((dtmp=iCustom(NULL, 0, "ATS Expansion Index V4.0.ex4", 5, pos)) != 0.0 &&
      dtmp != 2147483647.0) { Exp_Ind[cpt][5] = dtmp;       Exp_Ind[cpt][15] = Time[pos];       t_exp = true;
if (0) Alert("******* 5 - " + DoubleToStr(dtmp, Digits()) + " - " + IntegerToString(cpt) + " *******"); }
      if ((dtmp=iCustom(NULL, 0, "ATS Expansion Index V4.0.ex4", 6, pos)) != 0.0 &&
      dtmp != 2147483647.0) { Exp_Ind[cpt][6] = dtmp;       Exp_Ind[cpt][16] = Time[pos];       t_exp = true;
if (0) Alert("******* 6 - " + DoubleToStr(dtmp, Digits()) + " - " + IntegerToString(cpt) + " *******"); }
      if ((dtmp=iCustom(NULL, 0, "ATS Expansion Index V4.0.ex4", 7, pos)) != 0.0 &&
      dtmp != 2147483647.0) { Exp_Ind[cpt][7] = dtmp;       Exp_Ind[cpt][17] = Time[pos];//       t_exp = true;
if (0) Alert("******* 7 - " + DoubleToStr(dtmp, Digits()) + " - " + IntegerToString(cpt) + " *******"); }
      if ((dtmp=iCustom(NULL, 0, "ATS Expansion Index V4.0.ex4", 8, pos)) != 0.0 &&
      dtmp != 2147483647.0) { Exp_Ind[cpt][8] = dtmp;       Exp_Ind[cpt][18] = Time[pos];       t_exp = true;
if (0) Alert("******* 8 - " + DoubleToStr(dtmp, Digits()) + " - " + IntegerToString(cpt) + " *******"); }
      if ((dtmp=iCustom(NULL, 0, "ATS Expansion Index V4.0.ex4", 9, pos)) != 0.0 &&
      dtmp != 2147483647.0) { Exp_Ind[cpt][9] = dtmp;       Exp_Ind[cpt][19] = Time[pos];       t_exp = true;
if (0) Alert("******* 9 - " + DoubleToStr(dtmp, Digits()) + " - " + IntegerToString(cpt) + " *******"); }
      if (t_exp) { Exp_Ind[cpt][20] = Time[pos];         cpt ++; } }
   tim_exp = Time[0];         t_cpt = cpt;         t_exp = false;
   if (f_wBars(t_BxClo, TimeCurrent()) > 2/* * Period() * 60*/) t_BxClo = 0;

   double dtmp2=Exp_Ind[0][20] == Time[1]? (Exp_Ind[1][6] + Exp_Ind[1][9]) * 5.0 /
      ((dtmp=(Exp_Ind[2][6]+Exp_Ind[2][9]+Exp_Ind[3][6]+Exp_Ind[3][9]+Exp_Ind[4][6]+Exp_Ind[4][9]+Exp_Ind[5][6]+Exp_Ind[5][9]+Exp_Ind[6][6]+Exp_Ind[6][9])) > 0.0? dtmp: 1000.0) +
      (Exp_Ind[2][6] + Exp_Ind[2][9]) * 5.0 /
      ((dtmp=(Exp_Ind[3][6]+Exp_Ind[3][9]+Exp_Ind[4][6]+Exp_Ind[4][9]+Exp_Ind[5][6]+Exp_Ind[5][9]+Exp_Ind[6][6]+Exp_Ind[6][9]+Exp_Ind[7][6]+Exp_Ind[7][9])) > 0.0? dtmp: 1000.0):
      (Exp_Ind[0][6] + Exp_Ind[0][9]) * 5.0 /
      ((dtmp=(Exp_Ind[1][6]+Exp_Ind[1][9]+Exp_Ind[2][6]+Exp_Ind[2][9]+Exp_Ind[3][6]+Exp_Ind[3][9]+Exp_Ind[4][6]+Exp_Ind[4][9]+Exp_Ind[5][6]+Exp_Ind[5][9])) > 0.0? dtmp: 1000.0) +
      (Exp_Ind[1][6] + Exp_Ind[1][9]) * 5.0 /
      ((dtmp=(Exp_Ind[2][6]+Exp_Ind[2][9]+Exp_Ind[3][6]+Exp_Ind[3][9]+Exp_Ind[4][6]+Exp_Ind[4][9]+Exp_Ind[5][6]+Exp_Ind[5][9]+Exp_Ind[6][6]+Exp_Ind[6][9])) > 0.0? dtmp: 1000.0);
   dtmp = Exp_Ind[0][20] == Time[1]? (Exp_Ind[1][5] + Exp_Ind[1][8]) * 5.0 /
      ((dtmp=(Exp_Ind[2][5]+Exp_Ind[2][8]+Exp_Ind[3][5]+Exp_Ind[3][8]+Exp_Ind[4][5]+Exp_Ind[4][8]+Exp_Ind[5][5]+Exp_Ind[5][8]+Exp_Ind[6][5]+Exp_Ind[6][8])) > 0.0? dtmp: 1000.0) +
      (Exp_Ind[2][5] + Exp_Ind[2][8]) * 5.0 /
      ((dtmp=(Exp_Ind[3][5]+Exp_Ind[3][8]+Exp_Ind[4][5]+Exp_Ind[4][8]+Exp_Ind[5][5]+Exp_Ind[5][8]+Exp_Ind[6][5]+Exp_Ind[6][8]+Exp_Ind[7][5]+Exp_Ind[7][8])) > 0.0? dtmp: 1000.0):
      (Exp_Ind[0][5] + Exp_Ind[0][8]) * 5.0 /
      ((dtmp=(Exp_Ind[1][5]+Exp_Ind[1][8]+Exp_Ind[2][5]+Exp_Ind[2][8]+Exp_Ind[3][5]+Exp_Ind[3][8]+Exp_Ind[4][5]+Exp_Ind[4][8]+Exp_Ind[5][5]+Exp_Ind[5][8])) > 0.0? dtmp: 1000.0) +
      (Exp_Ind[1][5] + Exp_Ind[1][8]) * 5.0 /
      ((dtmp=(Exp_Ind[2][5]+Exp_Ind[2][8]+Exp_Ind[3][5]+Exp_Ind[3][8]+Exp_Ind[4][5]+Exp_Ind[4][8]+Exp_Ind[5][5]+Exp_Ind[5][8]+Exp_Ind[6][5]+Exp_Ind[6][8])) > 0.0? dtmp: 1000.0);
   if (/*(dtmp > 4.5 || dtmp2 > 4.5 ) &&*/
   Exp_Ind[0][20] != Exp_Ind2[0][1] && Exp_Ind[0][20] != Exp_Ind2[1][1] && Exp_Ind[0][20] != Exp_Ind2[2][1] &&
   Exp_Ind[1][20] != Exp_Ind2[0][1] && Exp_Ind[1][20] != Exp_Ind2[1][1] && Exp_Ind[1][20] != Exp_Ind2[2][1] &&
   Exp_Ind[0][20] != Exp_Ind3[0][1] && Exp_Ind[0][20] != Exp_Ind3[1][1] && Exp_Ind[0][20] != Exp_Ind3[2][1] &&
   Exp_Ind[1][20] != Exp_Ind3[0][1] && Exp_Ind[1][20] != Exp_Ind3[1][1] && Exp_Ind[1][20] != Exp_Ind3[2][1]) {
Alert("*** Exp_Ind (3) - " + DoubleToStr(Exp_Ind[0][5]+Exp_Ind[0][8], 3) + " - " + DoubleToStr(Exp_Ind[0][6]+Exp_Ind[0][9], 3) + " - " +
   DoubleToStr(Exp_Ind[1][5]+Exp_Ind[1][8], 3) + " - " + DoubleToStr(Exp_Ind[1][6]+Exp_Ind[1][9], 3) + " -up " + DoubleToStr(dtmp, 2) + " - " + exp_up + " -dn " +
   DoubleToStr(dtmp2, 2) + " - " + exp_dn + " - " + TimeToStr(Exp_Ind[0][20], TIME_DATE|TIME_MINUTES) + " - " + TimeToStr(Time[0], TIME_DATE|TIME_MINUTES) + " ***");
      if (dtmp > 4.5) { Exp_Ind2[exp_up][0] = dtmp;         Exp_Ind2[exp_up][1] = (Exp_Ind[0][20] == Time[1]? Exp_Ind[1][20]: Exp_Ind[0][20]);
         Exp_Ind2[exp_up][2] = Sell + 1; }                  if (dtmp2 > 4.5) { Exp_Ind3[exp_dn][0] = dtmp2;
         Exp_Ind3[exp_dn][1] = (Exp_Ind[0][20] == Time[1]? Exp_Ind[1][20]: Exp_Ind[0][20]);        Exp_Ind3[exp_dn][2] = Sell + 1; }
         if (exp_up < 2) exp_up ++;       else  exp_up = 0;          if (exp_dn < 2) exp_dn ++;        else  exp_dn = 0; } }

bool Exp_Inds2() { double Exp_Sup, Exp_Inf, Exp_Med, E_Range;         bool tst=false;
   for (int obj=0; obj < ObjectsTotal() && ! tst; obj ++) { string name=ObjectName(obj);
      if (name == "ATS Expansion Index V4.0aei_1") Exp_Sup = ObjectGet(name, OBJPROP_PRICE1);
      if (name == "ATS Expansion Index V4.0aei_2") Exp_Inf = ObjectGet(name, OBJPROP_PRICE1);
      if (tst=(name == "ATS Expansion Index V4.0aei_3")) Exp_Med = ObjectGet(name, OBJPROP_PRICE1); }

   E_Range = Sell? Exp_Inf - Exp_Med: Exp_Sup - Exp_Med;
   t_exp2 = Exp_Inf && Exp_Sup && Exp_Inf != 2147483647.0 && Exp_Sup != 2147483647.0? Exp_Ind[0][20] == Time[0]?
      (Buy && ((Exp_Ind[1][5] > E_Range && Exp_Ind[2][6] > E_Range) || (Exp_Ind[1][8] > E_Range && Exp_Ind[2][9] > E_Range))) ||
      (Sell && ((Exp_Ind[1][6] < E_Range && Exp_Ind[2][5] < E_Range) || (Exp_Ind[1][9] < E_Range && Exp_Ind[2][8] < E_Range)))/* ||
      (Buy && (Exp_Ind[2][5] > E_Range || Exp_Ind[2][8] > E_Range)) || (Sell && (Exp_Ind[2][6] < E_Range || Exp_Ind[2][9] < E_Range)) ||
      (Buy && (Exp_Ind[3][5] > E_Range || Exp_Ind[3][8] > E_Range)) || (Sell && (Exp_Ind[3][6] < E_Range || Exp_Ind[3][9] < E_Range))*/:
      (Buy && ((Exp_Ind[0][5] > E_Range && Exp_Ind[1][6] > E_Range) || (Exp_Ind[0][8] > E_Range && Exp_Ind[1][9] > E_Range))) ||
      (Sell && ((Exp_Ind[0][6] < E_Range && Exp_Ind[1][5] < E_Range) || (Exp_Ind[0][9] < E_Range && Exp_Ind[1][8] < E_Range)))/* ||
      (Buy && (Exp_Ind[1][5] > E_Range || Exp_Ind[1][8] > E_Range)) || (Sell && (Exp_Ind[1][6] < E_Range || Exp_Ind[1][9] < E_Range)) ||
      (Buy && (Exp_Ind[2][5] > E_Range || Exp_Ind[2][8] > E_Range)) || (Sell && (Exp_Ind[2][6] < E_Range || Exp_Ind[2][9] < E_Range))*/: false;
//Alert("******* t_exp2 - " + DoubleToStr(Exp_Inf, 1) + " - " + DoubleToStr(Exp_Med, 1) + " - " + DoubleToStr(Exp_Sup, 1) + " - " + DoubleToStr(E_Range, 1) + " - " + t_exp2 + " *******");
   return(t_exp2); }

void Entry_Points_Clo() { bool tst, tst2, tst3, Buy_=Buy, Sell_=Sell;         double dtmp;         string temp;         Entry_Points_Ind();
   if (floor(TimeCurrent() / 60) > tim_min) { tim_min = floor(TimeCurrent() / 60);        st_bull_ = st_bull;//        sup_trnd_ = sup_trend;         // && ! (Minute() % Period())
Alert("******* DrawArrow_HA() Minute() - " + Minute() + " - " + Seconds() + " - " + iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 0) + " - " + iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 0) + " *******");
      if (iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 0) != 2147483647) DrawArrow_HA((sup_trend=iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 0)), 0, 159, 1);
      if (iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 0) != 2147483647) DrawArrow_HA((sup_trend=iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 0)), 0, 159, 0);
      if (iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 0, 0) == 2147483647 && iCustom(NULL, 0, "super-trend_.ex4", 10, 4.0, 1, 0) == 2147483647)
         if (sup_trend < Bid) DrawArrow_HA(sup_trend, 0, 159, 1);       else  DrawArrow_HA(sup_trend, 0, 159, 0);
      if (st_bull_ != st_bull) { tim_mn_b = tim_min_;          tim_min_ = tim_min; } }

   if (Buy || Sell) t_BS = Buy ? 1 : Sell ? 2 : 0;
   if ((Sell=(iCustom(NULL, 0, "New folder\\Manual Trade Cashpower Lifetime.ex4", 0, 0) > 0.0)) ||
   (Buy=(iCustom(NULL, 0, "New folder\\Manual Trade Cashpower Lifetime.ex4", 1, 0) > 0.0))) { tim4 = TimeCurrent();
      Alert("*** Manual Trade Cashpower Lifetime: " + Symbol() + " - " + IntegerToString(Period()) + " - " +
         DoubleToStr(iCustom(NULL, 0, "New folder\\Manual Trade Cashpower Lifetime.ex4", 0, 0), Digits()) + " - " +
         DoubleToStr(iCustom(NULL, 0, "New folder\\Manual Trade Cashpower Lifetime.ex4", 1, 0), Digits()) + " ***");

      if (Buy) DrawArrow(Ask > (WindowPriceMax()+WindowPriceMin())/2.0 ? WindowPriceMin() +
         (WindowPriceMax()-WindowPriceMin())/5.0 : WindowPriceMax() - (WindowPriceMax()-WindowPriceMin())/10.0, 0, 159, 1, 0);
      if (Sell) DrawArrow(Ask > (WindowPriceMax()+WindowPriceMin())/2.0 ? WindowPriceMin() +
         (WindowPriceMax()-WindowPriceMin())/5.0 : WindowPriceMax() - (WindowPriceMax()-WindowPriceMin())/10.0, 0, 159, 0, 0); }
   if (floor((TimeCurrent() - tim4) / (Period() * 60)) <= 7) DrawArrow(Ask > (WindowPriceMax()+WindowPriceMin())/2.0 ? WindowPriceMin() +
         (WindowPriceMax()-WindowPriceMin())/5.0 : WindowPriceMax() - (WindowPriceMax()-WindowPriceMin())/10.0, 0, 158, t_BS==1? 1: 0, 0);

   if (iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 1, 0) > 0.0)
      DrawArrow((dtmp=iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 1, 0)), 0, 159, 0, 1);
   if (EPP_Min > dtmp) EPP_Min = dtmp;             if (EPP_Max < dtmp) EPP_Max = dtmp;
   if (! (Minute() % Period()) && i_sec > Seconds()) { EPP_Min_ = EPP_Min;       EPP_Max_ = EPP_Max; }

/*   if (! t_Pass) { int signs, wins, loss;    if (ObjectsTotal()) for (int pos=0; pos < ObjectsTotal(); pos ++) { name = ObjectName(pos);
         if (name == "eFess_ --------" || name == "eFess_ Cancelled" || name == "eFess_ Min profit" ||
         name == "eFess_ Signals" || name == "eFess_ Success rate" || name == "eFess_ Title" ||
         name == "eFess_ Win loss" || name == "eFess_RectLabel") ObjectSet(name, OBJPROP_XDISTANCE, -220.0);
         if (name == "eFess_ Signals") { temp = ObjectGetString(0, name, OBJPROP_TEXT);
            signs = StrToInteger(StringSubstr(temp, StringLen(temp) - 3, 3));    comm = "* Signals : " + IntegerToString(signs); }
         if (name == "eFess_ Win loss") { temp = ObjectGetString(0, name, OBJPROP_TEXT);
            temp = StringSubstr(temp, StringLen(temp) - 9, 1) == ":"? StringSubstr(temp, StringLen(temp) - 7, 7):
               StringSubstr(temp, StringLen(temp) - 8, 1) == ":"? StringSubstr(temp, StringLen(temp) - 6, 6):
               StringSubstr(temp, StringLen(temp) - 7, 1) == ":"? StringSubstr(temp, StringLen(temp) - 5, 5):
               StringSubstr(temp, StringLen(temp) - 6, 1) == ":"? StringSubstr(temp, StringLen(temp) - 4, 4):
               StringSubstr(temp, StringLen(temp) - 3, 3);     
            wins = StrToInteger(StringSubstr(temp, 3, 1) == "/"? StringSubstr(temp, 0, 3):
               StringSubstr(temp, 2, 1) == "/"? StringSubstr(temp, 0, 2): StringSubstr(temp, 0, 1));
            loss = StrToInteger(StringSubstr(temp, 3, 1) == "/"? StringSubstr(temp, 4, 3):
               StringSubstr(temp, 2, 1) == "/"? StringSubstr(temp, 3, 3): StringSubstr(temp, 2, 3));
            comm += " / Win/Loss : " + wins + "/" + loss + " / Success : " + itmp + "% *"; }
         if (itmp_ != itmp) Comment(comm); } }

   if (Period() < 30) { int it, _Order_240, _H4_Buy, _H4_Sell;          datetime _H4_tim1, _H4_tim2;
      for (int l=il; l < ArraySize(line_read2) && StrToTime(StringSubstr(line_read2[l], 0, 19)) <= TimeCurrent(); l ++) {
         if (StringFind(line_read2[l], "_Order_240") > 0) { _Order_240 = StringSubstr(line_read2[l],
            (it=StringFind(line_read2[l], "-", StringFind(line_read2[l], Symbol())) + 2), StringFind(line_read2[l], "-", it) - it - 1);
            GlobalVariableSet("t-"+ Symbol() + (temp="_Order_240"), _Order_240);/*          GlobalVars(temp, _Order_240, 0);* / }
         if (StringFind(line_read2[l], "_H4_Buy") > 0) { _H4_Buy = StringSubstr(line_read2[l],
            (it=StringFind(line_read2[l], "-", StringFind(line_read2[l], Symbol())) + 2), StringFind(line_read2[l], "-", it) - it - 1);
            GlobalVariableSet("t-"+ Symbol() + (temp="_H4_Buy"), _H4_Buy);/*                GlobalVars(temp, _H4_Buy, 0);* / }
         if (StringFind(line_read2[l], "_H4_tim1") > 0) { _H4_tim1 = StringSubstr(line_read2[l],
            (it=StringFind(line_read2[l], "-", StringFind(line_read2[l], Symbol())) + 2), StringFind(line_read2[l], "-", it) - it - 1);
            GlobalVariableSet("t-"+ Symbol() + (temp="_H4_tim1"), _H4_tim1);/*              GlobalVars(temp, _H4_tim1, 0);* / }
         if (StringFind(line_read2[l], "_H4_Sell") > 0) { _H4_Sell = StringSubstr(line_read2[l],
            (it=StringFind(line_read2[l], "-", StringFind(line_read2[l], Symbol())) + 2), StringFind(line_read2[l], "-", it) - it - 1);
            GlobalVariableSet("t-"+ Symbol() + (temp="_H4_Sell"), _H4_Sell);/*              GlobalVars(temp, _H4_Sell, 0);* / }
         if (StringFind(line_read2[l], "_H4_tim2") > 0) { _H4_tim2 = StringSubstr(line_read2[l],
            (it=StringFind(line_read2[l], "-", StringFind(line_read2[l], Symbol())) + 2), StringFind(line_read2[l], "-", it) - it - 1);
            GlobalVariableSet("t-"+ Symbol() + (temp="_H4_tim2"), _H4_tim2);/*              GlobalVars(temp, _H4_tim2, 0);* / }
/*         tst = (Sell=((GlobalVariableCheck(Symb+"_1440_CashPower") && GlobalVariableGet(Symb+"_1440_CashPower") == 2 && TimeCurrent() - GlobalVariableGet(Symb+"_1440_CP_Tim") < 3.5*per*3600 &&
            ((GlobalVariableCheck(Symb + "_240_CashPower") && GlobalVariableGet(Symb + "_240_CashPower") == 2 && TimeCurrent() - GlobalVariableGet(Symb + "_240_CP_Tim") < per*3600) ||
            (GlobalVariableCheck(Symb + "_60_CashPower") && GlobalVariableGet(Symb + "_60_CashPower") == 2 && TimeCurrent() - GlobalVariableGet(Symb + "_60_CP_Tim") < 0.25*per*3600) ||
            (GlobalVariableCheck(Symb + "_30_CashPower") && GlobalVariableGet(Symb + "_30_CashPower") == 2 && TimeCurrent() - GlobalVariableGet(Symb + "_30_CP_Tim") < 0.125*per*3600))) ||
            (GlobalVariableCheck(Symb + "_240_CashPower") && GlobalVariableGet(Symb + "_240_CashPower") == 2 && TimeCurrent() - GlobalVariableGet(Symb + "_240_CP_Tim") < per*3600 &&
            ((GlobalVariableCheck(Symb+"_1440_CashPower") && GlobalVariableGet(Symb+"_1440_CashPower") == 2 && TimeCurrent() - GlobalVariableGet(Symb+"_1440_CP_Tim") < 3.5*per*3600) ||
            (GlobalVariableCheck(Symb + "_60_CashPower") && GlobalVariableGet(Symb + "_60_CashPower") == 2 && TimeCurrent() - GlobalVariableGet(Symb + "_60_CP_Tim") < 0.25*per*3600) ||
            (GlobalVariableCheck(Symb + "_30_CashPower") && GlobalVariableGet(Symb + "_30_CashPower") == 2 && TimeCurrent() - GlobalVariableGet(Symb + "_30_CP_Tim") < 0.125*per*3600))) ||
            (GlobalVariableCheck(Symb + "_60_CashPower") && GlobalVariableGet(Symb + "_60_CashPower") == 2 && TimeCurrent() - GlobalVariableGet(Symb + "_60_CP_Tim") < 0.25*per*3600 &&
            ((GlobalVariableCheck(Symb+"_1440_CashPower") && GlobalVariableGet(Symb+"_1440_CashPower") == 2 && TimeCurrent() - GlobalVariableGet(Symb+"_1440_CP_Tim") < 3.5*per*3600) ||
            (GlobalVariableCheck(Symb + "_240_CashPower") && GlobalVariableGet(Symb + "_240_CashPower") == 2 && TimeCurrent() - GlobalVariableGet(Symb + "_240_CP_Tim") < per*3600) ||
            (GlobalVariableCheck(Symb + "_30_CashPower") && GlobalVariableGet(Symb + "_30_CashPower") == 2 && TimeCurrent() - GlobalVariableGet(Symb + "_30_CP_Tim") < 0.125*per*3600))) ||
            (GlobalVariableCheck(Symb + "_30_CashPower") && GlobalVariableGet(Symb + "_30_CashPower") == 2 && TimeCurrent() - GlobalVariableGet(Symb + "_30_CP_Tim") < 0.125*per*3600 &&
            ((GlobalVariableCheck(Symb + "_240_CashPower") && GlobalVariableGet(Symb + "_240_CashPower") == 2 && TimeCurrent() - GlobalVariableGet(Symb + "_240_CP_Tim") < per*3600) ||
            (GlobalVariableCheck(Symb + "_60_CashPower") && GlobalVariableGet(Symb + "_60_CashPower") == 2 && TimeCurrent() - GlobalVariableGet(Symb + "_60_CP_Tim") < 0.25*per*3600) ||
            (GlobalVariableCheck(Symb+"_1440_CashPower") && GlobalVariableGet(Symb+"_1440_CashPower") == 2 && TimeCurrent() - GlobalVariableGet(Symb+"_1440_CP_Tim") < 3.5*per*3600))))) ||
            (Buy=((GlobalVariableCheck(Symb+"_1440_CashPower") && GlobalVariableGet(Symb+"_1440_CashPower") == 1 && TimeCurrent() - GlobalVariableGet(Symb+"_1440_CP_Tim") < 3.5*per*3600 &&
            ((GlobalVariableCheck(Symb + "_240_CashPower") && GlobalVariableGet(Symb + "_240_CashPower") == 1 && TimeCurrent() - GlobalVariableGet(Symb + "_240_CP_Tim") < per*3600) ||
            (GlobalVariableCheck(Symb + "_60_CashPower") && GlobalVariableGet(Symb + "_60_CashPower") == 1 && TimeCurrent() - GlobalVariableGet(Symb + "_60_CP_Tim") < 0.25*per*3600) ||
            (GlobalVariableCheck(Symb + "_30_CashPower") && GlobalVariableGet(Symb + "_30_CashPower") == 1 && TimeCurrent() - GlobalVariableGet(Symb + "_30_CP_Tim") < 0.125*per*3600))) ||
            (GlobalVariableCheck(Symb + "_240_CashPower") && GlobalVariableGet(Symb + "_240_CashPower") == 1 && TimeCurrent() - GlobalVariableGet(Symb + "_240_CP_Tim") < per*3600 &&
            ((GlobalVariableCheck(Symb+"_1440_CashPower") && GlobalVariableGet(Symb+"_1440_CashPower") == 1 && TimeCurrent() - GlobalVariableGet(Symb+"_1440_CP_Tim") < 3.5*per*3600) ||
            (GlobalVariableCheck(Symb + "_60_CashPower") && GlobalVariableGet(Symb + "_60_CashPower") == 1 && TimeCurrent() - GlobalVariableGet(Symb + "_60_CP_Tim") < 0.25*per*3600) ||
            (GlobalVariableCheck(Symb + "_30_CashPower") && GlobalVariableGet(Symb + "_30_CashPower") == 1 && TimeCurrent() - GlobalVariableGet(Symb + "_30_CP_Tim") < 0.125*per*3600))) ||
            (GlobalVariableCheck(Symb + "_60_CashPower") && GlobalVariableGet(Symb + "_60_CashPower") == 1 && TimeCurrent() - GlobalVariableGet(Symb + "_60_CP_Tim") < 0.25*per*3600 &&
            ((GlobalVariableCheck(Symb+"_1440_CashPower") && GlobalVariableGet(Symb+"_1440_CashPower") == 1 && TimeCurrent() - GlobalVariableGet(Symb+"_1440_CP_Tim") < 3.5*per*3600) ||
            (GlobalVariableCheck(Symb + "_240_CashPower") && GlobalVariableGet(Symb + "_240_CashPower") == 1 && TimeCurrent() - GlobalVariableGet(Symb + "_240_CP_Tim") < per*3600) ||
            (GlobalVariableCheck(Symb + "_30_CashPower") && GlobalVariableGet(Symb + "_30_CashPower") == 1 && TimeCurrent() - GlobalVariableGet(Symb + "_30_CP_Tim") < 0.125*per*3600))) ||
            (GlobalVariableCheck(Symb + "_30_CashPower") && GlobalVariableGet(Symb + "_30_CashPower") == 1 && TimeCurrent() - GlobalVariableGet(Symb + "_30_CP_Tim") < 0.125*per*3600 &&
            ((GlobalVariableCheck(Symb + "_240_CashPower") && GlobalVariableGet(Symb + "_240_CashPower") == 1 && TimeCurrent() - GlobalVariableGet(Symb + "_240_CP_Tim") < per*3600) ||
            (GlobalVariableCheck(Symb + "_60_CashPower") && GlobalVariableGet(Symb + "_60_CashPower") == 1 && TimeCurrent() - GlobalVariableGet(Symb + "_60_CP_Tim") < 0.25*per*3600) ||
            (GlobalVariableCheck(Symb+"_1440_CashPower") && GlobalVariableGet(Symb+"_1440_CashPower") == 1 && TimeCurrent() - GlobalVariableGet(Symb+"_1440_CP_Tim") < 3.5*per*3600))))); * / }
/* if (l - il > 1) Alert("*** " + IntegerToString(l-1) + " 1- " + line_read2[l-1] + " 2- " + StringSubstr(line_read2[l-1],
    (it=StringFind(line_read2[l-1], "-", StringFind(line_read2[l-1], Symbol())) + 2), StringFind(line_read2[l-1], "-", it) - it - 1) + " 3- " + IntegerToString(it) + " ***"); * /
      datetime _M5_tim1_=GlobalVariableGet("t-"+ Symbol() + "_M5_tim1_"), _M5_tim1=GlobalVariableGet("t-"+ Symbol() + "_M5_tim1"), _M5_tim2_=GlobalVariableGet("t-"+ Symbol() +
         "_M5_tim2_"), _M5_tim2=GlobalVariableGet("t-"+ Symbol() + "_M5_tim2");
      int _M5_Buy=GlobalVariableGet("t-"+ Symbol() + "_M5_Buy"), _M5_Sell=GlobalVariableGet("t-"+ Symbol() + "_M5_Sell"), _M5_Previous=GlobalVariableGet("t-"+ Symbol() + "_M5_Previous");
      Comment("-- " + IntegerToString(_Order_240) + " - " + IntegerToString(_H4_Buy) + " - " + IntegerToString(_H4_tim1) + " - " + TimeToStr(_H4_tim1, TIME_SECONDS) + " - " +
         IntegerToString(_H4_Sell) + " - " + IntegerToString(_H4_tim2) + " - " + TimeToStr(_H4_tim2, TIME_SECONDS) + " : " + IntegerToString(_M5_Previous) + " - " +
         IntegerToString(_M5_Buy) + " - " + IntegerToString(_M5_tim1_) + " - " + TimeToStr(_M5_tim1_, TIME_SECONDS) + " - " + IntegerToString(_M5_tim1) + " - " +
         TimeToStr(_M5_tim1, TIME_SECONDS) + " - " + IntegerToString(_M5_Sell) + " - " + IntegerToString(_M5_tim2_) + " - " + TimeToStr(_M5_tim2_, TIME_SECONDS) + " - " +
         IntegerToString(_M5_tim2) + " - " + TimeToStr(_M5_tim2, TIME_SECONDS) + " --");                    il = l - 3; } */

   t_Sent = OrdersTotal();       if (t_Sent && ! ticket) { ticket = GlobalVariableGet("t-"+ Symbol() + "_ticket" + (Period() >= 30? "_240": ""));
      if (ticket > 0) tim1 = GlobalVariableGet("t-"+ Symbol() + "_tim1" + (Period() >= 30? "_240": "")); }
   t_Sent = ticket;        Bull = t_Sent && OrderSelect(ticket, SELECT_BY_TICKET) && ! OrderCloseTime() && ! OrderType();

   t_O240 = t_O24_? true: TimeCurrent() % 300 > 290 && GlobalVariableCheck("t-"+ Symbol() + "_Order_240")? GlobalVariableGet("t-"+ Symbol() + "_Order_240"): t_O240;
   if (myHour() > 21 || (myHour() == 21 && Minute() > 30)) t_Time = false;       else  t_Time = true;

   if (t_Sent && TimeCurrent() - tim1 < 2 && TimeCurrent() - GlobalVariableGet("t-"+ Symbol() + "_tim1" + (Period() >= 30? "_240": "")) > 20) {
      GlobalVariableSet("t-"+ Symbol() + (temp="_ticket" + (Period() >= 30? "_240": "")), ticket);          GlobalVars(temp, ticket, 2);
      GlobalVariableSet("t-"+ Symbol() + (temp="_tim1" + (Period() >= 30? "_240": "")), tim1 - 20);         GlobalVars(temp, (tim1=(tim1-20)), 2); }

   bool tst_d, tst_u;      tst = false;     for (int pos=ObjectsTotal()-1; pos >= 0 && ! tst && t_Sent; pos --) {
      string name=ObjectName(pos);          datetime OTim1 = ObjectGet(name, OBJPROP_TIME1);          int type=ObjectType(name);
      tst = ((tst_d=(StringSubstr(name,0,7)=="dnTrend")) || (tst_u=(StringSubstr(name,0,7)=="upTrend"))) && type == OBJ_ARROW &&// StringSubstr(name, 8, StringLen(Symbol())) == Symbol() &&
         floor(OTim1 / (60 * Period())) > floor(tim1 / (60 * Period())) && tim1 > 0; }   // && floor(TimeCurrent() / (60 * Period())) - floor(OTim1 / (60 * Period())) < 720 / Period();
   if (tst && ! OrdersTotal()) { tst = false;      tst_d = false;       tst_u = false; }
   if (tst) { temp="*** --Trend! - " + name + " - " + TimeToStr(OTim1, TIME_SECONDS) + " - " + /*TimeToStr(OTim2, TIME_MINUTES) + " - " + */TimeToStr(tim1, TIME_SECONDS) + " ***";
      if (AccountInfoInteger(ACCOUNT_TRADE_ALLOWED)) Alert(temp);                copy_file(temp, 1); }               bool tst_=tst;

   bool tst6=(iCustom(NULL, 0, "ATR.ex4", 14, 0, 0) > 1.25 || (fabs((iOpen(NULL,0,1)+iClose(NULL,0,1)) / 2.0 - sup_trend) > fmin(fabs(sup_trend - iCustom(NULL, 0, "Parabolic.ex4", 0, 1)),
      fabs((iOpen(NULL,0,1)+iClose(NULL,0,1)) / 2.0 - iCustom(NULL, 0, "Parabolic.ex4", 0, 1))) * 4.0)),
      t_H4_M5=/* Period() >= 30 &&*/ (t_Sent/* || ticket2*/) && ((Bull && (GlobalVariableGet("t-"+ Symbol() + "_M5_Sell") || (! GlobalVariableGet("t-"+ Symbol() + "_M5_Buy") && (tst6 ||
      Bid < iCustom(NULL, 0, "Parabolic.ex4", 0, 1) || iCustom(NULL, 0, "Parabolic.ex4", 0, 1) < sup_trend)))) || (! Bull && (GlobalVariableGet("t-"+ Symbol() + "_M5_Buy") ||
      (! GlobalVariableGet("t-"+ Symbol() + "_M5_Sell") && (tst6 || Ask > iCustom(NULL, 0, "Parabolic.ex4", 0, 1) || iCustom(NULL, 0, "Parabolic.ex4", 0, 1) > sup_trend)))));

   t_Wt2 = ((tst2=(iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 3, 0) > 0.0)) && TimeCurrent() % 300 > 290) ||
      (TimeCurrent() % 300 < 10 &&/* (t_Wt2 || bt) &&*/ (iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 3, 1) ||
      iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 3, 2)) &&
      (iCustom(NULL, 0, "Parabolic.ex4", 0, 1) > iHigh(NULL, 0, 1) || (EPP_Min_ > iClose(NULL, 0, 1) && EPP_Min_ < iOpen(NULL, 0, 1))));           if (tst2) tim6 = TimeCurrent();
/* if (myHour() == 6 && Minute() > 40) Alert("******* " + t_Sent + " - " + Bull + " - " + t_O240 + " - " + tst4b + " - " + OrderSelect(ticket, SELECT_BY_TICKET) + " - " + GlobalVariableGet("t-"+ Symbol() +
   "_M5_Buy") + " - " + GlobalVariableGet("t-"+ Symbol() + "_M5_Sell") + " - " + DoubleToStr(Bid, Digits()) + " - " + DoubleToStr(OrderOpenPrice(), Digits()) + " - " + DoubleToStr(iMA(NULL, 0, 100, 0, MODE_EMA,
   PRICE_CLOSE, 0), Digits()) + " - " + DoubleToStr(iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 3, 0), Digits()) + " - " + Buy + " - " +
   IntegerToString(t_BS) + " - " + tst + " - " + TimeToStr(tim4, TIME_MINUTES) + " - " + IntegerToString(floor((TimeCurrent() - tim4) / (Period() * 60))) +
   " - " + t_Wt2 + " - " + t_Wt3 + " - " + tst2 + " - " + (floor((TimeCurrent() - tim4) / (Period() * 60)) > 7 && t_Wt2) + " - " + IntegerToString(TimeCurrent() % 300) + " *******"); */
   if (t_EppCl && t_Pass && t_Sent && Bull && ((((t_Wt2 || ! t_O240)/* && (tst2 || bt))*/ || tst_u ||     // (t_H4_M5 && floor((TimeCurrent()-tim7)/(Period()*60)) > 7) ||
   tst4b) && OrderSelect(ticket, SELECT_BY_TICKET) && ! OrderCloseTime() && (myHour() > 3 || ! st_bull || (((tst2 && ! t_Rsi515) || (myHour() > 4 && (! iCustom(NULL, 0, "Entry_Points_Pro.ex4", "",
   maxcand, "", 0, 0, 500, "", 0, "", "08:00", "21:00", "", 1, 90, 2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 2, f_wBars(tim5, TimeCurrent())) || iCustom(NULL, 0, "Entry_Points_Pro.ex4",
   "", maxcand, "", 0, 0, 500, "", 0, "", "08:00", "21:00", "", 1, 90, 2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 4, f_wBars(tim5, TimeCurrent()))))) && myHour() > 1))) ||
   (tst3=(OrderSelect(ticket, SELECT_BY_TICKET) && floor(OrderOpenTime() / 60) >= tim_mn_b && floor(OrderOpenTime() / 60) <= tim_min_ && tim_min_ - tim_mn_b < 5))))
      if ((! Buy && (t_BS != 1 || floor((TimeCurrent() - tim4) / (Period() * 60)) > 7) && (! tst4b || floor((TimeCurrent() - tim1) / (Period() * 60)) > 7 || GlobalVariableGet("t-"+
      Symbol() + "_M5_Sell") || ! GlobalVariableGet("t-"+ Symbol() + "_M5_Buy"))) || (floor((TimeCurrent() - tim4) / (Period() * 60)) > 7 && TimeCurrent() % 300 < 10 && t_Wt2) ||
      (tst4b && ! st_bull && Bid > iMA(NULL, 0, 100, 0, MODE_EMA, PRICE_CLOSE, 0) && OrderOpenPrice() < iMA(NULL, 0, 100, 0, MODE_EMA, PRICE_CLOSE, 0)) || tst3 || t_CPEP3) {
         if (! tst_u ||/* (tick_m &&*/ t_Wt2 || ObjectGet(name, OBJPROP_PRICE1) > Bid) t_Sent = ! mOrderClose(ticket, 0.01, OrderType()? Ask: Bid, 15, clrNONE);
         else { t_Sent = OrderModify(ticket, OrderOpenPrice(), (tst_u? ObjectGet(name, OBJPROP_PRICE1): OrderType()? Ask: Bid) + (Sell? 1.0: -1.0) * 22 * Point(), OrderTakeProfit(), 0, clrNONE);
            if (t_Sent) tick_m = ticket; } }                                        // * 19-04-2022 : 12h à 19h *
      else if (OrderSelect(ticket, SELECT_BY_TICKET) && OrderStopLoss() < iMA(NULL, 0, 100, 0, MODE_EMA, PRICE_CLOSE, 0) &&
         OrderModify(ticket, OrderOpenPrice(), tst && (! t_Rsi515 || t_Adx)? (iCustom(NULL,0,"Parabolic.ex4",0,1)*4.0 + sup_trend) / 5.0: sup_trend, OrderTakeProfit(), 0, clrNONE)) {}
      if ((((! tst_u ||/* (tick_m &&*/ t_Wt2) && ! t_Sent) || (t_Sent && OrderSelect(tick_m, SELECT_BY_TICKET) && OrderCloseTime())) && ! OrderType()) {
         if (tst4b) tst4b = false;           tick_m = 0;          t_Sent = false;         t_EppCl = false;           t_CPEP3 = false;        t_ATSEP = false;     t_ATSEP2 = false;
Alert((temp="*** BUY Closed! - " + IntegerToString(ticket) + " - " + Symbol() + " - " + Bull + " - " + tst + " - " + t_H4_M5 + " - " + TimeToStr(tim1, TIME_MINUTES) + " - " +
   GlobalVariableGet("t-"+ Symbol() + "_M5_Sell") + " - " + (f_wBars(tim1, TimeCurrent())) + " ***"));   copy_file(temp, 1);     // floor(TimeCurrent()/(60*Period())) - floor(tim1/(60*Period()))
         ticket = 0;       tim1 = 0;         /* if (t_H4_M5) GlobalVariableSet("t-"+ Symbol() + "_M5_Sell", -1);           GlobalVariableSet("t-"+ Symbol() + "_M5_tim2", 0); }*/
         if (! tst3 && tst && t_O240 && GlobalVariableGet("t-"+ Symbol() + "_H4_Sell") && (! st_bull || GlobalVariableGet("t-"+ Symbol() + "_M5_Sell"))) {
            ticket = mOrderSend(Symbol(), 1, 0.01, Bid, 15, 1.01 * Bid, 0.0, NULL, Period() == 30? 5555541: Period() == 60? 5555542: 5555543, 0, clrNONE);
            if (ticket > 0) { tim1 = TimeCurrent();         t_Sent = true;       Bull = false;        tst = false;         tst4b = true;
Alert((temp="*** SELL! (2) - " + IntegerToString(ticket) + " - " + Symbol() + " - " + Bull + " - " + TimeToStr(tim1, TIME_MINUTES) + " ***"));      copy_file(temp, 1); } }
         temp = "* BUY Closed! | " + t_Sent + " | " + Bull + " | " + t_O240 + " | " + tst4b + " | " + OrderSelect(ticket, SELECT_BY_TICKET) + " | " + GlobalVariableGet("t-" + Symbol() +
            "_M5_Buy") + " | " + GlobalVariableGet("t-"+ Symbol() + "_M5_Sell") + " | " + DoubleToStr(Bid, 2) + " | " + DoubleToStr(OrderOpenPrice(), 2) + " | " + DoubleToStr(iMA(NULL, 0, 100,
            0, MODE_EMA, PRICE_CLOSE, 0), 2) + " | " + DoubleToStr(iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 3, 0), 2) + " | " +
            tst + " | " + Buy + " | " + Sell + " | " + IntegerToString(t_BS) + " | - | - | " + TimeToStr(tim1,TIME_MINUTES) + " | " + TimeToStr(tim4,TIME_MINUTES) + " | " +
            IntegerToString(floor((TimeCurrent() - tim4) / (Period() * 60))) + " | " + tst2 + " | " + t_Wt2 + " | " + (floor((TimeCurrent() - tim4) / (Period() * 60)) > 7 && t_Wt2) + " | " +
            IntegerToString(TimeCurrent() % 300) + " *";                   copy_file(temp, 3); }
//      else if (OrderSelect(tick_m, SELECT_BY_TICKET) && OrderCloseTime() && ! OrderType()) tick_m = 0;

/*   if (t_Pass && t_Sent && ! Bull && (! t_O240 || (tst2=(iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 2, 0) > 0.0)) ||
   tst || t_H4_M5) && OrderSelect(ticket, SELECT_BY_TICKET) && ! OrderCloseTime()) */
   t_Wt3 = ((tst2=(iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 2, 0) > 0.0)) && TimeCurrent() % 300 > 290) ||
      (TimeCurrent() % 300 < 10 &&/* (t_Wt3 || bt) &&*/ (iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 2, 1) ||
      iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 2, 2)) &&
      (iCustom(NULL, 0, "Parabolic.ex4", 0, 1) < iLow(NULL, 0, 1) || (EPP_Max_ < iClose(NULL, 0, 1) && EPP_Max_ > iOpen(NULL, 0, 1))));            if (tst2) tim5 = TimeCurrent();
   if (t_EppCl && t_Pass && t_Sent && ! Bull && ((((t_Wt3 || ! t_O240)/* && (tst2 || bt))*/ || tst_d ||      // (t_H4_M5 && floor((TimeCurrent()-tim7)/(Period()*60)) > 7) ||
   tst4b) && OrderSelect(ticket, SELECT_BY_TICKET) && ! OrderCloseTime() && (myHour() > 3 || st_bull || (((tst2 && ! t_Rsi515) || (myHour() > 4 && (! iCustom(NULL, 0, "Entry_Points_Pro.ex4", "",
   maxcand, "", 0, 0, 500, "", 0, "", "08:00", "21:00", "", 1, 90, 2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 3, f_wBars(tim6, TimeCurrent())) || iCustom(NULL, 0, "Entry_Points_Pro.ex4",
   "", maxcand, "", 0, 0, 500, "", 0, "", "08:00", "21:00", "", 1, 90, 2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 5, f_wBars(tim6, TimeCurrent()))))) && myHour() > 1))) ||
   (tst3=(OrderSelect(ticket, SELECT_BY_TICKET) && floor(OrderOpenTime() / 60) >= tim_mn_b && floor(OrderOpenTime() / 60) <= tim_min_ && tim_min_ - tim_mn_b < 5))))
      if ((! Sell && (t_BS != 2 || floor((TimeCurrent() - tim4) / (Period() * 60)) > 7) && (! tst4b || floor((TimeCurrent() - tim1) / (Period() * 60)) > 7 || GlobalVariableGet("t-"+
      Symbol() + "_M5_Buy") || ! GlobalVariableGet("t-"+ Symbol() + "_M5_Sell"))) || (floor((TimeCurrent() - tim4) / (Period() * 60)) > 7 && TimeCurrent() % 300 < 10 && t_Wt3) ||
      (tst4b && st_bull && Ask < iMA(NULL, 0, 100, 0, MODE_EMA, PRICE_CLOSE, 0) && OrderOpenPrice() > iMA(NULL, 0, 100, 0, MODE_EMA, PRICE_CLOSE, 0)) || tst3 || t_CPEP3) {
         if (! tst_d ||/* (tick_m &&*/ t_Wt3 || ObjectGet(name, OBJPROP_PRICE1) < Ask) t_Sent = ! mOrderClose(ticket, 0.01, OrderType()? Ask: Bid, 15, clrNONE);
         else { t_Sent = OrderModify(ticket, OrderOpenPrice(), (tst_d? ObjectGet(name, OBJPROP_PRICE1): OrderType()? Ask: Bid) + (Sell? 1.0: -1.0) * 22 * Point(), OrderTakeProfit(), 0, clrNONE);
            if (t_Sent) tick_m = ticket; } }                                        // * 19-04-2022 : 12h à 19h *
      else if (OrderSelect(ticket, SELECT_BY_TICKET) && OrderStopLoss() > iMA(NULL, 0, 100, 0, MODE_EMA, PRICE_CLOSE, 0) &&
         OrderModify(ticket, OrderOpenPrice(), tst && (! t_Rsi515 || t_Adx)? (iCustom(NULL,0,"Parabolic.ex4",0,1)*4.0 + sup_trend) / 5.0: sup_trend, OrderTakeProfit(), 0, clrNONE)) {}
      if ((((! tst_d ||/* (tick_m &&*/ t_Wt3) && ! t_Sent) || (t_Sent && OrderSelect(tick_m, SELECT_BY_TICKET) && OrderCloseTime())) && OrderType()) {
         if (tst4b) tst4b = false;           tick_m = 0;          t_Sent = false;         t_EppCl = false;           t_CPEP3 = false;        t_ATSEP = false;     t_ATSEP2 = false;
Alert((temp="*** SELL Closed! - " + IntegerToString(ticket) + " - " + Symbol() + " - " + Bull + " - " + tst + " - " + t_H4_M5 + " - " + TimeToStr(tim1, TIME_MINUTES) + " - " +
   GlobalVariableGet("t-"+ Symbol() + "_M5_Buy") + " - " + (f_wBars(tim1, TimeCurrent())) + " ***"));    copy_file(temp, 1);     // floor(TimeCurrent()/(60*Period())) - floor(tim1/(60*Period()))
            ticket = 0;       tim1 = 0;         /* if (t_H4_M5) GlobalVariableSet("t-"+ Symbol() + "_M5_Buy", -1);            GlobalVariableSet("t-"+ Symbol() + "_M5_tim1", 0); }*/
            if (! tst3 && tst && t_O240 && GlobalVariableGet("t-"+ Symbol() + "_H4_Buy") && (st_bull || GlobalVariableGet("t-"+ Symbol() + "_M5_Buy"))) {
               ticket = mOrderSend(Symbol(), 0, 0.01, Ask, 15, 0.99 * Ask, 0.0, NULL, Period() == 30? 5555541: Period() == 60? 5555542: 5555543, 0, clrNONE);
               if (ticket > 0) { tim1 = TimeCurrent();         t_Sent = true;       Bull = true;        tst = false;         tst4b = true;
Alert((temp="*** BUY! (2) - " + IntegerToString(ticket) + " - " + Symbol() + " - " + Bull + " - " + TimeToStr(tim1, TIME_MINUTES) + " ***"));      copy_file(temp, 1); } }
            temp = "* SELL Closed! | " + t_Sent + " | " + Bull + " | " + t_O240 + " | " + tst4b + " | " + OrderSelect(ticket, SELECT_BY_TICKET) + " | " + GlobalVariableGet("t-" + Symbol() +
               "_M5_Buy") + " | " + GlobalVariableGet("t-"+ Symbol() + "_M5_Sell") + " | " + DoubleToStr(Ask, 2) + " | " + DoubleToStr(OrderOpenPrice(), 2) + " | " + DoubleToStr(iMA(NULL, 0, 100,
               0, MODE_EMA, PRICE_CLOSE, 0), 2) + " | " + DoubleToStr(iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 2, 0), 2) + " | " +
               tst + " | " + Buy + " | " + Sell + " | " + IntegerToString(t_BS) + " | - | - | " + TimeToStr(tim1,TIME_MINUTES) + " | " + TimeToStr(tim4,TIME_MINUTES) + " | " +
               IntegerToString(floor((TimeCurrent() - tim4) / (Period() * 60))) + " | " + tst2 + " | " + t_Wt3 + " | " + (floor((TimeCurrent() - tim4) / (Period() * 60)) > 7 && t_Wt3) + " | " +
               IntegerToString(TimeCurrent() % 300) + " *";                   copy_file(temp, 3); }
//      else if (OrderSelect(tick_m, SELECT_BY_TICKET) && OrderCloseTime() && OrderType()) tick_m = 0;

   if (t_Sent && TimeCurrent() - tim1 < 2 && TimeCurrent() - GlobalVariableGet("t-"+ Symbol() + "_tim1" + (Period() >= 30? "_240": "")) > 1) {
      GlobalVariableSet("t-"+ Symbol() + (temp="_ticket" + (Period() >= 30? "_240": "")), ticket);          GlobalVars(temp, ticket, 3);
      GlobalVariableSet("t-"+ Symbol() + (temp="_tim1" + (Period() >= 30? "_240": "")), tim1);              GlobalVars(temp, tim1, 3); }

   if ((! ticket || (ticket && (! OrderSelect(ticket, SELECT_BY_TICKET) || OrderCloseTime()))) &&
   GlobalVariableGet("t-"+ Symbol() + "_tim1" + (Period() >= 30? "_240": ""))) { ticket = 0;          tim1 = 0;
      GlobalVariableSet("t-"+ Symbol() + (temp="_ticket" + (Period() >= 30? "_240": "")), 0);         GlobalVars(temp, 0, 4);
      GlobalVariableSet("t-"+ Symbol() + (temp="_tim1" + (Period() >= 30? "_240": "")), 0);           GlobalVars(temp, 0, 4); }

   if (! t_EppCl && OrderSelect(ticket, SELECT_BY_TICKET) && ! OrderCloseTime() && (t_Wt2 || t_Wt3 || tst_) &&
   ((Sell_ && OrderStopLoss() > OrderOpenPrice()) || (Buy_ && OrderStopLoss() < OrderOpenPrice()))) { bool tst1=false;
      tst = false;         tst2 = false;        dtmp = WindowPriceMax();         temp = "-";
      for (int obj=0; obj < ObjectsTotal()/* && ! tst*/; obj ++) { name = ObjectName(obj);
         tst = StringFind(name, "neutral") > 0 && ObjectType(name) == OBJ_TREND && ObjectGet(name, OBJPROP_TIME2) > OrderOpenTime() &&
            ((Sell_ && ObjectGet(name, OBJPROP_PRICE1) > OrderOpenPrice()) || (Buy_ && ObjectGet(name, OBJPROP_PRICE1) < OrderOpenPrice()));
         if (tst && dtmp > fabs(ObjectGet(name, OBJPROP_PRICE1) - OrderOpenPrice())) { temp = name;
            dtmp = fabs(ObjectGet(name, OBJPROP_PRICE1) - OrderOpenPrice()); } }
      if (temp != "-") { tst = false;        name = temp;      for (obj = 0; obj < ObjectsTotal() && ! tst; obj ++) { string name2=ObjectName(obj);
            tst = StringFind(name2, "liquid_") > 0 && ((tst1=(StringSubstr(name2, StringFind(name2, "liquid_buy") + 10, 16) == StringSubstr(name,
               StringFind(name, "neutral") + 7, 16))) || (tst2=(StringSubstr(name2, StringFind(name2, "liquid_sell") + 11, 16) == StringSubstr(name,
               StringFind(name, "neutral") + 7, 16)))) && ObjectType(name2) == OBJ_TREND; }
         if (tst && OrderModify(ticket, OrderOpenPrice(), ((Sell_ && tst1) || (Buy_ && tst2) || (! tst1 && ! tst2)? ObjectGet(name, OBJPROP_PRICE1):
            ObjectGet(name2, OBJPROP_PRICE1)) + (Sell_? 1.0: -1.0) * 22 * Point(), OrderTakeProfit(), 0, clrNONE)) {} } }

   if (ticket && ! Sell && ! Buy) { Buy = Buy_;          Sell = Sell_; }

/*   tst2 = false;     tst3 = false;     if (! ticket2) for (pos = 0; pos < OrdersTotal(); pos ++)      // && ! tst2
      if (OrderSelect(pos, SELECT_BY_POS) && OrderSymbol() == Symbol() && OrderMagicNumber() > 5555550 && OrderType() < 2) { ticket2 = OrderTicket();
         temp = Symbol() + " | " + IntegerToString(ticket2) + " | " + IntegerToString(OrderType()) + " | " + DoubleToStr(OrderLots(), 2) + " | " +
            DoubleToStr(OrderOpenPrice(), Digits()) + " | " + DoubleToStr(OrderStopLoss(), Digits()) + " | " + DoubleToStr(OrderTakeProfit(), Digits()) + " | " +
            OrderComment() + " | " + IntegerToString(OrderMagicNumber());
         tst2 = copy_file(temp, 0) != INVALID_HANDLE;       int orderType=OrderType();       double orderLots=OrderLots(), orderOpenPrice=OrderOpenPrice(),
            orderStopLoss=OrderStopLoss(), orderTakeProfit=OrderTakeProfit();                string orderComment=OrderComment(); }

   if (! tst2 && ! orderMagicNum && (tst3=FileIsExist("EA-write-file_Order_" + Symbol() + ".csv", 0))) { CSV_FILE_READ();        int row=0;
      while(row < ArraySize(line_read) / 7) { ticket2 = StrToInteger(line_read[row][0]);            orderType = StrToInteger(line_read[row][1]);         int ticket3=ticket2;
         orderLots = StrToDouble(line_read[row][2]);             orderOpenPrice = StrToDouble(line_read[row][3]);           orderStopLoss = StrToDouble(line_read[row][4]);
         orderTakeProfit = StrToDouble(line_read[row][5]);             orderComment = line_read[row][6];                    orderMagicNum = StrToInteger(line_read[row][7]);

      if (t_Pass && ticket2 && ! orderType && (iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 3, 0) > 0.0 || ((tst_ || t_H4_M5) &&
      (GlobalVariableGet("t-"+ Symbol() + "_H4_Buy") || GlobalVariableGet("t-"+ Symbol() + "_M5_Previous") == 1))) && OrderSelect(ticket2, SELECT_BY_TICKET) && ! OrderCloseTime()) {     // 4/5 flèche grise
         ticket2 = ! mOrderClose(ticket2, orderLots, orderType? Ask: Bid, 15, clrNONE);       if (! ticket2) {        // < 0.03? orderLots: orderLots - 0.02
Alert((temp="*** BUY Closed! (2) - " + IntegerToString(ticket3) + " - " + Symbol() + " - " + (! orderType) + " - " + tst + " - " + t_H4_M5 + " - " + TimeToStr(OrderOpenTime(), TIME_MINUTES) +
   " - " + GlobalVariableGet("t-"+ Symbol() + "_M5_Sell") + " ***"));         copy_file(temp, 1);        tim3 = OrderOpenTime(); } }

      if (t_Pass && ticket2 && orderType && (iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 2, 0) > 0.0 || ((tst_ || t_H4_M5) &&
      (GlobalVariableGet("t-"+ Symbol() + "_H4_Sell") || GlobalVariableGet("t-"+ Symbol() + "_M5_Previous") == 2))) && OrderSelect(ticket2, SELECT_BY_TICKET) && ! OrderCloseTime()) {    // 4/5 flèche grise
         ticket2 = ! mOrderClose(ticket2, orderLots, orderType? Ask: Bid, 15, clrNONE);       if (! ticket2) {        // < 0.03? orderLots: orderLots - 0.02
Alert((temp="*** SELL Closed! (2) - " + IntegerToString(ticket3) + " - " + Symbol() + " - " + (! orderType) + " - " + tst + " - " + t_H4_M5 + " - " + TimeToStr(OrderOpenTime(), TIME_MINUTES) +
   " - " + GlobalVariableGet("t-"+ Symbol() + "_M5_Buy") + " ***"));          copy_file(temp, 1);        tim3 = OrderOpenTime(); } }

      if (ticket3 && tst3 && ! orderType && (iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "08:00", "21:00", "", 1, 90, 2, 0) > 0.0 || (tst_ &&
      GlobalVariableGet("t-"+ Symbol() + "_H4_Buy")) || (GlobalVariableGet("t-"+ Symbol() + "_M5_Previous") == 2 && GlobalVariableGet("t-"+ Symbol() + "_M5_tim2_") > GlobalVariableGet("t-"+ Symbol() + "_M5_tim1_") &&
      GlobalVariableGet("t-"+ Symbol() + "_M5_tim2_") > tim3 && tim3 > 0 && ! GlobalVariableGet("t-"+ Symbol() + "_M5_Buy") && ! GlobalVariableGet("t-"+ Symbol() + "_M5_Sell")) ||
      GlobalVariableGet("t-"+ Symbol() + "_M5_Buy")) && OrderSelect(ticket3, SELECT_BY_TICKET) && OrderCloseTime()) {         // 4/5 flèche grise     | && OrderProfit() > -1.0
         ticket2 = mOrderSend(Symbol(), 0, orderLots, orderOpenPrice, 15, orderStopLoss, orderTakeProfit, orderComment, orderMagicNum, 0, clrNONE);    // < 0.03? orderLots: orderLots - 0.02
if (ticket2) { Alert((temp="*** BUY! (3) - "+IntegerToString(ticket2)+" - "+Symbol()+" - "+(! orderType)+" - "+GlobalVariableGet("t-"+ Symbol()+"_M5_Buy")+" - "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" ***"));
   copy_file(temp, 1);        ticket3 = ticket2; } }

      if (ticket3 && tst3 && orderType && (iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "08:00", "21:00", "", 1, 90, 3, 0) > 0.0 || (tst_ &&
      GlobalVariableGet("t-"+ Symbol() + "_H4_Sell")) || (GlobalVariableGet("t-"+ Symbol() + "_M5_Previous") == 1 && GlobalVariableGet("t-"+ Symbol() + "_M5_tim1_") > GlobalVariableGet("t-"+ Symbol() + "_M5_tim2_") &&
      GlobalVariableGet("t-"+ Symbol() + "_M5_tim1_") > tim3 && tim3 > 0 && ! GlobalVariableGet("t-"+ Symbol() + "_M5_Buy") && ! GlobalVariableGet("t-"+ Symbol() + "_M5_Sell")) ||
      GlobalVariableGet("t-"+ Symbol() + "_M5_Sell")) && OrderSelect(ticket3, SELECT_BY_TICKET) && OrderCloseTime()) {        // 4/5 flèche grise     | && OrderProfit() > -1.0
         ticket2 = mOrderSend(Symbol(), 1, orderLots, orderOpenPrice, 15, orderStopLoss, orderTakeProfit, orderComment, orderMagicNum, 0, clrNONE);    // < 0.03? orderLots: orderLots - 0.02
if (ticket2) { Alert((temp="*** SELL! (3) - "+IntegerToString(ticket2)+" - "+Symbol()+" - "+(! orderType)+" - "+GlobalVariableGet("t-"+ Symbol()+"_M5_Sell")+" - "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" ***"));
   copy_file(temp, 1);        ticket3 = ticket2; } }     row ++; } }

   row = 0;    if (! tst2 && orderMagicNum) { while(! tst2 && row < ArraySize(line_read) / 7) { tst2 = ! (OrderSelect(StrToInteger(line_read[row][0]), SELECT_BY_TICKET) &&
         OrderCloseTime() && (OrderProfit() < -1.0 || ((StrToInteger(line_read[row][1]) && (Ask < StrToDouble(line_read[row][5]) || Bid > StrToDouble(line_read[row][4]))) ||
         (! StrToInteger(line_read[row][1]) && (Bid > StrToDouble(line_read[row][5]) || Ask < StrToDouble(line_read[row][4]))))));        row ++; }
      if (! tst2) { FileDelete("EA-write-file_Order_" + Symbol() + ".csv");               orderMagicNum = 0;
Alert((temp="*** Fin du signal " + IntegerToString(orderMagicNum) + (OrderProfit() < -1.0? " (1)": " (2)") + " - " +
   IntegerToString(ticket2) + " - " + Symbol() + " - " + (! orderType) + " - " + TimeToStr(TimeCurrent(), TIME_MINUTES) + " ***"));       copy_file(temp, 1); } }

/*   if ((GlobalVariableCheck("t-"+ Symbol() + "_M5_Buy") && GlobalVariableGet("t-"+ Symbol() + "_M5_Buy") && floor(TimeCurrent() / (60 * Period())) > floor(GlobalVariableGet("t-"+ Symbol() + "_M5_tim1") / (60 * Period()))) ||
   ! iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "08:00", "21:00", "", 1, 90, 3, 0)) { GlobalVariableSet("t-"+ Symbol() + "_M5_Buy", 0);        GlobalVariableSet("t-"+ Symbol() + "_M5_tim1", 0); }
   if ((GlobalVariableCheck("t-"+ Symbol() + "_M5_Sell") && GlobalVariableGet("t-"+ Symbol() + "_M5_Sell") && floor(TimeCurrent() / (60 * Period())) > floor(GlobalVariableGet("t-"+ Symbol() + "_M5_tim2") / (60 * Period()))) ||
   ! iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "08:00", "21:00", "", 1, 90, 2, 0)) { GlobalVariableSet("t-"+ Symbol() + "_M5_Sell", 0);       GlobalVariableSet("t-"+ Symbol() + "_M5_tim2", 0); }*/
 }

void DrawArrow(double LinePrice,int BarNum,int Code,bool Bullish,int item) {
   string ArrowName = "Test_Arr"+(Bullish?"-Up_":"-Down_")+IntegerToString(Code)+"-"+LinePrice+" "+IntegerToString(Time[BarNum]);
   ObjectCreate(ArrowName,OBJ_ARROW,0,Time[BarNum],LinePrice);
   ObjectSet(ArrowName, OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet(ArrowName, OBJPROP_ARROWCODE, Code);
   ObjectSet(ArrowName, OBJPROP_COLOR, Bullish? clrLime: item? clrGray: clrPink);
   ObjectSet(ArrowName, OBJPROP_SELECTABLE, 0);
   ObjectSet(ArrowName, OBJPROP_SELECTED, 0);
   ObjectSet(ArrowName, OBJPROP_WIDTH, Code == 159? item? 0: 1: 2); }

int myHour() { return(Hour()); }       // - 1

void GlobalVars(string temp,ulong utmp,int item) {
   temp = "*** GlobalVariableSet("+IntegerToString(Period())+"-"+IntegerToString(item)+")! - " + Symbol() + temp + " - " + utmp + " - " + IntegerToString(Period()) + " - " +
      TimeToStr(TimeCurrent(), TIME_MINUTES) + " ***";         // Alert(())
   copy_file(temp, 1);           if (Period() >= 30) copy_file(temp, 2); }

void Entry_Points_Ind() { bool tst=false, t_Cop=false;         string temp;      int itmp=72;
//      if (GlobalVariableCheck("t-"+ Symbol() + "_Success_240")) itmp = GlobalVariableGet("t-"+ Symbol() + "_Success_240");
      if (! GlobalVariableCheck("t-"+ Symbol() + "_M5_Buy") && ! GlobalVariableCheck("t-"+ Symbol() + "_M5_Sell") && itmp >= 72) M5_Signals();

/*      t_Sent = OrdersTotal();       if (t_Sent && ! ticket) { ticket = GlobalVariableGet("t-"+ Symbol() + "_ticket_240");
         if (ticket > 0) Per_240 = GlobalVariableGet("t-"+ Symbol() + "_Period"); }          t_Sent = ticket; */

      if (! t_O240 && GlobalVariableCheck("t-"+ Symbol() + "_Order_240")) t_O240 = GlobalVariableGet("t-"+ Symbol() + "_Order_240");
//         if (t_O240) Per_240 = GlobalVariableGet("t-"+ Symbol() + "_Period"); }              if (! Per_240) Per_240 = 1;

      if ((((Period() < 30 && (Minute() < 57 || myHour() < 23 || DayOfWeek() < 5) && (myHour() > 2 || DayOfWeek() > 1)) &&
      ((iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90,
      2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", t_O240, 2, 0) > 0.0 && (t_O240 || myHour() < 5)) ||
      (iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "08:00", "21:00", "", 1, 90,
      2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", t_O240, 2, 0) > 0.0 && ! t_O240)) && itmp >= 72) &&
      ! GlobalVariableGet("t-"+ Symbol() + "_M5_Buy")) || (t_Sent && Buy)) { GlobalVariableSet("t-"+ Symbol() + (temp="_M5_Buy"), 1);    GlobalVars(temp, 1, 1);
         GlobalVariableSet("t-"+ Symbol() + (temp="_M5_tim1"), TimeCurrent());      GlobalVars(temp, TimeCurrent(), 1);
         temp = "*** BUY M5! - " + Symbol() + " - " + TimeToStr(TimeCurrent(), TIME_MINUTES) + " ***";
/*if (! (Seconds() % 20)) Alert(temp);*/            if (t_Cop) copy_file(temp, 1); }

      if ((((Period() < 30 && (Minute() < 57 || myHour() < 23 || DayOfWeek() < 5) && (myHour() > 2 || DayOfWeek() > 1)) &&
      ((iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90,
      2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", t_O240, 3, 0) > 0.0 && (t_O240 || myHour() < 5)) ||
      (iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "08:00", "21:00", "", 1, 90,
      2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", t_O240, 3, 0) > 0.0 && ! t_O240)) && itmp >= 72) &&
      ! GlobalVariableGet("t-"+ Symbol() + "_M5_Sell")) || (t_Sent && Sell)) { GlobalVariableSet("t-"+ Symbol()+(temp="_M5_Sell"), 1);    GlobalVars(temp, 1, 2);
         GlobalVariableSet("t-"+ Symbol() + (temp="_M5_tim2"), TimeCurrent());      GlobalVars(temp, TimeCurrent(), 2);
         temp = "*** SELL M5! - " + Symbol() + " - " + TimeToStr(TimeCurrent(), TIME_MINUTES) + " ***";
/*if (! (Seconds() % 20)) Alert(temp);*/            if (t_Cop) copy_file(temp, 1); }

      datetime tim2=Period() < 30? fmax(GlobalVariableGet("t-"+ Symbol() + "_M5_tim1"), GlobalVariableGet("t-"+ Symbol() + "_M5_tim2")):
         fmax(GlobalVariableGet("t-"+ Symbol() + "_H4_tim1"), GlobalVariableGet("t-"+ Symbol() + "_H4_tim2"));       bool tst_d, tst_u;
// dnTrend GBPJPY.i240 2022.12.08 08:00 O
      for (int pos=ObjectsTotal()-1; pos >= 0 && ! tst; pos --) {
         datetime OTim1/*=0, OTim2=0*/;       string name = ObjectName(pos);         OTim1 = ObjectGet(name, OBJPROP_TIME1);
/*         if (! OTim2) OTim2 = OTim1;      if (OTim1 > OTim2) OTim2 = OTim1;*/          int type=ObjectType(name);
         tst = ((tst_d=(StringSubstr(name,0,7)=="dnTrend")) || (tst_u=(StringSubstr(name,0,7)=="upTrend"))) &&// StringSubstr(name, 8, StringLen("t-"+ Symbol())) == Symbol() &&
            type == OBJ_ARROW && floor(OTim1 / (60 * Period())) > floor(tim2 / (60 * Period())) && tim2 > 0;
         if (StringSubstr(name, 2, 5) == "Trend" && fabs(floor(OTim1 / (60 * Period())) - floor(tim2 / (60 * Period()))) < 120 && type == OBJ_ARROW &&
         TimeCurrent() % 300 > 298) { temp = "*** --Trend! x - " + name + " - " + TimeToStr(OTim1, TIME_MINUTES) + " - " + TimeToStr(tim2, TIME_MINUTES) + " ***";
            if (t_Cop) copy_file(temp, 1); } }        // && floor(TimeCurrent() / (60 * Period())) - floor(OTim1 / (60 * Period())) < 720 / Period();
      if (tst && ! OrdersTotal()) { tst = false;      tst_d = false;       tst_u = false; }
      if (tst) { temp = "*** --Trend! (2) - " + name + " - " + TimeToStr(OTim1, TIME_MINUTES) + " - " + /*TimeToStr(OTim2, TIME_MINUTES) + " - " + */TimeToStr(tim2, TIME_MINUTES) + " ***";
         if (AccountInfoInteger(ACCOUNT_TRADE_ALLOWED)) Alert(temp);        if (t_Cop) copy_file(temp, 1); }

      if (((! iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90,
      2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 2, f_wBars(tim2, TimeCurrent())) ||
      iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 4, 0) > 0.0 ||
      iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 4, 1) > 0.0 ||
      iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 3, 0) > 0.0 ||
      iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 5, 0) > 0.0 ||
      ! tim2 || tst_u) && (GlobalVariableGet("t-"+ Symbol() + "_M5_Buy") || GlobalVariableGet("t-"+ Symbol() + "_H4_Buy")))) {
         if (Period() < 30) { if (GlobalVariableGet("t-"+ Symbol() + "_M5_Buy")) {
            GlobalVariableSet("t-"+ Symbol() + (temp="_M5_Buy"), 0);             GlobalVars(temp, 0, 5);
            GlobalVariableSet("t-"+ Symbol() + (temp="_M5_Previous"), 1);        GlobalVars(temp, 1, 5);
            GlobalVariableSet("t-"+ Symbol() + "_M5_tim1_", GlobalVariableGet("t-"+ Symbol() + "_M5_tim1"));
            GlobalVariableSet("t-"+ Symbol() + (temp="_M5_tim1"), 0);            GlobalVars(temp, 0, 5);
            temp = "*** M5_Buy = false;! - " + Symbol() + " - " + IntegerToString(Period()) + " - " + DoubleToStr(iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "",
               "01:00", "23:00", "", 1, 90, 2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 2, f_wBars(tim2, TimeCurrent())), Digits()) + " - " + DoubleToStr(iCustom(NULL, 0, "Entry_Points_Pro.ex4",
               "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 4, 0), Digits()) + " - " + DoubleToStr(iCustom(NULL, 0,
               "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 4, 1), Digits()) + " - " +
               DoubleToStr(iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 3, 0),
               Digits()) + " - " + DoubleToStr(iCustom(NULL, 0, "Entry_Points_Pro.ex4", 2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 5, 0), Digits()) + " - " + IntegerToString(f_wBars(tim2,
               TimeCurrent())) + " - " + TimeToStr(tim2, TIME_MINUTES) + " - " + TimeToStr(TimeCurrent(), TIME_MINUTES) + " ***";         if (t_Cop) copy_file(temp, 1); } }
         else if (GlobalVariableGet("t-"+ Symbol() + "_H4_Buy")) { GlobalVariableSet("t-"+ Symbol() + (temp="_H4_Buy"), 0);            GlobalVars(temp, 0, 6);
            GlobalVariableSet("t-"+ Symbol() + (temp="_H4_tim1"), 0);               GlobalVars(temp, 0, 6);
            t_O240 = false;      GlobalVariableSet("t-"+ Symbol() + (temp="_Order_240"), 0);       GlobalVars(temp, 0, 6); } }
      if (((! iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90,
      2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 3, f_wBars(tim2, TimeCurrent())) ||
      iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 5, 0) > 0.0 ||
      iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 5, 1) > 0.0 ||
      iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 2, 0) > 0.0 ||
      iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 4, 0) > 0.0 ||
      ! tim2 || tst_d) && (GlobalVariableGet("t-"+ Symbol() + "_M5_Sell") || GlobalVariableGet("t-"+ Symbol() + "_H4_Sell")))) {
         if (Period() < 30) { if (GlobalVariableGet("t-"+ Symbol() + "_M5_Sell")) {
            GlobalVariableSet("t-"+ Symbol() + (temp="_M5_Sell"), 0);            GlobalVars(temp, 0, 7);
            GlobalVariableSet("t-"+ Symbol() + (temp="_M5_Previous"), 2);        GlobalVars(temp, 2, 7);
            GlobalVariableSet("t-"+ Symbol() + "_M5_tim2_", GlobalVariableGet("t-"+ Symbol() + "_M5_tim2"));
            GlobalVariableSet("t-"+ Symbol() + (temp="_M5_tim2"), 0);            GlobalVars(temp, 0, 7);
            temp = "*** M5_Sell = false;! - " + Symbol() + " - " + IntegerToString(Period()) + " - " + DoubleToStr(iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "",
               "01:00", "23:00", "", 1, 90, 2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 3, f_wBars(tim2, TimeCurrent())), Digits()) + " - " + DoubleToStr(iCustom(NULL, 0, "Entry_Points_Pro.ex4",
               "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 5, 0), Digits()) + " - " + DoubleToStr(iCustom(NULL, 0,
               "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 5, 1), Digits()) + " - " +
               DoubleToStr(iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90, 2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 2, 0),
               Digits()) + " - " + DoubleToStr(iCustom(NULL, 0, "Entry_Points_Pro.ex4", 2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 4, 0), Digits()) + " - " + IntegerToString(f_wBars(tim2,
               TimeCurrent())) + " - " + TimeToStr(tim2, TIME_MINUTES) + " - " + TimeToStr(TimeCurrent(), TIME_MINUTES) + " ***";         if (t_Cop) copy_file(temp, 1); } }
         else if (GlobalVariableGet("t-"+ Symbol() + "_H4_Sell")) { GlobalVariableSet("t-"+ Symbol() + (temp="_H4_Sell"), 0);          GlobalVars(temp, 0, 8);
            GlobalVariableSet("t-"+ Symbol() + (temp="_H4_tim2"), 0);               GlobalVars(temp, 0, 8);
            t_O240 = false;      GlobalVariableSet("t-"+ Symbol() + (temp="_Order_240"), 0);       GlobalVars(temp, 0, 8); } } }

void M5_Signals() { bool tst=false;       string temp;
   for (int pos=0; pos < 200 && ! tst; pos ++) {
      if (iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90,
      2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 2, pos) > 0.0) { tst = true;
         GlobalVariableSet("t-"+ Symbol() + (temp="_M5_Buy"), 1);             GlobalVars(temp, 1, 9);
         GlobalVariableSet("t-"+ Symbol() + (temp="_M5_tim1"), Time[pos]);    GlobalVars(temp, Time[pos], 9); }

      if (iCustom(NULL, 0, "Entry_Points_Pro.ex4", "", maxcand, "", 0, 0, 500, "", 0, "", "01:00", "23:00", "", 1, 90,
      2, DeepSkyBlue, Red, LimeGreen, LightSkyBlue, "", false, 3, pos) > 0.0) { tst = true;
         GlobalVariableSet("t-"+ Symbol() + (temp="_M5_Sell"), 1);            GlobalVars(temp, 1, 10);
         GlobalVariableSet("t-"+ Symbol() + (temp="_M5_tim2"), Time[pos]);    GlobalVars(temp, Time[pos], 10); } } }

void Close_All_Trades(bool t_All) { string temp;
  for (int i = OrdersTotal()-1; i >= 0 && (t_All || f_Profit(0) <= -5.8 * TsTv); i --) {
    if (OrderSelect(i, SELECT_BY_POS)) { bool result = false;
       switch(OrderType()) {
          //Close opened long positions
          case OP_BUY  : result = OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),15,Pink);   // Slippage
            if (! t_All && OrderSelect(OrderTicket(), SELECT_BY_TICKET)) {
               GlobalVariableSet(Symbol() + "_Day_Balance", GlobalVariableGet(Symbol() + "_Day_Balance") + OrderProfit());
               if (OrderProfit() < 0.0) GlobalVariableSet(Symbol() + "_Balance", GlobalVariableGet(Symbol() + "_Balance") + OrderProfit()); }      break;
          //Close opened short positions
          case OP_SELL : result = OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),15,Pink);   // Slippage
            if (! t_All && OrderSelect(OrderTicket(), SELECT_BY_TICKET)) {
               GlobalVariableSet(Symbol() + "_Day_Balance", GlobalVariableGet(Symbol() + "_Day_Balance") + OrderProfit());
               if (OrderProfit() < 0.0) GlobalVariableSet(Symbol() + "_Balance", GlobalVariableGet(Symbol() + "_Balance") + OrderProfit()); }      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 Target Reached. All Trades Have Been Closed. (" + DoubleToStr(AccountBalance(), 2) + " *****";      Alert(temp); }

int mOrderSend(string symb,int type,double lots,double prx,int slip,double sl,double tp,string comm,long mgcnum,datetime exp,int clr) {
   return (TimeCurrent() < nxt_tim? true: OrderSend(symb, type, lots, prx, slip, sl, tp, comm, mgcnum, exp, clr)); }

bool mOrderClose(int tickt,double lots,double prx,int slip,int clr) { bool tst=false;
   t_DrDn = (GlobalVariableGet(Symbol() + "_Day_Balance") <= -5.7 * TsTv);
   t_DrUp = (GlobalVariableGet(Symbol() + "_Day_Balance") >= 10.0);
   if (Period() < 60 && (tst=OrderClose(tickt, lots, prx, slip, clr)) && OrderSelect(tickt, SELECT_BY_TICKET)) {
      GlobalVariableSet(Symbol() + "_Day_Balance", GlobalVariableGet(Symbol() + "_Day_Balance") + OrderProfit());
      if (OrderProfit() < 0.0) GlobalVariableSet(Symbol() + "_Balance", GlobalVariableGet(Symbol() + "_Balance") + OrderProfit()); }
   return tst; }

double f_Profit(bool t_Hst) { double dtmp=0.0;
   for (int pos=0; pos < (t_Hst? OrdersHistoryTotal(): OrdersTotal()); pos ++) if (OrderSelect(pos, SELECT_BY_POS, t_Hst? MODE_HISTORY: MODE_TRADES) &&
      Symbol() == OrderSymbol() && OrderProfit() && (! t_Hst || OrderOpenTime() > tim_Hst)) dtmp += OrderProfit();
   return dtmp; }

/* Alert("******* HA-1: " + iBarShift(NULL, 0, CP_tim) + " - " + TimeToStr(Time[iBarShift(NULL, 0, CP_tim)], TIME_MINUTES) + " - " + HA_Bull(iOpen(NULL, 0, iBarShift(NULL, 0, CP_tim)),
   iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)), iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)), iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)), iBarShift(NULL, 0, CP_tim)) + " *******");
Alert("******* HA-2: " + (iBarShift(NULL, 0, CP_tim)-1) + " - " + TimeToStr(Time[iBarShift(NULL, 0, CP_tim)-1], TIME_MINUTES) + " - " + HA_Bull(iOpen(NULL, 0, iBarShift(NULL, 0, CP_tim)-1),
   iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)-1), iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)-1), iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)-1), iBarShift(NULL, 0, CP_tim)-1) + " *******");
Alert("******* HA-3: " + (iBarShift(NULL, 0, CP_tim)-2) + " - " + TimeToStr(Time[iBarShift(NULL, 0, CP_tim)-2], TIME_MINUTES) + " - " + HA_Bull(iOpen(NULL, 0, iBarShift(NULL, 0, CP_tim)-2),
   iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)-2), iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)-2), iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)-2), iBarShift(NULL, 0, CP_tim)-2) + " *******");
Alert("******* HA-4: " + (iBarShift(NULL, 0, CP_tim)-3) + " - " + TimeToStr(Time[iBarShift(NULL, 0, CP_tim)-3], TIME_MINUTES) + " - " + HA_Bull(iOpen(NULL, 0, iBarShift(NULL, 0, CP_tim)-3),
   iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)-3), iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)-3), iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)-3), iBarShift(NULL, 0, CP_tim)-3) + " *******");
Alert("******* HA-5: " + (iBarShift(NULL, 0, CP_tim)-4) + " - " + TimeToStr(Time[iBarShift(NULL, 0, CP_tim)-4], TIME_MINUTES) + " - " + HA_Bull(iOpen(NULL, 0, iBarShift(NULL, 0, CP_tim)-4),
   iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)-4), iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)-4), iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)-4), iBarShift(NULL, 0, CP_tim)-4) + " *******");
Alert("******* HA-6: " + (iBarShift(NULL, 0, CP_tim)-5) + " - " + TimeToStr(Time[iBarShift(NULL, 0, CP_tim)-5], TIME_MINUTES) + " - " + HA_Bull(iOpen(NULL, 0, iBarShift(NULL, 0, CP_tim)-5),
   iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)-5), iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)-5), iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)-5), iBarShift(NULL, 0, CP_tim)-5) + " *******");
Alert("******* HA-7: " + (iBarShift(NULL, 0, CP_tim)-6) + " - " + TimeToStr(Time[iBarShift(NULL, 0, CP_tim)-6], TIME_MINUTES) + " - " + HA_Bull(iOpen(NULL, 0, iBarShift(NULL, 0, CP_tim)-6),
   iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)-6), iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)-6), iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)-6), iBarShift(NULL, 0, CP_tim)-6) + " *******");
Alert("******* HA-7: " + (iBarShift(NULL, 0, CP_tim)-7) + " - " + TimeToStr(Time[iBarShift(NULL, 0, CP_tim)-7], TIME_MINUTES) + " - " + HA_Bull(iOpen(NULL, 0, iBarShift(NULL, 0, CP_tim)-7),
   iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)-7), iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)-7), iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)-7), iBarShift(NULL, 0, CP_tim)-7) + " *******");
Alert("******* HA-8: " + (iBarShift(NULL, 0, CP_tim)-8) + " - " + TimeToStr(Time[iBarShift(NULL, 0, CP_tim)-8], TIME_MINUTES) + " - " + HA_Bull(iOpen(NULL, 0, iBarShift(NULL, 0, CP_tim)-8),
   iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)-8), iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)-8), iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)-8), iBarShift(NULL, 0, CP_tim)-8) + " *******");
Alert("******* HA-9: " + (iBarShift(NULL, 0, CP_tim)-9) + " - " + TimeToStr(Time[iBarShift(NULL, 0, CP_tim)-9], TIME_MINUTES) + " - " + HA_Bull(iOpen(NULL, 0, iBarShift(NULL, 0, CP_tim)-9),
   iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)-9), iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)-9), iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)-9), iBarShift(NULL, 0, CP_tim)-9) + " *******");
Alert("******* HA-10: " + (iBarShift(NULL, 0, CP_tim)-10) + " - " + TimeToStr(Time[iBarShift(NULL, 0, CP_tim)-10], TIME_MINUTES) + " - " + HA_Bull(iOpen(NULL, 0, iBarShift(NULL, 0, CP_tim)-10),
   iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)-10), iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)-10), iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)-10), iBarShift(NULL, 0, CP_tim)-10) + " *******");
Alert("******* HA-11: " + (iBarShift(NULL, 0, CP_tim)-11) + " - " + TimeToStr(Time[iBarShift(NULL, 0, CP_tim)-11], TIME_MINUTES) + " - " + HA_Bull(iOpen(NULL, 0, iBarShift(NULL, 0, CP_tim)-11),
   iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)-11), iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)-11), iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)-11), iBarShift(NULL, 0, CP_tim)-11) + " *******");
Alert("******* HA-12: " + (iBarShift(NULL, 0, CP_tim)-12) + " - " + TimeToStr(Time[iBarShift(NULL, 0, CP_tim)-12], TIME_MINUTES) + " - " + HA_Bull(iOpen(NULL, 0, iBarShift(NULL, 0, CP_tim)-12),
   iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)-12), iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)-12), iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)-12), iBarShift(NULL, 0, CP_tim)-12) + " *******");
Alert("******* HA-13: " + (iBarShift(NULL, 0, CP_tim)-13) + " - " + TimeToStr(Time[iBarShift(NULL, 0, CP_tim)-13], TIME_MINUTES) + " - " + HA_Bull(iOpen(NULL, 0, iBarShift(NULL, 0, CP_tim)-13),
   iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)-13), iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)-13), iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)-13), iBarShift(NULL, 0, CP_tim)-13) + " *******");
Alert("******* HA-14: " + (iBarShift(NULL, 0, CP_tim)-14) + " - " + TimeToStr(Time[iBarShift(NULL, 0, CP_tim)-14], TIME_MINUTES) + " - " + HA_Bull(iOpen(NULL, 0, iBarShift(NULL, 0, CP_tim)-14),
   iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)-14), iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)-14), iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)-14), iBarShift(NULL, 0, CP_tim)-14) + " *******");
Alert("******* HA-15: " + (iBarShift(NULL, 0, CP_tim)-15) + " - " + TimeToStr(Time[iBarShift(NULL, 0, CP_tim)-15], TIME_MINUTES) + " - " + HA_Bull(iOpen(NULL, 0, iBarShift(NULL, 0, CP_tim)-15),
   iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)-15), iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)-15), iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)-15), iBarShift(NULL, 0, CP_tim)-15) + " *******");
Alert("******* HA-16: " + (iBarShift(NULL, 0, CP_tim)-16) + " - " + TimeToStr(Time[iBarShift(NULL, 0, CP_tim)-16], TIME_MINUTES) + " - " + HA_Bull(iOpen(NULL, 0, iBarShift(NULL, 0, CP_tim)-16),
   iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)-16), iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)-16), iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)-16), iBarShift(NULL, 0, CP_tim)-16) + " *******");
Alert("******* HA-17: " + (iBarShift(NULL, 0, CP_tim)-17) + " - " + TimeToStr(Time[iBarShift(NULL, 0, CP_tim)-17], TIME_MINUTES) + " - " + HA_Bull(iOpen(NULL, 0, iBarShift(NULL, 0, CP_tim)-17),
   iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)-17), iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)-17), iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)-17), iBarShift(NULL, 0, CP_tim)-17) + " *******");
Alert("******* HA-18: " + (iBarShift(NULL, 0, CP_tim)-18) + " - " + TimeToStr(Time[iBarShift(NULL, 0, CP_tim)-18], TIME_MINUTES) + " - " + HA_Bull(iOpen(NULL, 0, iBarShift(NULL, 0, CP_tim)-18),
   iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)-18), iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)-18), iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)-18), iBarShift(NULL, 0, CP_tim)-18) + " *******");
Alert("******* HA-19: " + (iBarShift(NULL, 0, CP_tim)-19) + " - " + TimeToStr(Time[iBarShift(NULL, 0, CP_tim)-19], TIME_MINUTES) + " - " + HA_Bull(iOpen(NULL, 0, iBarShift(NULL, 0, CP_tim)-19),
   iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)-19), iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)-19), iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)-19), iBarShift(NULL, 0, CP_tim)-19) + " *******");
Alert("******* HA-20: " + (iBarShift(NULL, 0, CP_tim)-20) + " - " + TimeToStr(Time[iBarShift(NULL, 0, CP_tim)-20], TIME_MINUTES) + " - " + HA_Bull(iOpen(NULL, 0, iBarShift(NULL, 0, CP_tim)-20),
   iClose(NULL, 0, iBarShift(NULL, 0, CP_tim)-20), iHigh(NULL, 0, iBarShift(NULL, 0, CP_tim)-20), iLow(NULL, 0, iBarShift(NULL, 0, CP_tim)-20), iBarShift(NULL, 0, CP_tim)-20) + " *******"); */
