Complex indicator signals with RSI 50 line crosses

 

I want to create an indicator that will alert me when RSI crosses the 50 mark, reaches a high point e.g. 65, then drops below the 50 mark, then crosses above it again and reaches or exceeds the previous high 65. 

At the final point of exceeding the previous high and only at that point would I like the signal to occur. 

I understand how to do this using shift for each individual bar etc..., but when the amount of bars is arbitrary I do not understand how I should approach the logic behind something like this...

Also since I cannot use iHighest for indicators, how do I obtain the highest point for such specificity..?

I am not asking anyone to code this for me, but if anyone could offer insight as to where I should start or point me in the right direction it would be much appreciated. :)

 
fabian waldo: RSI crosses the 50 mark, reaches a high point e.g. 65, then drops below the 50 mark, then crosses above it again and reaches or exceeds the previous high 65. ,

but when the amount of bars is arbitrary I do not understand how I should approach the logic behind something like this...
You code it exactly as you stated. Use a state machine.
OnCalculate(...){
   double rsi =...
   enum State{Unknown, Above65, Below50, Found};
   static State state = Unknown;
   switch(state){
   case Unknown:
      if(rsi > 65) state=Above65;
      break;
   case Above65:
      if(rsi < 50) state=Below50;
      break;
   case Below50:
      if(rsi > 65){state=Found; arrow[...] = ...; }
      break;
   case Found:
      if(rsi < 50) state=Unknown;
      break;
   }
}
 
whroeder1:
You code it exactly as you stated. Use a state machine.


Thankyou whroeder1 I will look into to using a state machine. 

However, do you also know how I can tackle the ihighest/ ilowest issue as your solution will require a predetermined value (65) - however these numbers are arbitrary and will change every time since I need the highest and lowest points (above and below the 50 mark. 

Thankyou for the guidance already! 

Reason: