//#property strict
extern double lot = 0.01;  // Taille des lots
extern int slip = 5;       // Taille du slippage
extern int comm = 13;      // Commission (pipettes)

//                test v iOPen/(iHigh+iLow)/2
bool ea_show=false, Op_OHL=true, Op_Show=false, Op_DDw=false, Op_HiLo=false,
      rate1c=false, rate2c=true, rate3c=false, rate4c=false, haBull;
int frameX=20,frameY=35, cpt=1, ticket, total2=0, total3=0, total2_, total3_;
bool t_clo_=false, t_blue=true, t_vilt=true, t_orge=true, bull_, pass1, endbull;
datetime blue_time,blue_time2,vilt_time,vilt_time2,orge_time,orge_time2;
string LabelNameEnd;       double pips2dbl, WM=0, AccBalance, p_Coef;
double ha1Open, ha1Close, haOpen, haClose, haHigh, haLow;

#include <Liste dObjets EA.mqh>

void OnInit() { ObjectsDelete(1);
//  EventSetMillisecondTimer(100);
  ChartSetInteger(0,CHART_SHOW_GRID,true);

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

  if (GlobalVariableCheck("Bullish")) bull_ = GlobalVariableGet("Bullish");
  if (GlobalVariableCheck("Ticket")) { ticket = GlobalVariableGet("Ticket");
     Print("*** -> (1) Ticket LOADED! ",ticket," ***"); }  else Print("*** -> (1) Ticket NOT LOADED! ",ticket," ***");

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

void OnTick() { if (ea_show) { ObjectsDelete(0);
     if (GlobalVariableCheck("frameX")) frameX = GlobalVariableGet("frameX");
     CreateButton(0,0,"<>",1,frameX-18,frameY+1,0);     CreateButton(0,0,"Show-EA",0,frameX,frameY,0); }
  if (GlobalVariableCheck("RateOC1")) rate1c = GlobalVariableGet("RateOC1");
  if (! rate1c) { if (GlobalVariableCheck("RateOC2")) rate2c = GlobalVariableGet("RateOC2");
  if (! rate2c) { if (GlobalVariableCheck("RateOC3")) rate3c = GlobalVariableGet("RateOC3");
  if (! rate3c) if (GlobalVariableCheck("RateOC4")) rate4c = GlobalVariableGet("RateOC4"); } }
  if (GlobalVariableCheck("Show_EA")) ea_show = GlobalVariableGet("Show_EA");

  int obj_total=ObjectsTotal(), i, j, k=0, k_, p=0, exp_1=0, exp_2=0;
  int obj_bar_cl, obj_bar_cl2, obj_bar_cl3, prv_pos=0, total=0, total0, hightotal=0, drawdown=0, ntot;   //, type
  int obj_bars[], obj_pos[], obj_pos0[], obj_reOps[][2], reOpn_brs[], reClo_brs[];                         // v [2]
  string name, obj_liqTypes[], obj_liqTyp_1="", obj_liqTyp_2="";     double drawdwnp,obj_Prices[],obj_prClots[],reOpn_prs[],reClo_prs[],obj_Levels[];
  datetime OTim1, OTim2, obj_Neutrals[];  bool t_neutral=false, t_liquid_b=false, t_liquid_s=false, t_neutral0, t_liquid_b0, t_liquid_s0;
  ArrayResize(obj_bars, obj_total);       ArrayResize(obj_pos, obj_total);       ArrayResize(obj_pos0, obj_total);
  ArrayResize(obj_reOps, obj_total);      ArrayResize(obj_Prices, obj_total);    ArrayResize(obj_prClots, obj_total);
  ArrayResize(obj_Levels, obj_total);     ArrayResize(reOpn_prs, obj_total);     ArrayResize(reClo_prs, obj_total);
  ArrayResize(reOpn_brs, obj_total);      ArrayResize(reClo_brs, obj_total);     ArrayResize(obj_Neutrals, obj_total);
  ArrayResize(obj_liqTypes, obj_total);   string nam_B, nam_S;                   bool bull, pos_prem=true;
  if (bull_==NULL && bull_!=false) Print("** TEST mode strict -> (bull_==NULL && bull_!=false) **");

  if (! ticket && (OrdersTotal()==1 || OrdersTotal()==3)) { 
      if (GlobalVariableCheck("Bullish")) bull_ = GlobalVariableGet("Bullish");
      if (GlobalVariableCheck("Ticket")) { ticket = GlobalVariableGet("Ticket");
         Print("*** -> (2) Ticket LOADED! ",ticket," ***"); }  else Print("*** -> (2) Ticket NOT LOADED! ",ticket," ***"); }
//    confirmer manuellement avec une option par click      | v ou MessageBox()                                            ***
//  if (! OrdersTotal() && ticket) { Print("** --> Ticket CHANGED! (OnTick) ",ticket," -> 0 ***");      ticket = 0; }      ***
  for (int pos=0; pos<obj_total; pos++) {
     OTim2 = 0;     name = ObjectName(pos);     //type = ObjectType(name);
     t_neutral0 = t_neutral;   t_liquid_b0 = t_liquid_b;   t_liquid_s0 = t_liquid_s;
     if ((t_neutral=(StringFind(name, "neutral") > 0)) ||
     (t_liquid_b=(StringFind(name, "liquid_buy") > 0)) || (t_liquid_s=(StringFind(name, "liquid_sell") > 0))) {
        if ((! t_neutral0 && t_neutral) || (! t_liquid_b0 && t_liquid_b) || (! t_liquid_s0 && t_liquid_s)) i = 0;
        OTim1 = ObjectGet(name,OBJPROP_TIME1);
        while (OTim1 > OTim2 && i < Bars) { OTim2 = iTime(NULL,0,Bars-(i+1));   i ++; }
// Time[0] = bougie en cours  |  Time[Bars-1] = bougie la plus ancienne du chart
        if (t_neutral) { obj_Neutrals[pos] = OTim1;      obj_bars[pos] = i;     obj_pos[p] = pos;     obj_pos0[p] = pos;
            obj_liqTypes[pos] = (ObjectType((nam_B=StringSubstr(name, 0, (StringSubstr(name,5,1)==2?13:8))+"liquid_buy"+StringSubstr
               (name, StringFind(name, "tral")+4))) > 0 ? "Buy" : (ObjectType((nam_S=StringSubstr(name,0,(StringSubstr(name,5,1)==2?13:8))+
                  "liquid_sell"+StringSubstr(name, StringFind(name, "tral")+4))) > 0 ? "Sell" : "Error"));
            obj_Prices[pos] = (iOpen(NULL,0,Bars-i) * (rate1c? 5.0: rate2c? 4.0: rate3c? 3.0: rate4c? 2.0: 1.0) +
                  iClose(NULL,0,Bars-i) * (rate1c? 1.0: rate2c? 2.0: rate3c? 3.0: rate4c? 4.0: 5.0)) / 6.0;
            if (ObjectType((nam_B=StringSubstr(name, 0, (StringSubstr(name,5,1)==2?13:8))+"liquid_buy"+StringSubstr(name, 
               StringFind(name, "tral")+4))) > 0 && ObjectType((nam_S=StringSubstr(name,0,(StringSubstr(name,5,1)==2?13:8))+
               "liquid_sell"+StringSubstr(name, StringFind(name, "tral")+4))) > 0) {     if (Op_HiLo) 
               Print("*** -> 2 liquid lines | ",pos," - ",(Bars-i)," - ",obj_Prices[pos]," - ",StringToUpper(obj_liqTypes[pos])," - ",
                  StringToUpper(obj_liqTyp_1)," - barre : ",TimeToStr(Time[Bars-i],TIME_DATE|TIME_MINUTES)," ***");
                  obj_liqTypes[pos] = "Error-2"; }      // obj_liqTyp_1   ou   obj_liqTyp_1=="Sell"? "Buy": "Sell"
            if (obj_liqTyp_1 == obj_liqTyp_2 && obj_liqTyp_1 != "") { k ++;     for (j=1; j<=k; j++) obj_pos[p-j] = pos; }
            else   k = 0;                    // groupe activé ou pas, possible meilleur résultat sans mais avec fort drawdown -> *(1)*
            obj_Levels[pos] = (ObjectGet((obj_liqTypes[pos]=="Buy"?nam_B:nam_S),OBJPROP_PRICE1)+ObjectGet(name,OBJPROP_PRICE1))/2.0;
            obj_liqTyp_2 = obj_liqTyp_1;     obj_liqTyp_1 = obj_liqTypes[pos];      p ++; }
/*        total += (prv_pos ? (obj_liqTypes[pos] == "Buy" && obj_liqTypes[prv_pos] == "Sell" ? 1 :      // sans les commissions
            (obj_liqTypes[prv_pos] == "Buy" && obj_liqTypes[pos] == "Sell" ? -1 : 0)) * (obj_Prices[prv_pos]-obj_Prices[pos])/Point : 0);
        Print (pos, " object ("+IntegerToString(type)+") ", name, " description= "+ObjectDescription(name)+" * "+
            TimeToStr(OTim1,TIME_DATE|TIME_SECONDS)+"-"+TimeToStr(OTim2,TIME_DATE|TIME_SECONDS)+"-"+DoubleToStr(iOpen(NULL,0,Bars-i),5)+
            "-("+IntegerToString(i)+")-"+(ObjectType(StringSubstr(name,0,(StringSubstr(name,5,1)==2?13:8))+"liquid_buy"+StringSubstr(name, 
            StringFind(name, "tral")+4)) > 0 ? "Buy" : (ObjectType(StringSubstr(name,0,(StringSubstr(name,5,1)==2?13:8))+"liquid_sell"+
            StringSubstr(name, StringFind(name, "tral")+4)) > 0 ? "Sell" : t_neutral?"Error":"liquid"))+"-"+ObjectGet(name,OBJPROP_PRICE1)+"-"+
            TimeToString(ObjectGet(name,OBJPROP_TIME2),TIME_DATE|TIME_SECONDS)+"-"+ObjectGet(name,OBJPROP_PRICE2)+"-"+
            DoubleToStr(obj_Prices[pos],5)+"-"+(ObjectType(StringSubstr(name, 0, (StringSubstr(name,5,1)==2?13:8))+"liquid_buy"+
            StringSubstr(name, StringFind(name, "tral")+4)) > 0 ? DoubleToStr((obj_Prices[pos]-ObjectGet(name,OBJPROP_PRICE1))/Point,0) :
            (ObjectType(StringSubstr(name, 0, (StringSubstr(name,5,1)==2?13:8))+"liquid_sell"+StringSubstr(name, StringFind(name, "tral")+4))>0 ?
            DoubleToStr((ObjectGet(name,OBJPROP_PRICE1)-obj_Prices[pos])/Point,0) : 0))+" | "+IntegerToString(prv_pos)+" - "+
            DoubleToStr(obj_Prices[prv_pos], 5)+" - "+IntegerToString((prv_pos ? (obj_liqTypes[pos] == "Buy" && obj_liqTypes[prv_pos] == "Sell"? 1: 
            (obj_liqTypes[prv_pos] == "Buy" && obj_liqTypes[pos] == "Sell" ? -1 : 0)) * (obj_Prices[prv_pos]-obj_Prices[pos])/Point : 0))+
            " - "+IntegerToString(total)+" *");
            if ((obj_liqTypes[pos] == "Buy" && obj_liqTypes[prv_pos] != "Buy") ||
               (obj_liqTypes[pos] == "Sell" && obj_liqTypes[prv_pos] != "Sell")) prv_pos = pos;     //*/
     }  }   k = 0;   p = 0;      //total = 0;     prv_pos = 0;            // <- remettre si | est remis

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

/* - partie finale ---------------------------------------------------------------------------------------------------------------- */
   double tmp, tmp2, this_Order_Price;     datetime this_Order_Time;
   if (! total2) total2 = total;       if (! total3 && ! total3_) { total3 = total;    AccBalance = AccountBalance(); }
   obj_reOps[pos][1] = 0;     pos --;     //pos = prv_pos;     prv_pos = prv_pos0;     name = ObjectName(pos);    k_ = k;
   obj_Prices[pos] = (iOpen(NULL,0,Bars-obj_bars[obj_pos[p-1]]) * (rate1c? 5.0: rate2c? 4.0: rate3c? 3.0: rate4c? 2.0: 1.0) + 
         iClose(NULL,0,Bars-obj_bars[obj_pos[p-1]]) * (rate1c? 1.0: rate2c? 2.0: rate3c? 3.0: rate4c? 4.0: 5.0)) / 6.0;
   if (obj_liqTypes[pos] == "Error") CreateLabel0(obj_Levels[pos],Bars-obj_bars[pos],"- NO LIQUID LINE - "+IntegerToString(pos)+" *",0,0,0);    // && Op_HiLo
   if (obj_liqTypes[pos] == "Error-2") CreateLabel0(obj_Levels[pos],Bars-obj_bars[pos],"- 2 LIQUID LINES - "+IntegerToString(pos)+" *",0,0,0);  // && Op_HiLo
   t_clo = false;    j = 0;   while(! Time[j]) j ++;
   for (i=obj_bars[obj_pos[p-1]]+1; i <= Bars && ! t_clo; i ++) { obj_prClots[pos] = iClose(NULL,0,Bars-i);
/*Print("*** ",i," - ",p," - ",(Bars-i)," - ",pos," - ",obj_pos[p-2]," - ",obj_pos[p-1]," - ",obj_pos[p]," - ",obj_liqTypes[prv_pos]," - ",
   iOpen(NULL,0,Bars-i)," - ",iHigh(NULL,0,Bars-i)," - ",iLow(NULL,0,Bars-i)," - ",iClose(NULL,0,Bars-i)," - ",obj_prClots[pos]," - ",
((obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (obj_prClots[pos]-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) > 0.3 &&
         ((obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (iClose(NULL,0,Bars-i) - iOpen(NULL,0,Bars-i+1)) > 20 * Point ||
         ((obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (iClose(NULL,0,Bars-i+1) - iOpen(NULL,0,Bars-i+1))) > 20 * Point)),
         " - ",((obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (iClose(NULL,0,Bars-i) - iOpen(NULL,0,Bars-i+1)) > 20 * Point ||
            ((obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (iClose(NULL,0,Bars-i+1) - iOpen(NULL,0,Bars-i+1))) > 20 * Point),
         " - ",(obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (obj_prClots[pos]-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)),
         " - ",(obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (iClose(NULL,0,Bars-i) - iOpen(NULL,0,Bars-i+1)),
         " - ",((obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (iClose(NULL,0,Bars-i+1) - iOpen(NULL,0,Bars-i+1)))," ***"); */
//      haBull = HA_Bull(iOpen(NULL,0,Bars-i+2), iClose(NULL,0,Bars-i+2), iOpen(NULL,0,Bars-i+1), iClose(NULL,0,Bars-i+1), 
//         iHigh(NULL,0,Bars-i+1), iLow(NULL,0,Bars-i+1), iOpen(NULL,0,Bars-i), iClose(NULL,0,Bars-i), iHigh(NULL,0,Bars-i), iLow(NULL,0,Bars-i));
      t_clo = f_mqh_code(3, pos, prv_pos, i, obj_liqTypes[prv_pos], obj_prClots[pos], 0, 0);                                                       // * MQH *
      if (ea_show && t_clo) { //&& (!prv_pos || (obj_liqTypes[prv_pos]=="Buy" && obj_liqTypes[prv_pos]=="Sell") || (obj_liqTypes[prv_pos]=="Buy" && obj_liqTypes[prv_pos]=="Sell"))) {
         DrawArrow_pf(obj_prClots[pos], Bars-i, 3, !bull, 1);         DrawArrow_pf(obj_prClots[pos], Bars-i, 5, !bull, 1); }       // 1er niveau de sortie en bleu
      if (t_clo) blue_time = Time[Bars-i+j];                      if (t_clo && i == Bars-j) { //t_blue = false;
         if (t_blue) Print("** -> DrawArrow_OS *1 ",bull_," ",bull," ",t_clo_," ",t_clo," ",ticket," ",Bid," ",Ask," ",i," ",j," ",Bars," ",(Bars-j-i)," ",TimeToStr(Time[Bars-j-i],
            TIME_MINUTES)," ",TimeToStr(Time[j],TIME_MINUTES)," | ",pos," ",obj_prClots[pos]," ",vScale," **");   t_blue = false;   blue_time2 = Time[j]; }
      if ((t_clo_ || t_clo) && i == Bars-j-1 && ticket && blue_time2 == Time[Bars-j-i]) { //t_clo_ = false;      t_clo = false;
         if (cpt == 1) { DrawArrow_pf(bull? Bid: Ask, j, 2, !bull, 1);        DrawArrow_pf(bull? Bid: Ask, j, 6, !bull, 1);      total2_ = total2;
//            total2 += (prv_pos ? (obj_liqTypes[prv_pos] == "Buy" ? -1 : (obj_liqTypes[prv_pos] == "Sell" ? 1 : 0)) * (obj_Prices[pos] - obj_prClots[pos]) / Point -
//               (obj_liqTypes[prv_pos] == "Buy" || obj_liqTypes[prv_pos] == "Sell" ? 1 : 0) * comm : 0);
            total2 += total3 - total3_; }                                           // total2 à revoir dans cette partie    ***
         Print("** -> DrawArrow_OS 1* ",bull_," ",bull," ",t_clo_," ",t_clo," ",ticket," ",Bid," ",Ask," ",i," ",j," ",Bars," ",(Bars-j-i)," ",TimeToStr(Time[Bars-j-i],TIME_MINUTES)," ",
            TimeToStr(Time[j],TIME_MINUTES)," | ",pos," ",obj_prClots[pos]," ",vScale," | ",(tmp=AccountBalance())," **");      t_clo_ = false;      t_clo = false;    t_blue = true;
         DrawArrow_OS(1, obj_prClots[pos]+(bull? 150*vScale*Point: 625*vScale*Point), Bars-i, 0, bull, ticket);      // 250
         Print("** --> total = ",total,", total2 = ",total2," (",DoubleToStr(obj_Prices[pos],5)," - ",DoubleToStr(obj_prClots[pos],5)," - ",TimeToStr(Time[Bars-obj_bars[obj_pos[p-1]]],
            TIME_MINUTES)," - ",TimeToStr(Time[Bars-i],TIME_MINUTES)," - ",DoubleToStr(Bid,5)," - ",DoubleToStr(Ask,5),"), total2_ = ",total2_," (",(total2-total2_),") ...");
         Print("** --> suite total3 = ",total3," (",OrderProfit()," - ",OrderSwap()," - ",OrderCommission()," - ",DoubleToStr(OrderOpenPrice(),5)," - ",DoubleToStr(OrderClosePrice(),5),
            " - ",TimeToStr(OrderOpenTime(),TIME_MINUTES)," - ",TimeToStr(OrderCloseTime(),TIME_MINUTES),", p_Coef: ",p_Coef,", ",(OrderProfit()*p_Coef)," ",(OrderSwap()*p_Coef)," ",
            (OrderCommission()*p_Coef),") ...");                    Print("** --> suite total3_ = ",total3_," (",(total3-total3_)," - ",(AccountBalance()-tmp),") | ",
            tmp," - ",AccountBalance()," - ",AccBalance," -",(AccountBalance()-AccBalance)>-0.015?" ok":"> BALANCE"," | (",ntot,") ",pos," - ",DoubleToStr(obj_Prices[pos],5)," - ",
            DoubleToStr(obj_prClots[pos],5)," | ticket = ",ticket," **"); }
      else if (i==Bars-j-1 && t_clo_ && ticket && blue_time2 == Time[Bars-j-i]) 
         Print("** -> DrawArrow_OS 1 Error: ",t_clo_," ",t_clo," ",ticket," ",Bid," ",Ask," ",i," ",(Bars-i)," | ",pos," ",obj_prClots[pos]," ***");
      else if (i == Bars-j-1 && blue_time2 == Time[Bars-j-i]) t_blue = true;
      t_clo_ = (i == Bars-j-1 && t_clo_ ? t_clo_ : (i == Bars-j && t_clo));
      if (ea_show && !(iHigh(NULL,0,Bars-i) - iLow(NULL,0,Bars-i))) CreateLabel0_pf(iOpen(NULL,0,Bars-i),Bars-i,"- HIGH() = LOW() - "+DoubleToStr(iOpen(NULL,0,  // && Op_HiLo
      Bars-i),4)+" - "+DoubleToStr(iHigh(NULL,0,Bars-i),4)+" - "+DoubleToStr(iLow(NULL,0,Bars-i),4)+" - "+DoubleToStr(iClose(NULL,0,Bars-i),4)+" *",0,0,0); }
   if ((obj_liqTypes[prv_pos]=="Buy" && obj_liqTyp_2 == "Sell") || (obj_liqTyp_2 == "Buy" && obj_liqTypes[prv_pos]=="Sell")) obj_bar_cl = Bars-i+(t_clo?1:0);
   if (! t_clo) { i --;       obj_prClots[pos] = (iOpen(NULL,0,Bars-i) * (rate1c? 5.0: rate2c? 4.0: rate3c? 3.0: rate4c? 2.0: 1.0) +
         iClose(NULL,0,Bars-i) * (rate1c? 1.0: rate2c? 2.0: rate3c? 3.0: rate4c? 4.0: 5.0)) / 6.0; }        ntot = 1;
   total += (prv_pos ? (obj_liqTypes[prv_pos] == "Buy" ? -1 : (obj_liqTypes[prv_pos] == "Sell" ? 1 : 0)) *     // && obj_Prices[pos]>0 && obj_prClots[pos]>0
         (obj_Prices[pos] - obj_prClots[pos]) / Point - (obj_liqTypes[prv_pos] == "Buy" || obj_liqTypes[prv_pos] == "Sell" ? 1 : 0) * comm : 0);
   if (((t_clo_ || t_clo) && i == Bars-j && ticket && blue_time2 == Time[Bars-j-i+1]) || pass1) Print("** --> (1a) total = ",total,", total2 = ",total2,
         ", total2_ = ",total2_,", total3 = ",total3,", total3_ = ",total3_,", ticket = ",ticket," **");
//Print("*** ",i," - ",p," - ",(Bars-i)," - ",pos," - ",obj_pos[p-2]," - ",obj_pos[p-1]," - ",obj_pos[p]," - ",obj_liqTypes[prv_pos]," - ",obj_Prices[pos]," - ",obj_prClots[pos]," - ",total," ***");
   if (! ((obj_liqTypes[prv_pos]=="Buy" && obj_liqTyp_2=="Sell") || (obj_liqTyp_2=="Buy" && obj_liqTypes[prv_pos]=="Sell"))) { temp = "final";
      // dans ce bloc la logique d'apparition des flèches est différente par rapport au précédent (-> prv_pos)
      if (ea_show) { DrawArrow_pf(obj_Prices[pos], Bars-obj_bars[obj_pos[p-1]], 3, bull, 0);    DrawArrow_pf(obj_Prices[pos], Bars-obj_bars[obj_pos[p-1]], 5, bull, 0); }
      if (obj_bar_cl >= Bars-obj_bars[obj_pos[p-1]]) { ntot = 2;
         total += (obj_liqTypes[prv_pos] == "Buy" ? -1 : (obj_liqTypes[prv_pos] == "Sell" ? 1 : 0)) * (obj_Prices[pos] - obj_prClots[pos]) / Point - comm;
         if (pass1) Print("** --> (1b) total = ",total,", total2 = ",total2,", total2_ = ",total2_,", total3 = ",total3,", total3_ = ",total3_,", ticket = ",ticket," **");
         if (obj_bars[obj_pos[p-1]] >= Bars-1 && ! ticket) { total2_ = total2;
            DrawArrow_pf(bull? Ask: Bid, Bars-obj_bars[obj_pos[p-1]], 2, bull, 0);     DrawArrow_pf(bull? Ask: Bid, Bars-obj_bars[obj_pos[p-1]], 6, bull, 0);
            total2 += (obj_liqTypes[prv_pos] == "Buy" ? -1 : (obj_liqTypes[prv_pos] == "Sell" ? 1 : 0)) * (obj_Prices[pos] - obj_prClots[pos]) / Point - comm;
            Print("** -> DrawArrow_OS 2 ",bull_," ",bull," ",ticket," ",Bid," ",Ask," ",p," ",obj_pos[p-1]," ",obj_bars[obj_pos[p-1]]," | ",pos," ",obj_Prices[pos]," ",vScale," **");
            DrawArrow_OS(2, obj_Prices[pos]+(bull? 250*vScale*Point: 625*vScale*Point), Bars-obj_bars[obj_pos[p-1]], 0, bull, 0);
            Print("** --> total = ",total,", total2 = ",total2," (",obj_Prices[pos]," - ",obj_prClots[pos],"), total2_ = ",total2_,", total3 = ",total3," (",OrderProfit()," - ",
               OrderSwap()," - ",OrderCommission()," - ",DoubleToStr(OrderOpenPrice(),5)," - ",DoubleToStr(OrderClosePrice(),5),"), total3_ = ",total3_,", ticket = ",ticket," **"); } }
      if (ea_show && Op_Show) { name = ObjectName(prv_pos);
         nam_B = StringSubstr(name, 0, (StringSubstr(name,5,1)==2?13:8))+"liquid_buy"+StringSubstr(name, StringFind(name, "tral")+4);
         nam_S = StringSubstr(name, 0, (StringSubstr(name,5,1)==2?13:8))+"liquid_sell"+StringSubstr(name, StringFind(name, "tral")+4);
         obj_Levels[prv_pos] = (ObjectGet((obj_liqTypes[prv_pos]=="Buy"?nam_B:nam_S),OBJPROP_PRICE1)+ObjectGet(name,OBJPROP_PRICE1))/2.0;
         CreateLabel_pf(obj_Levels[prv_pos],Bars-obj_bars[obj_pos[p-1]],obj_pos[p-1],bull,"  total: "+DoubleToStr(total,0)+" ("+temp+") "+
               IntegerToString(Bars-obj_bars[obj_pos[p-1]])+" "+IntegerToString(obj_bar_cl),1,2); } }
   if (hightotal < total) hightotal = total;    else if (hightotal && drawdown > total-hightotal) { drawdown = total - hightotal;    drawdwnp = (drawdown*1.0/hightotal*1.0)*100.0; }
   if (t_clo) { //CreateLabel0_pf(iOpen(NULL,0,Bars-obj_bars[obj_pos0[p+1]]),Bars-obj_bars[obj_pos0[p+1]],"- test reOps - "+IntegerToString(pos)+" *",0,0,0);     // -> (0 && *(1)*
      if (ea_show && ! ((obj_liqTypes[prv_pos]=="Buy" && obj_liqTyp_2=="Sell") || (obj_liqTyp_2=="Buy" && obj_liqTypes[prv_pos]=="Sell")) && Op_Show) 
         CreateLabel0_pf(iOpen(NULL,0,Bars-obj_bars[obj_pos0[p]]),Bars-obj_bars[obj_pos0[p]],"- test reOps - "+IntegerToString(prv_pos)+"*"+
            IntegerToString(obj_pos0[p-1])+"*"+IntegerToString(obj_pos0[p])+"*"+IntegerToString(obj_pos[p-1])+"-"+IntegerToString(obj_pos[p])+" *",0,0,0);
      t_opn=false;      while (i <= (obj_pos0[p]?obj_bars[obj_pos0[p]]:Bars)) { reOpn_prs[k] = 0.0;   reClo_prs[k] = 0.0;
       t_clo=false;     for (i=i; i <= (obj_pos0[p]?obj_bars[obj_pos0[p]]:Bars) && ! t_clo; i ++) { reOpn_prs[k] = iClose(NULL,0,Bars-i);   reOpn_brs[k] = i;
//         haBull = HA_Bull(iOpen(NULL,0,Bars-i+2), iClose(NULL,0,Bars-i+2), iOpen(NULL,0,Bars-i+1), iClose(NULL,0,Bars-i+1), 
//            iHigh(NULL,0,Bars-i+1), iLow(NULL,0,Bars-i+1), iOpen(NULL,0,Bars-i), iClose(NULL,0,Bars-i), iHigh(NULL,0,Bars-i), iLow(NULL,0,Bars-i));
         t_clo = f_mqh_code(4, pos, prv_pos, i, obj_liqTypes[prv_pos], 0, reOpn_prs[k], 0); }      // boucle des reOps Label_Arrow_Test(Type= 1,      // * MQH *
       if (t_clo) { //if (t_clo2 < 13) { t_clo2 ++;   Label_Arrow_Test(1,prv_pos,p,i,k,reOpn_prs[k],!bull,pX,pY,total,obj_pos0,obj_pos);   pY += 34; }
         if (ea_show) { DrawArrowInt_pf(iClose(NULL,0,Bars-i+1), Bars-i+1, 3, true);         DrawArrowInt_pf(iClose(NULL,0,Bars-i+1), Bars-i+1, 5, true); }
/*         if (i >= Bars-1 && ! ticket) { DrawArrowInt_pf(bull? Bid: Ask, Bars-i+1, 2, true);        DrawArrowInt_pf(bull? Bid: Ask, Bars-i+1, 6, true);
            Print("** -> DrawArrow_OS 3 ",bull_," ",bull," ",ticket," ",Bid," ",Ask," ",i," ",(Bars-i+1)," | ",pos," ",iClose(NULL,0,Bars-i+1)," ",vScale," **");
            DrawArrow_OS(3, iClose(NULL,0,Bars-i+1)+(bull? 250*vScale*Point: 625*vScale*Point), Bars-i+1, 0, bull, 0); }   */
         orge_time = Time[Bars-i+j];                      if (i == Bars-j+1) { //t_orge = false;
            if (t_orge) Print("** -> DrawArrow_OS *3 ",bull_," ",bull," ",t_clo," ",ticket," ",Bid," ",Ask," ",i," ",j," ",Bars," ",(Bars-j-i+1)," ",TimeToStr(Time[Bars-j-i+1],
               TIME_MINUTES)," ",TimeToStr(Time[j],TIME_MINUTES)," | ",pos," ",obj_prClots[pos]," ",vScale," **");   t_orge = false;   orge_time2 = Time[j]; }
         if (i == Bars-j && ! ticket && orge_time2 == Time[Bars-j-i+1]) {
            DrawArrowInt_pf(bull? Ask: Bid, j, 2, true);           DrawArrowInt_pf(bull? Ask: Bid, j, 6, true);
            Print("** -> DrawArrow_OS 3* ",bull_," ",bull," ",t_clo," ",ticket," ",Bid," ",Ask," ",i," ",j," ",Bars," ",(Bars-j-i+1)," ",TimeToStr(Time[Bars-j-i+1],
               TIME_MINUTES)," ",TimeToStr(Time[j],TIME_MINUTES)," | ",pos," ",obj_prClots[pos]," ",vScale," **");      t_clo = false;    t_orge = true;
            if (! DrawArrow_OS(3, iClose(NULL,0,Bars-i+1)+(bull? 250*vScale*Point: 625*vScale*Point), j+1, 0, bull, 0))
                  Print("*** DrawArrow_OS 3 Error: ",GetLastError()," ***");
            else Print("** --> total = ",total,", total2 = ",total2,", total2_ = ",total2_,", total3 = ",total3,", total3_ = ",total3_,", ticket = ",ticket," **"); }
         else if (i == Bars-j && orge_time2 == Time[Bars-j-i+1]) t_orge = true;
         t_clo = false;   t_opn = true;                                                      // boucle de recherche des reCls Label_Arrow_Test(Type= 2,
         for (i=i; i <= Bars && ! t_clo; i ++) { reClo_prs[k] = iClose(NULL,0,Bars-i);       reClo_brs[k] = i;
//            haBull = HA_Bull(iOpen(NULL,0,Bars-i+2), iClose(NULL,0,Bars-i+2), iOpen(NULL,0,Bars-i+1), iClose(NULL,0,Bars-i+1), 
//               iHigh(NULL,0,Bars-i+1), iLow(NULL,0,Bars-i+1), iOpen(NULL,0,Bars-i), iClose(NULL,0,Bars-i), iHigh(NULL,0,Bars-i), iLow(NULL,0,Bars-i));
            t_clo = f_mqh_code(5, pos, prv_pos, i, obj_liqTypes[prv_pos], 0, 0, reClo_prs[k]); }                                                   // * MQH *
         if (ea_show && t_clo) { //&& t_clo3 < 13) { t_clo3 ++;    Label_Arrow_Test(2,prv_pos,p,i,k,reClo_prs[k],bull,pX,pY,total,obj_pos0,obj_pos);     pY += 34; }
            DrawArrowInt_pf(iClose(NULL,0,Bars-i+1), Bars-i+1, 3, false);        DrawArrowInt_pf(iClose(NULL,0,Bars-i+1), Bars-i+1, 5, false); }
/*         if (t_clo && i == Bars-1 && ticket) { DrawArrowInt_pf(bull? Bid: Ask, Bars-i+1, 2, false);      DrawArrowInt_pf(bull? Bid: Ask, Bars-i+1, 6, false);
            Print("** -> DrawArrow_OS 4 ",bull_," ",bull," ",ticket," ",Bid," ",Ask," ",i," ",(Bars-i+1)," | ",pos," ",iClose(NULL,0,Bars-i+1)," ",vScale," **");
            DrawArrow_OS(4, iClose(NULL,0,Bars-i+1)+(bull? 250*vScale*Point: 625*vScale*Point), Bars-i+1, 0, bull, 1); }   //ticket */
         if (t_clo) vilt_time = Time[Bars-i+j];                      if (t_clo && i == Bars-j+1) { //t_vilt = false;
            if (t_vilt) Print("** -> DrawArrow_OS *4 ",bull_," ",bull," ",t_clo," ",ticket," ",Bid," ",Ask," ",i," ",j," ",Bars," ",(Bars-j-i+1)," ",TimeToStr(Time[Bars-j-i+1],
               TIME_MINUTES)," ",TimeToStr(Time[j],TIME_MINUTES)," | ",pos," ",obj_prClots[pos]," ",vScale," **");   t_vilt = false;   vilt_time2 = Time[j]; }
         if (t_clo && i == Bars-j && ticket && vilt_time2 == Time[Bars-j-i+1]) {
            if (cpt == 1) { DrawArrowInt_pf(bull? Bid: Ask, j, 2, false);        DrawArrowInt_pf(bull? Bid: Ask, j, 6, false);      total2_ = total2;
               total2 += (obj_liqTypes[prv_pos] == "Buy" ? -1 : (obj_liqTypes[prv_pos] == "Sell" ? 1 : 0)) * (reOpn_prs[k] - reClo_prs[k]) / Point - 
                  (obj_liqTypes[prv_pos] == "Buy" || obj_liqTypes[prv_pos] == "Sell" ? 1 : 0) * comm; }
            Print("** -> DrawArrow_OS 4* ",bull_," ",bull," ",t_clo," ",ticket," ",Bid," ",Ask," ",i," ",j," ",Bars," ",(Bars-j-i+1)," ",TimeToStr(Time[Bars-j-i+1],
            TIME_MINUTES)," ",TimeToStr(Time[j],TIME_MINUTES)," | ",pos," ",obj_prClots[pos]," ",vScale," | ",(tmp=AccountBalance())," **");   t_clo = false;   t_vilt = true;
            if (! DrawArrow_OS(4, iClose(NULL,0,Bars-i+1)+(bull? 150*vScale*Point: 625*vScale*Point), j+1, 0, bull, ticket))     // 250
                  Print("*** DrawArrow_OS 4 Error: ",GetLastError()," ***");
            else { Print("** --> total = ",total,", total2 = ",total2," (",DoubleToStr(reOpn_prs[k],5)," - ",DoubleToStr(reClo_prs[k],5)," - ",TimeToStr(Time[Bars-reOpn_brs[k]],
            TIME_MINUTES)," - ",TimeToStr(Time[Bars-reClo_brs[k]],TIME_MINUTES)," - ",DoubleToStr(Bid,5)," - ",DoubleToStr(Ask,5),"), total2_ = ",total2_," (",(total2-total2_),") ...");
            Print("** --> suite total3 = ",total3," (",OrderProfit()," - ",OrderSwap()," - ",OrderCommission()," - ",DoubleToStr(OrderOpenPrice(),5)," - ",DoubleToStr(OrderClosePrice(),5),
               " - ",TimeToStr(OrderOpenTime(),TIME_MINUTES)," - ",TimeToStr(OrderCloseTime(),TIME_MINUTES),", p_Coef: ",p_Coef,", ",(OrderProfit()*p_Coef)," ",(OrderSwap()*p_Coef)," ",
               (OrderCommission()*p_Coef),") ...");                    Print("** --> suite total3_ = ",total3_," (",(total3-total3_)," ",(AccountBalance()-tmp),") | ",
               tmp," - ",AccountBalance()," - ",AccBalance," -",(AccountBalance()-AccBalance)>-0.015?" ok":"> BALANCE"," | (",ntot,") ",pos," - ",DoubleToStr(obj_Prices[pos],5)," - ",
               DoubleToStr(obj_prClots[pos],5)," | ticket = ",ticket," **"); } }
         else if (i == Bars-j && vilt_time2 == Time[Bars-j-i+1]) t_vilt = true;
         if (! t_clo) reClo_prs[k] = (obj_liqTypes[prv_pos]=="Buy" ? Bid : Ask); }     k ++; }                      // fin de boucle While **
      obj_reOps[pos][0] = obj_reOps[obj_pos[p-2]][1];      obj_reOps[pos][1] = k - 1;
      if (! obj_reOps[pos][0] && prv_pos) obj_reOps[pos][0] = k_ - 1;
      if (t_opn) { tst1 = (obj_liqTypes[prv_pos] == "Buy");// && (! prv_pos || obj_liqTypes[prv_pos] == "Sell"));     // -> (0 && *(1)*
         tst2 = (obj_liqTypes[prv_pos] == "Sell");  //(! prv_pos || obj_liqTypes[prv_pos] == "Buy") && 
         for (l = obj_reOps[pos][0]+1; l <= obj_reOps[pos][1]; l ++) if (reClo_prs[l]) {   // ou  && reClo_prs[l]
            total += (tst1 ? -1 : (tst2 ? 1 : 0)) * (reOpn_prs[l] - reClo_prs[l]) / Point - (tst1 || tst2 ? 1 : 0) * comm;    ntot = 3;
            if (pass1) Print("** --> (1c) total = ",total,", total2 = ",total2,", total2_ = ",total2_,", total3 = ",total3,", total3_ = ",total3_,
                  ", ticket = ",ticket," **");                                                                       if (ea_show && Op_Show)
            CreateLabel_pf(reClo_prs[l],Bars-reClo_brs[l],pos,!bull,"   px:"+DoubleToStr(reClo_prs[l],5)+" tot: "+DoubleToStr(total,0)+" - "+IntegerToString(pos)+" - "+IntegerToString(l),0,1); } }
//         if (obj_reOps[pos][0]+1 <= obj_reOps[pos][1]) Print("** --> (2) total = ",total,", total2 = ",total2,", total3 = ",total3,", total3_ = ",total3_,", ticket = ",ticket," **"); }
      if (total - hightotal < drawdown / 4 * 3 && Op_DDw) Print ("(2) ", pos," object "," | ",prv_pos," - ",obj_Prices[prv_pos]," - total : ",total," - hightotal : ",
         hightotal," - drawdown : ",drawdown," - ",drawdwnp?DoubleToStr(drawdwnp,1):"-.-"," % - ",obj_reOps[pos][0]," - ",obj_reOps[pos][1]," - t_clo/bleu : ",
         TimeToStr(Time[obj_bar_cl],TIME_DATE|TIME_MINUTES)," *");
      if (hightotal < total) hightotal = total;    else if (drawdown > total - hightotal) { drawdown = total - hightotal;
            if (hightotal) drawdwnp = (drawdown*1.0 / hightotal*1.0) * 100.0; } }
//   Print (pos, " object ", ObjectName(pos), " | ", prv_pos, " - ", obj_Prices[prv_pos], " - total : ", total, " *");
/* -------------------------------------------------------------------------------------------------------------------------------- */

  if (WM != WindowPriceMax()) ObjectsPositions(vScale);
//  if (bull != bull_) Print("*** -> bull CHANGED! ",ticket," - ",bull_," - ",bull," ***");
  int tmfr=Period();  string stmfr= tmfr==PERIOD_M1? "M1": tmfr==PERIOD_M5? "M5": tmfr==PERIOD_M15? "M15": tmfr==PERIOD_M30? "M30": 
      tmfr==PERIOD_H1? "H1": tmfr==PERIOD_H4? "H4": tmfr==PERIOD_D1? "D1": tmfr==PERIOD_W1? "W1": "MN1";
  if (ObjectType("EA_Check-"+stmfr+"-1_0 "+IntegerToString(Time[0])) > 0) {}
//      Print("** -> DrawArrow_chk EXISTS! EA_Check1_0 "+IntegerToString(Time[0])+" **");
  else if (! DrawArrow_chk(WindowPriceMax()-50*vScale*Point,0,1)) Print("*** DrawArrow_chk Error (1): ",GetLastError()," ***");
  if (obj_bars[prv_pos] >= Bars-1 && (!ticket || (bull_==NULL && bull_!=false) || ((bull && ! bull_) || (! bull && bull_)))) {
      if (ObjectType("EA_Check-"+stmfr+"-2_0 "+IntegerToString(Time[0])) > 0) {}
//         Print("** -> DrawArrow_chk EXISTS! EA_Check2_0 "+IntegerToString(Time[0])+" **");
      else if (! DrawArrow_chk(WindowPriceMax()-310*vScale*Point,0,2)) Print("*** DrawArrow_chk Error (2): ",GetLastError()," ***");   //iClose(NULL,0,0)
      if (Bars != obj_bars[obj_pos[p-1]]) tmp = obj_Prices[prv_pos];    else tmp = (iOpen(NULL,0,Bars-obj_bars[obj_pos[p-2]]) * (rate1c? 5.0: rate2c? 4.0: 
         rate3c? 3.0: rate4c? 2.0: 1.0) + iClose(NULL,0,Bars-obj_bars[obj_pos[p-2]]) * (rate1c? 1.0: rate2c? 2.0: rate3c? 3.0: rate4c? 4.0: 5.0)) / 6.0;
      total2_ = total2;   /* total2 += (prv_pos? (obj_liqTypes[prv_pos]=="Sell"? 1: obj_liqTypes[prv_pos]=="Buy"? -1: 0): 0) * (tmp - (bull? Bid: Ask))/Point
         - (obj_liqTypes[prv_pos] == "Buy" || obj_liqTypes[prv_pos] == "Sell" ? 1 : 0) * comm;  */    // total2 à revoir dans cette partie    ***
      Print("** -> DrawArrow_OS 5 ",(obj_bars[prv_pos] >= Bars-1 && (!ticket || bull_==NULL || (bull && ! bull_) || (! bull && bull_)))," ",
         (obj_bars[prv_pos] >= Bars-1)," ",(!ticket || bull_==NULL || (bull && ! bull_) || (! bull && bull_))," ",bull_," ",bull," ",
         ticket," ",Bid," ",Ask," ",prv_pos," ",obj_bars[prv_pos]," ",(Bars-obj_bars[prv_pos])," ",TimeToStr(Time[Bars-obj_bars[prv_pos]],
         TIME_MINUTES)," | ",pos," ",iClose(NULL,0,Bars-i+1)," ",vScale," | ",(tmp2=AccountBalance())," **"); //*/
      if (! DrawArrow_OS(5, obj_Levels[prv_pos]+(bull? 250*vScale*Point: 250*vScale*Point), Bars-obj_bars[prv_pos], 0, bull, 0)) 
            Print("*** DrawArrow_OS 5 Error: ",GetLastError()," ***");
//Print("** --> total = ",total,", total2 = ",total2,", total2_ = ",total2_,", total3 = ",total3,", total3_ = ",total3_,", ticket = ",ticket," **");     // ?
      else { total2 += total3 - total3_;              // total2 n'a pas d'intérêt dans cette partie
         Print("** --> total = ",total,", total2 = ",total2," (",DoubleToStr(tmp,5)," - ",DoubleToStr(iClose(NULL,0,0),5)," - ",TimeToStr(Time[Bars-obj_bars[obj_pos[p-
            (Bars!=obj_bars[obj_pos[p-1]]?1:2)]]],TIME_MINUTES)," - ",TimeToStr(Time[Bars-i+1],TIME_MINUTES)," | ",DoubleToStr(Bid,5)," - ",DoubleToStr(Ask,5),"), total2_ = ",
            total2_," (",(total2-total2_),") ...");
         Print("** --> suite total3 = ",total3," (",OrderProfit()," - ",OrderSwap()," - ",OrderCommission()," - ",DoubleToStr(OrderOpenPrice(),5)," - ",DoubleToStr(OrderClosePrice(),5),
            " - ",TimeToStr(OrderOpenTime(),TIME_MINUTES)," - ",TimeToStr(OrderCloseTime(),TIME_MINUTES),", p_Coef: ",p_Coef,", ",(OrderProfit()*p_Coef)," ",(OrderSwap()*p_Coef)," ",
            (OrderCommission()*p_Coef),") ...");                    Print("** --> suite total3_ = ",total3_," (",(total3-total3_)," ",(AccountBalance()-tmp2),") | ",
            tmp2," - ",AccountBalance()," - ",AccBalance," -",(AccountBalance()-AccBalance)>-0.015?" ok":"> BALANCE"," | ticket = ",ticket," ...");
         Print("** --> suite (",ntot,") ",pos," - ",DoubleToStr(obj_Prices[pos],5)," - ",DoubleToStr(obj_prClots[pos],5)," - ",prv_pos," - ",
            DoubleToStr(obj_Prices[prv_pos],5)," - ",DoubleToStr(obj_prClots[prv_pos],5)," **"); }
      if (! DrawArrow_end(bull? Ask: Bid, Bars-obj_bars[prv_pos], 2, bull, 0)) Print("*** DrawArrow_end Error(1): ",GetLastError()," ***");
      if (! DrawArrow_end(bull? Ask: Bid, Bars-obj_bars[prv_pos], 6, bull, 0)) Print("*** DrawArrow_end Error(2): ",GetLastError()," ***");
      this_Order_Time = TimeCurrent();    this_Order_Price = bull? Ask: Bid;     t_blue = true;     t_vilt = true;     t_orge = true;     bull_ = bull;
      GlobalVariableSet("th_O_P", this_Order_Price);     GlobalVariableSet("th_O_T", this_Order_Time);      GlobalVariableSet("th_O_B", bull); }
//  total += (prv_pos ? (obj_liqTypes[prv_pos] == "Sell" ? 1 : obj_liqTypes[prv_pos] == "Buy" ? -1 : 0) : 0) * (obj_Prices[prv_pos] - iClose(NULL,0,0)) / Point;
  DrawArrow(((bull=(obj_liqTypes[prv_pos]=="Sell")) ? obj_Levels[prv_pos]+100*vScale*Point : obj_Levels[prv_pos]+250*vScale*Point), Bars-obj_bars[prv_pos], 0, bull,0);
  if (ea_show) { DrawArrow(obj_Prices[prv_pos], Bars-obj_bars[prv_pos], 3, !bull,0);     DrawArrow(obj_Prices[prv_pos], Bars-obj_bars[prv_pos], 5, !bull,0);
     CreateLabel(obj_Levels[prv_pos],Bars-obj_bars[prv_pos],pos,!bull,"   px: "+DoubleToStr(obj_Prices[prv_pos],5)+" "+DoubleToStr(obj_prClots[pos],5),0,0); }
  ObjectDelete(LabelNameEnd);    CreateLabel_end(0,0,obj_total,!bull,"  total: "+DoubleToStr(total,0)+" ("+(ticket? endbull? "buy": "sell": "end")+")",0);
  if (exp_1 || exp_2) CreateLabel_end(0,0,exp_1+exp_2,NULL,"* exp_1: "+IntegerToString(exp_1)+" - exp_2: "+IntegerToString(exp_2)+" * ",1);
  if (hightotal < total) hightotal = total;  else if (hightotal && drawdown > total-hightotal) { drawdown = total-hightotal;  drawdwnp = (drawdown*1.0/hightotal*1.0)*100.0; }
//  Print (pos, " (1) object LAST | ", (ObjectType(StringSubstr(name,0,(StringSubstr(name,5,1)==2?13:8))+"liquid_buy"+StringSubstr(name, StringFind(name, "tral")+4)) 
//      > 0 ? "Sell" : (ObjectType(StringSubstr(name,0,(StringSubstr(name,5,1)==2?13:8))+"liquid_sell"+StringSubstr(name, StringFind(name,"tral")+4))>0? "Buy ": "Err ")), " ",
//      prv_pos, " - ", obj_Prices[prv_pos], " - ", iClose(NULL,0,0), " - ", iClose(NULL,0,0), " - ", pos, " - ", obj_pos[p+1], " - ", p, " - total : ", total, " *");

  GlobalVariableSet("total", total);
  GlobalVariableSet("total2", total2);
  GlobalVariableSet("total3", total3);
  GlobalVariableSet("AccBalance", AccBalance);
//  CreateLabel_end(0,0,0,0,"  WM: "+DoubleToStr(WM,5));
  pass1 = false;
  return;
}

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

void OnDeinit(const int reason) {
  GlobalVariableSet("Bullish", bull_);
  GlobalVariableSet("Ticket", ticket);
  Print("*** -> Ticket SAVED! ",ticket," ***");
//  if (reason == 3) ObjectsDelete(2);
  return;
}

bool DrawArrow_chk(double LinePrice,int BarNum,int I) { int tmfr=Period();
   string stmfr= tmfr==PERIOD_M1? "M1": tmfr==PERIOD_M5? "M5": tmfr==PERIOD_M15? "M15": tmfr==PERIOD_M30? "M30": 
      tmfr==PERIOD_H1? "H1": tmfr==PERIOD_H4? "H4": tmfr==PERIOD_D1? "D1": tmfr==PERIOD_W1? "W1": "MN1",
      ArrowName="EA_Check-"+stmfr+"-"+IntegerToString(I)+"_"+IntegerToString(BarNum)+" "+IntegerToString(Time[BarNum]);
   if (! ObjectCreate(ArrowName,OBJ_ARROW,0,Time[BarNum],LinePrice)) return false;
   ObjectSet(ArrowName, OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet(ArrowName, OBJPROP_ARROWCODE, 252);
   ObjectSet(ArrowName, OBJPROP_COLOR, I==1? ticket? clrGold: clrSilver: clrSkyBlue);
   ObjectSet(ArrowName, OBJPROP_SELECTABLE, 0);
   ObjectSet(ArrowName, OBJPROP_SELECTED, 0);
   ObjectSet(ArrowName, OBJPROP_WIDTH, 2);
//   ObjectSet(ArrowName, OBJPROP_YDISTANCE, 55);
   return true;
}

bool DrawArrow_OS(int Typ,double LinePrice,int BarNum,int Code,bool Bullish,int Clot) {
   Bullish = Clot? Bullish? false: true: Bullish;     int ticket_=ticket;
   string ArrowName = "EA_OS-"+IntegerToString(Typ)+(Typ==1||Typ==4?"-out":"-in")+"_Arr"+(Bullish? "-Up_": "-Down_")+   //&&!Clot)||(!Bullish&&Clot)
      IntegerToString(Code?Code:Bullish?241:242)+"-"+IntegerToString(BarNum)+"-"+IntegerToString(Clot)+" "+IntegerToString(TimeCurrent());
   if (cpt == 1 && ! ObjectCreate(ArrowName,OBJ_ARROW,0,Typ==1? blue_time: Time[BarNum],LinePrice)) return false;
   if (Typ==1) blue_time = 0;       if (Typ==3) orge_time = 0;       if (Typ==4) vilt_time = 0;    //: Typ==3? orge_time: Typ==4? vilt_time
   ObjectSet(ArrowName, OBJPROP_ARROWCODE, Bullish? SYMBOL_ARROWUP: SYMBOL_ARROWDOWN);
   ObjectSet(ArrowName, OBJPROP_COLOR, Typ==1? clrSkyBlue: Typ==3? clrOrange: Typ==4? clrViolet: 
                                                Bullish? Typ==2? clrMediumSpringGreen: clrLimeGreen: Typ==2? clrViolet: clrDeepPink);
   ObjectSet(ArrowName, OBJPROP_SELECTABLE, 0);
   ObjectSet(ArrowName, OBJPROP_SELECTED, 0);               //ticket = Clot? 0: ticket;
   ObjectSet(ArrowName, OBJPROP_WIDTH, Typ==2? 4: 5);       bool t_close=false, t_tick=ticket;
   if (AccBalance != AccountBalance()) AccBalance = AccountBalance();         p_Coef = 100.0;   // revoir avec pips2dbl et lot
   if ((Clot || ticket) && OrderSelect(floor(Clot? Clot: ticket), SELECT_BY_TICKET) && ! OrderCloseTime())
      while (! t_close) { t_close = OrderClose(floor(Clot? Clot: ticket), lot, Bullish? Bid: Ask, slip, clrNONE);
         if (t_close) { ticket = 0;                  total3_ = total3;
            Print("** -> OrderClose ",ticket_," ",OrderProfit()," - ",OrderSwap()," - ",OrderCommission()," - ",DoubleToStr(OrderOpenPrice(),5)," - ",
   DoubleToStr(OrderClosePrice(),5)," - ",DoubleToStr(Bid,5)," - ",DoubleToStr(Ask,5)," - ",TimeToStr(OrderCloseTime(),TIME_MINUTES)," - ",TimeToStr(TimeCurrent(),TIME_MINUTES)," **");
//            p_Coef = fabs(OrderClosePrice() - OrderOpenPrice() / OrderProfit()) / Point; //p_Coef (= 100 pour lot = 0.01)
            total3 += (OrderProfit() + OrderSwap() + OrderCommission()) * p_Coef;
            AccBalance += OrderProfit() + OrderSwap() + OrderCommission();
            if (AccountBalance() - AccBalance > -0.015) Print("** -> AccountBalance() - AccBalance! (1) ",(AccountBalance() - AccBalance)," ***");
            else  Print("** -> AccountBalance() - AccBalance! (2) ",(AccountBalance() - AccBalance)," - ",AccountBalance()," - ",AccBalance," (",
               OrderProfit()," - ",OrderSwap()," - ",OrderCommission()," - ",DoubleToStr(OrderOpenPrice(),5)," - ",DoubleToStr(OrderClosePrice(),5),") ***");
            if (AccBalance != AccountBalance()) { total3 += (AccountBalance() - AccBalance) * p_Coef;
               if (AccountBalance() - AccBalance > -0.015) AccBalance = AccountBalance(); } }
         else  Sleep(1000); }                             // v attention au spread en fin de marché -> ok si décalage favorable **
   if (ticket) { Print("** -> Ticket Select ERROR! (1) (cpt ",cpt,", typ ",Typ,") ",GetLastError(),", ticket ",ticket," ***");
      if (Clot && (ticket==1 || cpt==2)) { ticket = 0;   cpt = 1; }     else cpt ++; }
   else if (! Clot) { ticket = OrderSend(Symbol(), Bullish? ORDER_TYPE_BUY: ORDER_TYPE_SELL, lot, Bullish? Ask: Bid, slip, 0.0, 0.0, NULL);
      endbull = Bullish;  if (! t_tick) if (! OrderSelect(floor(Clot? Clot: ticket), SELECT_BY_TICKET) && ! OrderCloseTime())
            Print("** -> Ticket Select ERROR! (2) (cpt ",cpt,", typ ",Typ,") ",GetLastError(),", ticket ",ticket," ***"); }
/*         Print("** -> OrderSend ",ticket," ",OrderProfit()," - ",OrderSwap()," - ",OrderCommission()," - ",DoubleToStr(OrderOpenPrice(),5)," - ",
               DoubleToStr(OrderClosePrice(),5)," **"); } */
   if (ticket_ != ticket) Print("** --> Ticket CHANGED! (",Typ,") ",ticket_," ",ticket," - ",Bullish," **");
   GlobalVariableSet("Bullish", Bullish);          GlobalVariableSet("Ticket", ticket);
//int ticket = OrderSend(parts[10], (parts[11]=="SELL"?1:0), lot, (parts[11]=="SELL"?vBid:vAsk), 1, 0.0, 0.0, tmp2);
//   DrawArrow_OS(LinePrice, BarNum, Code, Bullish, Clot);  */
   return true;
}

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

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

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

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

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

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

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

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

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

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

void ObjectsPositions(double vScale) {
   int j=0,bar=WindowFirstVisibleBar(),obj_total=ObjectsTotal(),bars=WindowBarsPerChart(),tmfr=Period();       while(! Time[bar-bars+j]) j ++;
   string name, stmfr= tmfr==PERIOD_M1? "M1": tmfr==PERIOD_M5? "M5": tmfr==PERIOD_M15? "M15": tmfr==PERIOD_M30? "M30": 
      tmfr==PERIOD_H1? "H1": tmfr==PERIOD_H4? "H4": tmfr==PERIOD_D1? "D1": tmfr==PERIOD_W1? "W1": "MN1";
//   Print("** ---> ", WM, " ", WindowPriceMax(), " ", tmfr, " ", stmfr, " ", j, " ", bar, " ", bars, " ", TimeToStr(Time[bar],TIME_MINUTES), " ", TimeToStr(Time[bar-bars+j],TIME_MINUTES), " **");
   datetime OTime;      WM = WindowPriceMax();     for (int pos=0; pos < obj_total; pos ++) {
     name = ObjectName(pos);    OTime = ObjectGet(name,OBJPROP_TIME1);
/*     if (pos && (StringSubstr(name,0,8) == "EA_Check" || StringSubstr(name,0,8) == "EA_Test1" ||
        StringSubstr(name,0,8) == "EA_Test2") && Time[bar] <= OTime && Time[bar-bars+j] >= OTime)
   Print("** --> ",name," ",TimeToStr(OTime,TIME_MINUTES)," ",ObjectGet(name,OBJPROP_PRICE)," ",TimeToStr(ObjectGet(name,OBJPROP_TIME1),TIME_MINUTES)," ",ObjectGet(name,OBJPROP_PRICE1)," **");//*/
     if (pos && (StringSubstr(name,0,8) == "EA_Check" || StringSubstr(name,0,8) == "EA_Test1" || StringSubstr(name,0,8) == "EA_Test2")) //{
//   Print("**(1) -> ", name, " ", TimeToStr(OTime,TIME_MINUTES), " OBJPROP_COLOR: ", ColorToString(ObjectGet(name,OBJPROP_COLOR)), " **");
      if (Time[bar] <= OTime && Time[bar-bars+j]+Period()*60 >= OTime) {
         if (StringSubstr(name,9,StringFind(name,"-",StringFind(name,"-")+1)-9) != stmfr) {   // && stmfr!="M1"
            ObjectSet(name,OBJPROP_BACK,true);        ObjectSet(name,OBJPROP_PRICE1, WM + 1500 * vScale * Point);
            if (ObjectGet(name,OBJPROP_COLOR)) { ObjectSet(name,OBJPROP_ZORDER,ObjectGet(name,OBJPROP_COLOR));     ObjectSet(name,OBJPROP_COLOR,clrBlack); }
/*   Print("**(2a) -> ", name, " ", TimeToStr(OTime,TIME_MINUTES), " OBJPROP_COLOR: ", ColorToString(ObjectGet(name,OBJPROP_COLOR)), " OBJPROP_ZORDER: ", ObjectGet(name,OBJPROP_ZORDER), 
         " OBJPROP_PRICE1: ", ObjectGet(name,OBJPROP_PRICE1), " OBJPROP_BACK: ", ObjectGet(name,OBJPROP_BACK), " **");*/ }
         else { ObjectSet(name,OBJPROP_BACK,false);      ObjectSet(name,OBJPROP_PRICE1, WM - (StringSubstr(name,StringSubstr(name,0,7) == "EA_Test"? 7:
                    (StringSubstr(name,8,1)=="-"? StringFind(name,"-",StringFind(name,"-")+1)+1: 8),1) == "1"? 50: 310)*vScale*Point);
            if (ObjectGet(name,OBJPROP_ZORDER)) { ObjectSet(name,OBJPROP_COLOR,ObjectGet(name,OBJPROP_ZORDER));      ObjectSet(name,OBJPROP_ZORDER,0); }
/*   Print("**(2b) -> ", name, " ", TimeToStr(OTime,TIME_MINUTES), " OBJPROP_COLOR: ", ColorToString(ObjectGet(name,OBJPROP_COLOR)), " OBJPROP_ZORDER: ", ObjectGet(name,OBJPROP_ZORDER), 
         " OBJPROP_PRICE1: ", ObjectGet(name,OBJPROP_PRICE1), " OBJPROP_BACK: ", ObjectGet(name,OBJPROP_BACK), " **");*/ }
/*   Print("** -> ", name, " ", OTime, " ", ObjectGet(name,OBJPROP_PRICE1), " ", WM, " **");*/ } } //}
   return; }

void BrokerDigitAdjust(string symbol) {
 int Multiplier = 1;
 if (MarketInfo(symbol,MODE_DIGITS) == 3 || MarketInfo(symbol,MODE_DIGITS) == 5) Multiplier = 10;
 if (MarketInfo(symbol,MODE_DIGITS) == 6) Multiplier = 100;   
 if (MarketInfo(symbol,MODE_DIGITS) == 7) Multiplier = 1000;
 pips2dbl = Multiplier*MarketInfo(symbol,MODE_POINT); }
/* - partie finale ---------------------------------------------------------------------------------------------------------------- */

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

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

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

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

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

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

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

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