//#property strict
extern double lot = 0.01;  // Taille des lots
extern int slip = 5;       // Taille du slippage

// test v iOPen/(iHigh+iLow)/2
bool ea_show=false, Op_OHL=true, Op_Show=false, Op_DDw=false, Op_HiLo=false;
int frameX=20, frameY=35, ticket;     string bar_Dirs[],bar_Dir;
double bar_OPrs[],bar_OPts[],pips2dbl;

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");

  CreateButton(0,0,"<>",0,frameX-18,frameY+1,0);
  CreateButton(0,0,"Show-EA",0,frameX,frameY,0);
  return; }

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

  int obj_total=ObjectsTotal(), i,j,k=0,k_,p=0, obj_bar_cl,obj_bar_cl2,obj_bar_cl3,prv_pos=0,total=0,total0,hightotal=0,drawdown=0; //, type
  int obj_bars[], obj_pos[], obj_pos0[], obj_reOps[][2], reClo_brs[];   //, reOpn_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(reClo_brs, obj_total);      ArrayResize(obj_Neutrals, obj_total);  ArrayResize(obj_liqTypes, obj_total);
  ArrayResize(bar_Dirs, Bars);            ArrayResize(bar_OPrs, Bars);           string nam_B,nam_S;   bool bull_,bull,pos_prem=true;
  if (GlobalVariableCheck("Bullish")) bull_ = GlobalVariableGet("Bullish");

  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) * 5.0 + iClose(NULL,0,Bars-i)) / 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]," - ",obj_liqTypes[pos]," - ",obj_liqTyp_1," - barre : ",TimeToStr(Time[Bars-i],
                  TIME_DATE|TIME_MINUTES)," ***");               obj_liqTypes[pos] = obj_liqTyp_1; }
            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] == "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);
         t_clo = (iHigh(NULL,0,Bars-i) - iLow(NULL,0,Bars-i) > 0.0 &&
            ((obj_liqTypes[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[pos]=="Buy" ? -1 : 1) * (iClose(NULL,0,Bars-i) - iOpen(NULL,0,Bars-i+1)) > 20 * Point ||
            ((obj_liqTypes[pos]=="Buy" ? -1 : 1) * (iClose(NULL,0,Bars-i+1) - iOpen(NULL,0,Bars-i+1))) > 20 * Point)));
         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) * 6 : 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]? 6: 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))
            DrawArrowInt(obj_Levels[pos]+(bull ? 100*vScale*Point : 250*vScale*Point), Bars-obj_bars[pos], 0, bull);
         total0 = (total ? 0 : (obj_liqTypes[pos] == "Buy" ? -1 : (obj_liqTypes[pos] == "Sell" ? 1 : 0)) * (obj_Prices[pos] - obj_prClots[pos]) / Point - 6);     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
            t_clo = (iHigh(NULL,0,Bars-i) - iLow(NULL,0,Bars-i) > 0.0 &&                                // boucle des reOps Label_Arrow_Test(Type= 1,
               (((obj_liqTypes[pos]=="Buy" ? 1 : -1) * (reOpn_prs[k]-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) > 0.3 && 
               (!Op_OHL || (obj_liqTypes[pos]=="Buy"? -1: 1) * (iOpen(NULL,0,Bars-i) - (iHigh(NULL,0,Bars-i)+iLow(NULL,0,Bars-i)) / 2) > 20 * Point)) ||
               ((obj_liqTypes[pos]=="Buy" ? 1 : -1) * (reOpn_prs[k] - iOpen(NULL,0,Bars-i)) > 20 * Point && 
               (obj_liqTypes[pos]=="Buy" ? 1 : -1) * (iOpen(NULL,0,Bars-i) - (iHigh(NULL,0,Bars-i)+iLow(NULL,0,Bars-i)) / 2) > 20 * Point &&
               (obj_liqTypes[pos]=="Buy" ? 1 : -1) * (reOpn_prs[k]-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) < 0.3))); }
          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_pos[p+1]] && ! t_clo; i ++) { reClo_prs[k] = iClose(NULL,0,Bars-i);       reClo_brs[k] = i;
//               t_clo = ((obj_liqTypes[pos]=="Buy" ? -1 : 1) * (obj_prClots[pos]-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) > 0.3);
               t_clo = (iHigh(NULL,0,Bars-i) - iLow(NULL,0,Bars-i) > 0.0 &&
               (((obj_liqTypes[pos]=="Buy" ? -1 : 1) * (reClo_prs[k]-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) > 0.3 && 
               (!Op_OHL || (obj_liqTypes[pos]=="Buy"? -1: 1) * (iOpen(NULL,0,Bars-i) - (iHigh(NULL,0,Bars-i)+iLow(NULL,0,Bars-i)) / 2) > 20 * Point ||
               (obj_liqTypes[pos]=="Buy" ? -1 : 1) * (reClo_prs[k]-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) > 0.75)) ||
               ((obj_liqTypes[pos]=="Buy" ? -1 : 1) * (reClo_prs[k] - iOpen(NULL,0,Bars-i)) > 20 * Point && 
               (obj_liqTypes[pos]=="Buy" ? -1 : 1) * (iOpen(NULL,0,Bars-i) - (iHigh(NULL,0,Bars-i)+iLow(NULL,0,Bars-i)) / 2) > 20 * Point &&
               (obj_liqTypes[pos]=="Buy" ? -1 : 1) * (iOpen(NULL,0,Bars-i) - (iOpen(NULL,0,Bars-i+1)+iClose(NULL,0,Bars-i+1)) / 2) > 20 * Point &&
               (obj_liqTypes[pos]=="Buy" ? -1 : 1) * (reClo_prs[k]-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) < 0.3))); }
            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_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) * 6;       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 ---------------------------------------------------------------------------------------------------------------- */
   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]]) * 5.0 + iClose(NULL,0,Bars-obj_bars[obj_pos[p-1]])) / 6.0;
   t_clo=false;    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)))," ***"); */
      t_clo = (iHigh(NULL,0,Bars-i) - iLow(NULL,0,Bars-i) > 0.0 &&
         ((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)));
      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, 0, 1);         DrawArrow_pf(obj_prClots[pos], Bars-i, 5, 0, 1); }       // 1er niveau de sortie en bleu
      if (t_clo && i == Bars-1 && ticket) { DrawArrow_pf(bull? Bid: Ask, 0, 2, Bars-i, 1);
         Print("** -> DrawArrow_OS 1 ",bull_," ",bull," ",ticket," ",Bid," ",Ask," ",i," ",(Bars-i)," | ",pos," ",obj_prClots[pos]," ",vScale," **");
         DrawArrow_OS(1, obj_prClots[pos]+(bull? 250*vScale*Point: 625*vScale*Point), Bars-i, 0, bull, 1); }   //ticket
      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) * 5.0 + iClose(NULL,0,Bars-i)) / 6.0; }
   total += (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) * 6 : 0);
//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]]) {
         total += (obj_liqTypes[prv_pos] == "Buy" ? -1 : (obj_liqTypes[prv_pos] == "Sell" ? 1 : 0)) * (obj_Prices[pos] - obj_prClots[pos]) / Point - 6;
         if (obj_bars[obj_pos[p-1]] >= Bars-1 && !ticket) { DrawArrow_pf(bull? Bid: Ask, Bars-obj_bars[obj_pos[p-1]], 2, bull, 0);
            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); } }
      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);
         t_clo = (iHigh(NULL,0,Bars-i) - iLow(NULL,0,Bars-i) > 0.0 &&                                    // boucle des reOps Label_Arrow_Test(Type= 1,
            (((obj_liqTypes[prv_pos]=="Buy" ? 1 : -1) * (reOpn_prs[k]-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) > 0.3 && 
            (!Op_OHL || (obj_liqTypes[prv_pos]=="Buy"? -1: 1) * (iOpen(NULL,0,Bars-i) - (iHigh(NULL,0,Bars-i)+iLow(NULL,0,Bars-i)) / 2) > 20 * Point)) ||
            ((obj_liqTypes[prv_pos]=="Buy" ? 1 : -1) * (reOpn_prs[k] - iOpen(NULL,0,Bars-i)) > 20 * Point && 
            (obj_liqTypes[prv_pos]=="Buy" ? 1 : -1) * (iOpen(NULL,0,Bars-i) - (iHigh(NULL,0,Bars-i)+iLow(NULL,0,Bars-i)) / 2) > 20 * Point &&
            (obj_liqTypes[prv_pos]=="Buy" ? 1 : -1) * (reOpn_prs[k]-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) < 0.3))); }
       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);
            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); }
         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;
//            t_clo = ((obj_liqTypes[pos]=="Buy" ? -1 : 1) * (obj_prClots[pos]-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) > 0.3);
            t_clo = (iHigh(NULL,0,Bars-i) - iLow(NULL,0,Bars-i) > 0.0 &&
               (((obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (reClo_prs[k]-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) > 0.3 && 
               (!Op_OHL || (obj_liqTypes[prv_pos]=="Buy"? -1: 1) * (iOpen(NULL,0,Bars-i) - (iHigh(NULL,0,Bars-i)+iLow(NULL,0,Bars-i)) / 2) > 20 * Point ||
               (obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (reClo_prs[k]-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) > 0.75)) ||
               ((obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (reClo_prs[k] - iOpen(NULL,0,Bars-i)) > 20 * Point && 
               (obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (iOpen(NULL,0,Bars-i) - (iHigh(NULL,0,Bars-i)+iLow(NULL,0,Bars-i)) / 2) > 20 * Point &&
               (obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (iOpen(NULL,0,Bars-i) - (iOpen(NULL,0,Bars-i+1)+iClose(NULL,0,Bars-i+1)) / 2) > 20 * Point &&
               (obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (reClo_prs[k]-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) < 0.3))); }
         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);
            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) 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) * 6;       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 (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 (ObjectType("EA_Test1_"+IntegerToString(Bars-obj_bars[prv_pos])) > 0) {}
  else   DrawArrow_tst(WindowPriceMax()-250*Point,Bars-obj_bars[prv_pos],1); */
  if (obj_bars[prv_pos] >= Bars-1 && (!ticket || bull_==NULL || (bull=="Sell" && !bull_) || (bull=="Buy" && bull_))) {
/*      if (ObjectType("EA_Test2_"+IntegerToString(Bars-obj_bars[prv_pos])) > 0) {}
      else   DrawArrow_tst(WindowPriceMax()-300*Point,Bars-obj_bars[prv_pos],2);
    Print("** -> DrawArrow_OS 5 ",(obj_bars[prv_pos] >= Bars-1 && (!ticket || bull_==NULL || (bull=="Sell" && !bull_) || (bull=="Buy" && bull_)))," ",
    (obj_bars[prv_pos] >= Bars-1)," ",(!ticket || bull_==NULL || (bull=="Sell" && !bull_) || (bull=="Buy" && bull_))," ",bull_," ",bull," ",
    ticket," ",Bid," ",Ask," ",prv_pos," ",obj_bars[prv_pos]," ",(Bars-obj_bars[prv_pos])," | ",pos," ",iClose(NULL,0,Bars-i+1)," ",vScale," **"); //*/
      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 Error: ",GetLastError()," ***");
      if (! DrawArrow_end(bull? Bid: Ask, Bars-obj_bars[prv_pos], 2, bull, 0))
{}/*         Print("*** DrawArrow_end Error: ",GetLastError()," ***"); */            GlobalVariableSet("Bullish", bull == "Sell"? 1: 0); }
//  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);
     CreateLabel_end(0,0,obj_total,!bull,"  total: "+DoubleToStr(total,0)+" (end)"); }
  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, " *");

  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 DrawArrow_tst(double LinePrice,int BarNum,int I) {
   string ArrowName = "EA_Test"+IntegerToString(I)+"_"+IntegerToString(BarNum)+" "+IntegerToString(TimeCurrent());
   ObjectCreate(ArrowName,OBJ_ARROW,0,Time[BarNum],LinePrice);
   ObjectSet(ArrowName, OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet(ArrowName, OBJPROP_ARROWCODE, 2);
   ObjectSet(ArrowName, OBJPROP_COLOR, I==1? clrOrange: clrGold);
   ObjectSet(ArrowName, OBJPROP_SELECTABLE, 0);
   ObjectSet(ArrowName, OBJPROP_SELECTED, 0);
   ObjectSet(ArrowName, OBJPROP_WIDTH, 5);
}

bool DrawArrow_OS(int Typ,double LinePrice,int BarNum,int Code,bool Bullish,int Clot) {
   Bullish = Clot? Bullish? false: true: Bullish;
   string ArrowName = "EA_OS-"+IntegerToString(Typ)+(Typ==1||Typ==4?"-out":"-in")+"_Arr"+(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, Bullish? SYMBOL_ARROWUP: SYMBOL_ARROWDOWN);
   ObjectSet(ArrowName, OBJPROP_COLOR, Clot? clrSkyBlue: Bullish? clrLime: clrDeepPink);
   ObjectSet(ArrowName, OBJPROP_SELECTABLE, 0);
   ObjectSet(ArrowName, OBJPROP_SELECTED, 0);   ticket = Clot ? 0 : 1;
   ObjectSet(ArrowName, OBJPROP_WIDTH, 5);     /* bool t_close = false;
   if (Clot || ticket) { if (OrderSelect(floor(Clot? Clot: ticket), SELECT_BY_TICKET) == true) 
      while (! t_close) { t_close = OrderClose(floor(Clot? Clot: ticket), lot, Bullish? Bid: Ask), slip, clrNONE);
         if (t_close) ticket = 0;      else Sleep(1000); } }
   if (! Clot) ticket = OrderSend(Symbol(), Bullish? ORDER_TYPE_BUY: ORDER_TYPE_SELL, lot, Bullish? Ask: Bid, slip, 0.0, 0.0, NULL);
//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? clrLime: clrDeepPink);
      ObjectSet(ArrowName, OBJPROP_SELECTABLE, 0);
      ObjectSet(ArrowName, OBJPROP_SELECTED, 0);
      ObjectSet(ArrowName, OBJPROP_WIDTH, 2); }
   bar_Dirs[BarNum] = (Clot? "Close": Bullish? "Buy": "Sell");
   bar_OPrs[BarNum] = (Clot? 0.0: LinePrice);
   bar_OPts[BarNum] = (Clot? 0.0: LinePrice);
   bar_Dir = (Clot? "Close": Bullish? "Buy": "Sell");
}
// 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? clrLime: 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, 0);
   ObjectSet(ArrowName, OBJPROP_SELECTED, 0);
   ObjectSet(ArrowName, OBJPROP_WIDTH, 2);
   bar_Dirs[BarNum] = (Bullish? bar_Dir=="Buy"? "Sell": "Buy": "Close");
   bar_OPrs[BarNum] = (Bullish? LinePrice: 0.0);
}

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? 9: 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) {
   string LabelName = PREFIX+"_end_Label_"+IntegerToString(Bullish?241:242)+"-"+IntegerToString(Pos)+"-"+IntegerToString(BarNum)+"-0-0";
   ObjectCreate(LabelName,OBJ_LABEL,0,0,0);
   ObjectSet(LabelName,OBJPROP_XDISTANCE,10);
   ObjectSet(LabelName,OBJPROP_YDISTANCE,30);
   ObjectSet(LabelName,OBJPROP_CORNER,CORNER_RIGHT_UPPER);
   ObjectSet(LabelName,OBJPROP_ANCHOR,ANCHOR_RIGHT);
   ObjectSetString(0,LabelName,OBJPROP_TEXT,vText);
   ObjectSet(LabelName,OBJPROP_FONTSIZE,12);
   ObjectSet(LabelName,OBJPROP_COLOR, 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);
     if (pos && StringSubstr(name,0,8) == "EA_Test_") { j ++;   if (ObjectDelete(name)) { i ++;  pos --; } } }
   if (P) Print (pos, " objects, DELETED: ", i, " / ", j, " / ", obj_total);
   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 = (10/Multiplier)*MarketInfo(symbol,MODE_POINT); }
/* - partie finale ---------------------------------------------------------------------------------------------------------------- */

void DrawArrow_pf(double LinePrice,int BarNum,int Code,bool Bullish,bool Clot) {
   string ArrowName = (Code==2? "EA": PREFIX)+"_pf_Arr"+(Bullish?"-Up_":"-Down_")+IntegerToString(Code?Code:Bullish?241:242)+"-"+
      IntegerToString(BarNum)+"-"+IntegerToString(Clot)+(Code==2? " "+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? clrLime: clrDeepPink);
   ObjectSet(ArrowName, OBJPROP_SELECTABLE, 0);
   ObjectSet(ArrowName, OBJPROP_SELECTED, 0);
   ObjectSet(ArrowName, OBJPROP_WIDTH, 2);
   bar_Dirs[BarNum] = (Clot? "Close": Bullish? "Buy": "Sell");
   bar_OPrs[BarNum] = (Clot? 0.0: LinePrice);
   bar_OPts[BarNum] = (Clot? 0.0: LinePrice);
   bar_Dir = (Clot? "Close": Bullish? "Buy": "Sell");
}

bool DrawArrow_end(double LinePrice,int BarNum,int Code,bool Bullish,bool Clot) {
   string ArrowName = "EA_end_Arr"+(Bullish?"-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? clrLime: clrDeepPink);
   ObjectSet(ArrowName, OBJPROP_SELECTABLE, 0);
   ObjectSet(ArrowName, OBJPROP_SELECTED, 0);
   ObjectSet(ArrowName, OBJPROP_WIDTH, 2);
   bar_Dirs[BarNum] = (Clot? "Close": Bullish? "Buy": "Sell");
   bar_OPrs[BarNum] = (Clot? 0.0: LinePrice);
   bar_OPts[BarNum] = (Clot? 0.0: LinePrice);
   bar_Dir = (Clot? "Close": Bullish? "Buy": "Sell");
   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? clrLime: 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);
   bar_Dirs[BarNum] = (Bullish? bar_Dir=="Buy"? "Sell": "Buy": "Close");
   bar_OPrs[BarNum] = (Bullish? LinePrice: 0.0);
}

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); }
