why this code didn't get me the result

 

hi

i want to make adjust to object when state is active, but the case happend then didn't adjusted 

int x = IndicatorCounted();
   if (x < 0) return (-1);
     
   for (int L =1; L<Bars; L++) {
   //for (int L = Bars-1; L>= 1; L--) {
  // int U= L> MaxHistoryBars;
     if ( (High[L]<Low[L-1])
      &&((Low[L-1]-High[L])>min())){
         curr_rec_obj= "up_"+High[L-1]+"_"+MathRand()  ;             
            ObjectCreate(curr_rec_obj, OBJ_RECTANGLE, 0,Time[L] ,High[L],Time[L-1],Low[L-1]);   
            ObjectSet(curr_rec_obj, OBJPROP_STYLE, STYLE_SOLID);
            ObjectSet(curr_rec_obj, OBJPROP_WIDTH, 1);
            ObjectSet(curr_rec_obj, OBJPROP_COLOR, BearColor);
            ObjectSet(curr_rec_obj, OBJPROP_BACK, TRUE);
            ObjectCreate(0,L+"ST",OBJ_VLINE,0,Time[L],0); 
            gab_statue="up";
         
        
         for(int i=L;i>2;i--)
         //for (int i =2; i<L; i++)
           //datetime date=Time[i];
           {
               if( gab_statue=="up"){ 
                  if( High[L]>Low[i])
                      {                                            
                        ObjectSet(curr_rec_obj, OBJPROP_TIME2,Time[i]);                    
                      //  Alert(1006+" "+curr_rec_obj+" "+High[L]);
                        gab_statue="false";
                        break; 
                       }
                      else
                        {
                        ArrayResize(gab_data,ArrayRange(gab_data,0)+1);
                     int arrayindex=ArrayRange(gab_data,0)-1;
                     gab_data[arrayindex][0]= Time[L];
                     gab_data[arrayindex][1]= "up";                     
                     gab_data[arrayindex][2]= DoubleToString(High[i]);
                     gab_data[arrayindex][3]= DoubleToString(Low[i-1]);
                     gab_data[arrayindex][4]= curr_rec_obj;
                     break;
                     }
                }       
           }
        break;
      }
   }
 
some help to get solution 
 
Sherif Omar: i want to make adjust to object when state is active, but the case happend then didn't adjusted 
  1. Use the debugger or print out your variables, and find out why.

  2. Always use strict. Fixing the warnings will save you hours of debugging.
              Program Properties (#property) - Preprocessor - Language Basics - MQL4 Reference

  3. Start using the new Event Handling Functions.
              Event Handling Functions - Functions - Language Basics - MQL4 Reference

  4. Stop using IndicatorCounted and use the values in OnCalculate
              How to do your lookbacks correctly.

  5. gab_data[arrayindex][0]= Time[L];
    gab_data[arrayindex][1]= "up";                     
    gab_data[arrayindex][2]= DoubleToString(High[i]);
    gab_data[arrayindex][3]= DoubleToString(Low[i-1]);
    gab_data[arrayindex][4]= curr_rec_obj;
    Don't use a 2D array. Use a 1D array of a struct. Then you can store the datetime and prices without conversions in and out. And the code self-documents, which 0 … 4 doesn't.

  6. ObjectCreate(0,L+"ST",OBJ_VLINE,0,Time[L],0); 
    Do not use as series shifts in object names. Once a new bar forms you will try to use the same shift again and the create fails. (Use Bars-L or Time[L].)
 
whroeder1:
  1. Use the debugger or print out your variables, and find out why.

  2. Always use strict. Fixing the warnings will save you hours of debugging.
              Program Properties (#property) - Preprocessor - Language Basics - MQL4 Reference

  3. Start using the new Event Handling Functions.
              Event Handling Functions - Functions - Language Basics - MQL4 Reference

  4. Stop using IndicatorCounted and use the values in OnCalculate
              How to do your lookbacks correctly.

  5. Don't use a 2D array. Use a 1D array of a struct. Then you can store the datetime and prices without conversions in and out. And the code self-documents, which 0 … 4 doesn't.

  6. Do not use as series shifts in object names. Once a new bar forms you will try to use the same shift again and the create fails. (Use Bars-L or Time[L].)

Thank you very much

Reason: