Cycle While help me please!!! - page 2

 

Perhaps so it should work, give me an opinion please?

control in the first candle that RSI is greater than 50, then I go back to look for the first candle with a lower RSI at 30, as soon as I find the cycle ends and I will have in the candle 0 buffer1

correct?!?


thanks to all and sorry my bad English!

int i=0;        
        
      if (iRSI(NULL,0,4,PRICE_CLOSE,1+i) > 50)
      
      
      int I=2;
      while (iRSI(NULL,0,4,PRICE_CLOSE,I) > 30 )  
      
      {I++;}  
      
      
Buffer1[i] = High[i];
 
What is the point of

      int I=2;
      while (iRSI(NULL,0,4,PRICE_CLOSE,I) > 30 )  
      
      {I++;}  
it does nothing
 
until the RSI is above 30, the cycle goes on and increments of a candle the condition to be tested.
When RSI is below 30, the loop exits.

It's wrong?
 
fly7680:
until the RSI is above 30, the cycle goes on and increments of a candle the condition to be tested.
When RSI is below 30, the loop exits.

It's wrong?

It's not wrong, but what is its purpose?

You get a value for the variable I but then you do not do anything with it.

 
Loops 2 loop for
   int limit = -1;
   if( counted_bars > 0 ) counted_bars --;
   limit = Bars - counted_bars;
   for( i= limit;i>=0;i--)
     {
     if (iRSI(NULL,0,4,PRICE_CLOSE,i) > 50) // First condition true
      {        
       int I=i+1;
       Fleche_Up[i] = High[i];
       for(int u = I;u< I+15;u++)
        {
         if(iRSI(NULL,0,4,PRICE_CLOSE,u) < 30) //Second condition true
         {
         Fleche_Down[u] = Low[u] ;
         break;
        }
       }    
     }
  
    }
 

That hardly resembles the code that you have been posting

   int limit = -1;
   if( counted_bars > 0 ) counted_bars --;
   limit = Bars - counted_bars;


Where does counted_bars get its value? It is not declared or assigned a value in your code.

If  counted_bars does = 0, limit will be assigned the value of Bars.

As the highest bar index is Bars-1, you risk an Array out of range error



     if (iRSI(NULL,0,4,PRICE_CLOSE,i) > 50) // First condition true


do you really just want to check that the RSI for that bar is above 50 or do you only want to check for a cross above or bounce off 50? (see my earlier post)



       for(int u = I;u< I+15;u++)


You should also check that u<Bars to avoid an Array out of range error
Reason: