Help with funtion..

 

Hi all. I have written a program for practice as I am learning. I have written and re-written it for the last 2 days and am stuck.

The function call is to initialise the first two points of a iRSI swing. 

It should look for the highest  and then the lowest low.

If we forget about the highest high for now and just look at the lowest low.

1. Identify iRSI <30 .   It does

2. Go into while () operator.  It does

3. Locate first lowest low based on  low[1] < low[2]. It does

4. Until iRSI > 30, keep checking for an even lower low on the next candle and then the next candle again etc.  It does not do this.

void InitializeDirection()
  {

   int a = 0;
   double DirectionRSI = 0.0;
   DirectionRSI = iRSI(NULL,0,4,0,Shift_Count);
   
//-- Highest high swing
   if(DirectionRSI >70 && !IsStopped() && Direction_Long_High ==0.0)
      while(DirectionRSI > 70 && a < Bars)
        {
         if(High[1] > High[2])
           {
            Print("RSI Long high is "+ DoubleToString(DirectionRSI,2));
            MarkCandle_1();
            Direction_Long_High = DirectionRSI;
            break;
           }
         else
            a++;
        }
//-- Lowest low swing       
   if(DirectionRSI <30 && !IsStopped() && Direction_Long_Low ==0.0)
      while(DirectionRSI < 30 && a < Bars && !IsStopped())
        {
         if( Low[1] < Low[2]&& Direction_Long_Low ==0.0)
           {
            MarkCandle_2();
            Direction_Long_Low = Low[1];
            Print("RSI Long Low is "+ DoubleToString(Direction_Long_Low,2));
            a++;
           }
         if(  Low[1] < Low[2]&& Direction_Long_Low !=0.0 && Direction_Long_Low > Low[1])
           {
            MarkCandle_3();
            Direction_Long_Low = Low[1];
            Print("New RSI Long Low is "+ DoubleToString(Direction_Long_Low,2));
           a++;
           }
          else
           {
              Print("a++");
              a++;
            }
          }


        }

Any help will be appreciated.

 
The Rsi Low/High ,or the chart Low/High ? 
 
Lorentzos Roussos:
The Rsi Low/High ,or the chart Low/High ? 

The RSI

 
Richard Roberts:

The RSI

Hmm , you dont seem to be updating the rsi value as you move into the search though

 
Would I be able to just ad the iRSI into the while operator or would I have to call it as a function?
 

You are only using candle 1 and 2

So do you need Shift_Count and counter a(a<Bars)

 
paul selvan:

You are only using candle 1 and 2

So do you need Shift_Count and counter a(a<Bars)

Shift_Count is from another part of the program, it does not effect the operation of this one. 

The while operator as I understand it will not work without "Bars" or something similar to count against. As in   "a<Bars;"

Reason: