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

//Op_Shw2 = false;

/* double haOpen, haClose, haHigh, haLow; -> utiliser ici en remplacement des iOpen(...), iClose(...), iHigh(...), iLow(...) */
bool f_mqh_code(int mqh_code, int pos, int prv_pos, int i, string liq_typ, double pr_clo, double reopn_pr, double reclo_pr) { bool t_clo;

   switch (mqh_code) {
      case 0:  t_clo = (iHigh(NULL,0,Bars-i) - iLow(NULL,0,Bars-i) > 0.0 &&      // cette option retirée double presque le résulat final **
            ((liq_typ=="Buy" ? -1 : 1) * (pr_clo-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) > 0.3 &&
            ((liq_typ=="Buy" ? -1 : 1) * (iClose(NULL,0,Bars-i) - iOpen(NULL,0,Bars-i+1)) > 20 * Point ||
            ((liq_typ=="Buy" ? -1 : 1) * (iClose(NULL,0,Bars-i+1) - iOpen(NULL,0,Bars-i+1))) > 20 * Point)));/*
            (((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 && 
            (!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) * (obj_prClots[pos]-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) > 0.75)) ||
            ((obj_liqTypes[pos]=="Buy" ? -1 : 1) * (obj_prClots[pos] - 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) * (obj_prClots[pos]-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) < 0.3)));*/
         break;
      case 1:  t_clo = (iHigh(NULL,0,Bars-i) - iLow(NULL,0,Bars-i) > 0.0 && 
            (((liq_typ=="Buy" ? 1 : -1) * (reopn_pr-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) > 0.3 && 
            (!Op_OHL || (liq_typ=="Buy"? -1: 1) * (iOpen(NULL,0,Bars-i) - (iHigh(NULL,0,Bars-i)+iLow(NULL,0,Bars-i)) / 2) > 20 * Point)) ||
            ((liq_typ=="Buy" ? 1 : -1) * (reopn_pr - iOpen(NULL,0,Bars-i)) > 20 * Point && 
            (liq_typ=="Buy" ? 1 : -1) * (iOpen(NULL,0,Bars-i) - (iHigh(NULL,0,Bars-i)+iLow(NULL,0,Bars-i)) / 2) > 20 * Point &&
            (liq_typ=="Buy" ? 1 : -1) * (reopn_pr-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) < 0.3)));
         break;
      case 2:/*  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);
               HiLoVal = ((iHigh(NULL,0,Bars-i+5)-iLow(NULL,0,Bars-i+5)) + (iHigh(NULL,0,Bars-i+1)-iLow(NULL,0,Bars-i+1)) + (iHigh(NULL,0,Bars-i+2)-
                  iLow(NULL,0,Bars-i+2)) + (iHigh(NULL,0,Bars-i+3)-iLow(NULL,0,Bars-i+3)) + (iHigh(NULL,0,Bars-i+4)-iLow(NULL,0,Bars-i+4))) / Point / 5;
               MrktVal = (obj_liqTypes[pos]=="Buy"? 1: obj_liqTypes[pos]=="Sell"? -1: 0) * ((obj_liqTypes[pos]=="Buy"? j==i? iHigh(NULL,0,Bars-i): 
                  iLow(NULL,0,Bars-i): j==i? iLow(NULL,0,Bars-i): iHigh(NULL,0,Bars-i)) - reOpn_prs[k]) / Point; */
            t_clo = (iHigh(NULL,0,Bars-i) - iLow(NULL,0,Bars-i) > 0.0 && 
            (((liq_typ=="Buy" ? -1 : 1) * (reclo_pr-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) > 0.3 && 
            (!Op_OHL || (liq_typ=="Buy"? -1: 1) * (iOpen(NULL,0,Bars-i) - (iHigh(NULL,0,Bars-i)+iLow(NULL,0,Bars-i)) / 2) > 20 * Point ||
            (liq_typ=="Buy" ? -1 : 1) * (reclo_pr-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) > 0.75)) ||
            ((liq_typ=="Buy" ? -1 : 1) * (reclo_pr - iOpen(NULL,0,Bars-i)) > 20 * Point && 
            (liq_typ=="Buy" ? -1 : 1) * (iOpen(NULL,0,Bars-i) - (iHigh(NULL,0,Bars-i)+iLow(NULL,0,Bars-i)) / 2) > 20 * Point &&
            (liq_typ=="Buy" ? -1 : 1) * (iOpen(NULL,0,Bars-i) - (iOpen(NULL,0,Bars-i+1)+iClose(NULL,0,Bars-i+1)) / 2) > 20 * Point &&
            (liq_typ=="Buy" ? -1 : 1) * (reclo_pr-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) < 0.3)/* ||
               (HighVal-MrktVal > HiLoVal * 2 && HighVal && MrktVal-HighVal < DDwnVal / 4*3)*/));
         break;
      case 3:  t_clo = (iHigh(NULL,0,Bars-i) - iLow(NULL,0,Bars-i) > 0.0 && 
            ((liq_typ=="Buy" ? -1 : 1) * (pr_clo-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) > 0.3 &&
            ((liq_typ=="Buy" ? -1 : 1) * (iClose(NULL,0,Bars-i) - iOpen(NULL,0,Bars-i+1)) > 20 * Point ||
            ((liq_typ=="Buy" ? -1 : 1) * (iClose(NULL,0,Bars-i+1) - iOpen(NULL,0,Bars-i+1))) > 20 * Point)));
         break;
      case 4:  t_clo = (iHigh(NULL,0,Bars-i) - iLow(NULL,0,Bars-i) > 0.0 &&                                    // boucle des reOps Label_Arrow_Test(Type= 1,
            (((liq_typ=="Buy" ? 1 : -1) * (reopn_pr-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) > 0.3 && 
            (!Op_OHL || (liq_typ=="Buy"? -1: 1) * (iOpen(NULL,0,Bars-i) - (iHigh(NULL,0,Bars-i)+iLow(NULL,0,Bars-i)) / 2) > 20 * Point)) ||
            ((liq_typ=="Buy" ? 1 : -1) * (reopn_pr - iOpen(NULL,0,Bars-i)) > 20 * Point && 
            (liq_typ=="Buy" ? 1 : -1) * (iOpen(NULL,0,Bars-i) - (iHigh(NULL,0,Bars-i)+iLow(NULL,0,Bars-i)) / 2) > 20 * Point &&
            (liq_typ=="Buy" ? 1 : -1) * (reopn_pr-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) < 0.3)));
         break;
      case 5: // 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 && 
            (((liq_typ=="Buy" ? -1 : 1) * (reclo_pr-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) > 0.3 && 
            (!Op_OHL || (liq_typ=="Buy"? -1: 1) * (iOpen(NULL,0,Bars-i) - (iHigh(NULL,0,Bars-i)+iLow(NULL,0,Bars-i)) / 2) > 20 * Point ||
            (liq_typ=="Buy" ? -1 : 1) * (reclo_pr-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) > 0.75)) ||
            ((liq_typ=="Buy" ? -1 : 1) * (reclo_pr - iOpen(NULL,0,Bars-i)) > 20 * Point && 
            (liq_typ=="Buy" ? -1 : 1) * (iOpen(NULL,0,Bars-i) - (iHigh(NULL,0,Bars-i)+iLow(NULL,0,Bars-i)) / 2) > 20 * Point &&
            (liq_typ=="Buy" ? -1 : 1) * (iOpen(NULL,0,Bars-i) - (iOpen(NULL,0,Bars-i+1)+iClose(NULL,0,Bars-i+1)) / 2) > 20 * Point &&
            (liq_typ=="Buy" ? -1 : 1) * (reclo_pr-iOpen(NULL,0,Bars-i)) / (iHigh(NULL,0,Bars-i)-iLow(NULL,0,Bars-i)) < 0.3)));
         break;
      case 6:
         break;
      case 7:
         break;
/*      case 1:
         break;
      case 1:
         break;
      case 1:
         break;
      case 1:
         break;
      case 1:
         break;
      case 1:
         break;
      case 1:
         break;
      case 1:
         break;
      case 1:
         break;
      case 1:
         break;
      default:   
*/     }
   return(t_clo); }

bool HA_Bull(double vyOpen, double vyClose, double vOpen, double vClose, double vHigh, double vLow) {
/*   haOpen = (ExtOpenBuffer[i-1]+ExtCloseBuffer[i-1])/2;
   haClose=(open[i]+high[i]+low[i]+close[i])/4;
   haHigh=MathMax(high[i],MathMax(haOpen,haClose));
   haLow=MathMin(low[i],MathMin(haOpen,haClose)); */

   haOpen = (vyOpen + vyClose) / 2;
   haClose = (vOpen + vHigh + vLow + vClose) / 4;
   haHigh = MathMax(vHigh, MathMax(haOpen, haClose));
   haLow = MathMin(vLow, MathMin(haOpen, haClose));

   return(haOpen < haClose); }

/* for(i=pos; i<rates_total; i++)
     {
      haOpen=(ExtOpenBuffer[i-1]+ExtCloseBuffer[i-1])/2;
      haClose=(open[i]+high[i]+low[i]+close[i])/4;
      haHigh=MathMax(high[i],MathMax(haOpen,haClose));
      haLow=MathMin(low[i],MathMin(haOpen,haClose));
      if(haOpen<haClose)
        {   // ici la barre est bleue -> bull
         ExtLowHighBuffer[i]=haLow;
         ExtHighLowBuffer[i]=haHigh;
        }
      else
        {   // ici la barre est jaune -> bear
         ExtLowHighBuffer[i]=haHigh;
         ExtHighLowBuffer[i]=haLow;
        }
      ExtOpenBuffer[i]=haOpen;
      ExtCloseBuffer[i]=haClose;
     } */
