//+--------------------------------------------------------------------+
//|                        "Liste dObjets.mqh"          Utilisé dans : |
//|              "Liste dObjets (6).mq4" "Ind Liste dObjets (all).mq4" |
//|              "Liste dObjets EA.mq4" "Ind Liste dObjets (cha2).mq4" |
//+--------------------------------------------------------------------+

#include <Liste dObjets.mqh>

/* double haOpen, haClose, haHigh, haLow; -> utiliser ici en remplacement des iOpen(...), iClose(...), iHigh(...), iLow(...) */
bool f_mqh_code2(int mqh_code, int pos, int prv_pos, int i, int k) { bool t_clo;    // spécifiquement pour "Liste dObjets (7).mq4"
   double day1_Open, day1_Close, this_Open, this_Close, this_High, this_Low;
   if (ha_Opt) { day1_Open = ha1Open;  day1_Close = ha1Close;    this_Open = haOpen;  this_Close = haClose;   this_High = haHigh;  this_Low = haLow; }
   else { day1_Open = iOpen(sym_target,per_target,Bars-i+1);       day1_Close = iClose(sym_target,per_target,Bars-i+1);
      this_Open = iOpen(sym_target,per_target,Bars-i);         this_Close = iClose(sym_target,per_target,Bars-i);
      this_High = iHigh(sym_target,per_target,Bars-i);         this_Low = iLow(sym_target,per_target,Bars-i); }

   switch (mqh_code) {
      case 0:  t_clo = (this_High - this_Low > 0.0 && 
            ((obj_liqTypes[pos]=="Buy" ? -1 : 1) * (obj_prClots[pos] - this_Open) / (this_High - this_Low) > 0.3 &&
            ((obj_liqTypes[pos]=="Buy" ? -1 : 1) * (this_Close - day1_Open) > 20 * Point ||
            ((obj_liqTypes[pos]=="Buy" ? -1 : 1) * (day1_Close - day1_Open)) > 20 * Point)));
         break;
      case 1:  t_clo = (this_High - this_Low > 0.0 && 
            (((obj_liqTypes[pos]=="Buy" ? 1 : -1) * (reOpn_prs[k] - this_Open) / (this_High - this_Low) > 0.3 && 
            (!Op_OHL || (obj_liqTypes[pos]=="Buy"? -1: 1) * (this_Open - (this_High + this_Low) / 2) > 20 * Point)) ||
            ((obj_liqTypes[pos]=="Buy" ? 1 : -1) * (reOpn_prs[k] - this_Open) > 20 * Point && 
            (obj_liqTypes[pos]=="Buy" ? 1 : -1) * (this_Open - (this_High + this_Low) / 2) > 20 * Point &&
            (obj_liqTypes[pos]=="Buy" ? 1 : -1) * (reOpn_prs[k] - this_Open) / (this_High - this_Low) < 0.3)));
         break;
      case 2:  t_clo = (this_High - this_Low > 0.0 && 
            (((obj_liqTypes[pos]=="Buy" ? -1 : 1) * (reClo_prs[k] - this_Open) / (this_High - this_Low) > 0.3 && 
            (!Op_OHL || (obj_liqTypes[pos]=="Buy"? -1: 1) * (this_Open - (this_High + this_Low) / 2) > 20 * Point ||
            (obj_liqTypes[pos]=="Buy" ? -1 : 1) * (reClo_prs[k] - this_Open) / (this_High - this_Low) > 0.75)) ||
            ((obj_liqTypes[pos]=="Buy" ? -1 : 1) * (reClo_prs[k] - this_Open) > 20 * Point && 
            (obj_liqTypes[pos]=="Buy" ? -1 : 1) * (this_Open - (this_High + this_Low) / 2) > 20 * Point &&
            (obj_liqTypes[pos]=="Buy" ? -1 : 1) * (this_Open - (day1_Open + day1_Close) / 2) > 20 * Point &&
            (obj_liqTypes[pos]=="Buy" ? -1 : 1) * (reClo_prs[k] - this_Open) / (this_High - this_Low) < 0.3)));
         break;
      case 3:  t_clo = (this_High - this_Low > 0.0 && 
            ((obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (obj_prClots[pos] - this_Open) / (this_High - this_Low) > 0.3 &&
            ((obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (this_Close - day1_Open) > 20 * Point ||
            ((obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (day1_Close - day1_Open)) > 20 * Point)));
         break;
      case 4:  t_clo = (this_High - this_Low > 0.0 && 
            (((obj_liqTypes[prv_pos]=="Buy" ? 1 : -1) * (reOpn_prs[k] - this_Open) / (this_High - this_Low) > 0.3 && 
            (!Op_OHL || (obj_liqTypes[prv_pos]=="Buy"? -1: 1) * (this_Open - (this_High + this_Low) / 2) > 20 * Point)) ||
            ((obj_liqTypes[prv_pos]=="Buy" ? 1 : -1) * (reOpn_prs[k] - this_Open) > 20 * Point && 
            (obj_liqTypes[prv_pos]=="Buy" ? 1 : -1) * (this_Open - (this_High + this_Low) / 2) > 20 * Point &&
            (obj_liqTypes[prv_pos]=="Buy" ? 1 : -1) * (reOpn_prs[k] - this_Open) / (this_High - this_Low) < 0.3)));
         break;
      case 5:  t_clo = (this_High - this_Low > 0.0 && 
            (((obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (reClo_prs[k] - this_Open) / (this_High - this_Low) > 0.3 && 
            (!Op_OHL || (obj_liqTypes[prv_pos]=="Buy"? -1: 1) * (this_Open - (this_High + this_Low) / 2) > 20 * Point ||
            (obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (reClo_prs[k] - this_Open) / (this_High - this_Low) > 0.75)) ||
            ((obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (reClo_prs[k] - this_Open) > 20 * Point && 
            (obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (this_Open - (this_High + this_Low) / 2) > 20 * Point &&
            (obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (this_Open - (day1_Open + day1_Close) / 2) > 20 * Point &&
            (obj_liqTypes[prv_pos]=="Buy" ? -1 : 1) * (reClo_prs[k] - this_Open) / (this_High - this_Low) < 0.3)));
         break;
      case 6:
         break;
      case 7:
         break; }
   return(t_clo); }

