Cycle While help me please!!!

 
Hello everyone!
Unfortunately the while loop you just can not make it work. I would like to run this code.
the RSI to candlemust be above level 50, now start the while loop that will search the first candle back in the graph is below the level 30.
But the desired result is not correct, where am I wrong?

Thank you all for the replies.


   int i=0;
        
        
        if (iRSI(NULL,0,4,PRICE_CLOSE,1+i) > 50) // First condition true
        
        int I=2;
        while(I++ < 200)
        {
        
         if(iRSI(NULL,0,4,PRICE_CLOSE,I) < 30) //Second condition true
        {
         Buffer1[i] = High[i] ; //Show Buffer        
         break; //exit cycle While
        }



 
int i=0;
        
        
        if (iRSI(NULL,0,4,PRICE_CLOSE,1+i) > 50) // First condition true
        
        int I=i+2;
        while(I < 200)
        {
        
         if(iRSI(NULL,0,4,PRICE_CLOSE,I) < 30) //Second condition true
        {
         Buffer1[i] = High[i] ; //Show Buffer        
         break; //exit cycle While
        }
        I++;
        }
 
thanks for the quick answer but unfortunately it does not work, press the buffer on each candle
 
fly7680:
thanks for the quick answer but unfortunately it does not work, press the buffer on each candle

Brakets?

if (iRSI(NULL,0,4,PRICE_CLOSE,1+i) > 50// First condition true
{
        int I=i+2;
        while(I < 200)
        {
         
         if(iRSI(NULL,0,4,PRICE_CLOSE,I) < 30//Second condition true
        {
         Buffer1[i] = High[i] ; //Show Buffer         
         break//exit cycle While
        }
        I++;

        } 

 
fly7680:
thanks for the quick answer but unfortunately it does not work, press the buffer on each candle

Try this :

   if (iRSI(NULL,0,4,PRICE_CLOSE,1) > 50)
      { int i=2; for (; i<Bars && iRSI(NULL,0,4,PRICE_CLOSE,i)>30; i++); if (i<Bars) buffer[i] = High[i]; }
 

in each candle there is the buffer in back testing.




 
Mladen Rakic:

Try this :

   if (iRSI(NULL,0,4,PRICE_CLOSE,1) > 50)
      { int i=2; for (; i<Bars && iRSI(NULL,0,4,PRICE_CLOSE,i)>30; i++); if (i<Bars) buffer[i] = High[i]; }
thanks for your help but it does not work! I must have the buffer in the candle 0, only when I meet, in a candle behind the RSI below level 30 and candle 1 RSI level up 50
 

It is not clear what you are trying to do.

Your code simply checks if the last closed bar is above RSI 50 and any of the previous 200 bars are below RSI 30.

it does not work, press the buffer on each candle


I don't know what that means


if you change

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


to

if (iRSI(NULL,0,4,PRICE_CLOSE,1+i) > 50 && iRSI(NULL,0,4,PRICE_CLOSE,1+i) <= 50) // First condition true


you will only see the arrow when the RSI crosses above or bounces off of the 50 level
 
Keith Watford:

It is not clear what you are trying to do.

Your code simply checks if the last closed bar is above RSI 50 and any of the previous 200 bars are below RSI 30.


He wants like this.

1) If prevoius bar rsi >50

2) after that fount bar where rsi<30 and put there arrow

 
eevviill14:

He wants like this.

1) If prevoius bar rsi >50

2) after that fount bar where rsi<30 and put there arrow

If that is the case

instead of

Buffer1[i] = High[i]


it should be

Buffer1[I] = High[I]


one of the problems associated with mixing variables i and I (ie lower case and capitals) in the same block of code
 
eevviill14:

He wants like this.

1) If prevoius bar rsi >50

2) after that fount bar where rsi<30 and put there arrow

1) Candle 1 RSI > 50

2) Research of the first candle back with RSI <30 and put arrow in candle 0

3) end search and exit cylce for

Reason: