extermum point not working

 

hi

my code is flowing ...

int OnInit()
  {

//storage 20 high_price history and it's date in array by loop
   for(i=0; i<=20; i++)
     {
      HSaveP[i]=iHigh(Symbol(),Period(),i);
      HSaveD[i]=iTime(Symbol(),Period(),i);
     }

//check my condition in my array that is true by loop
   for(j=4; j<=16; j++)
     {

      //divided my array in 2 section. right side and left side whole target data(j to j-4 and j to j+4). if true so j is extermum
      if(HSaveP[j]>HSaveP[j-1] && HSaveP[j]>HSaveP[j-2] && HSaveP[j]>HSaveP[j-3] && HSaveP[j]>HSaveP[j-4] &&
         HSaveP[j]>HSaveP[j+1] && HSaveP[j]>HSaveP[j+2] && HSaveP[j]>HSaveP[j+3] && HSaveP[j]>HSaveP[j+4])
        {

         //storage right side to HSortP1 and left Side to HSortP2 for compare the amount of difference between target and lowest in each side
         q=0;
         for(q=0; q<=4; q++)
           {
            HSortP1[q]=HSaveP[j+q];
            HSortP2[q]=HSaveP[j-q];
           }

         //get index of lowest array
         HLP1=ArrayMinimum(HSortP1,0,WHOLE_ARRAY);
         HLP2=ArrayMinimum(HSortP2,0,WHOLE_ARRAY);

         // check condition for minimum amount of difference between target and lowest in each side. if true is extermum of sweeng.
         if(fabs(HSaveP[j]-HSortP1[HLP1])>fabs((HSortP1[HLP1]/100)*7) && fabs(HSaveP[j]-HSortP2[HLP2])>fabs((HSortP2[HLP2]/100)*7))
           {

            // if true, storage value to global array variable for next compare and etc
            HExtermumP[j]=HSaveP[j];
            HExtermumD[j]=HSaveD[j];
            //rsi not working :|
            HExtermumRsi[j]=iRSI(Symbol(),Period(),14,j);
            //create ellipse on extermum to check my extermum points visually
            ObjectCreate(0,"myEllipse1"+j,OBJ_ARROW,1,HSaveD[j],HSaveP[j],HSaveD[j-1],HSaveP[j-1],HSaveD[j+1],HSaveP[j+1],clrRed,STYLE_SOLID,2,true,true,false,true);
           }
        }
     }
   return(INIT_SUCCEEDED);
  }

it doesn't work

help me please

 
troojansafir: it doesn't work, help me please
  1. Don't try to use any price or server related functions in OnInit (or on load,) as there may be no connection/chart yet:

    1. Terminal starts.
    2. Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
    3. OnInit is called.
    4. For indicators OnCalculate is called with any existing history.
    5. Human may have to enter password, connection to server begins.
    6. New history is received, OnCalculate called again.
    7. New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
  2. "Doesn't work" is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless.

    Do you really expect an answer? There are no mind readers here and our crystal balls are cracked.

    With the information you've provided — we can only guess. And you haven't provided any information for that.

    How can we know what it's doing and what you want it to do?

  3. Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?