Indicator doesn't respect the RSI limits

Wilailak Worabuth
130
Wilailak Worabuth  

Hi,


I have one indicator that gives me one alert when I have one engulfing candle in a range of RSI values, but for some reason the indicator is not reading the RSI values and some of the alerts are  not being given exactly when the candle closes.

Here is the code 


 open1=NormalizeDouble(iOpen(_Symbol,_Period,1),_Digits);

   open2=NormalizeDouble(iOpen(_Symbol,_Period,2),_Digits);

   close1=NormalizeDouble(iClose(_Symbol,_Period,1),_Digits);

   close2=NormalizeDouble(iClose(_Symbol,_Period,2),_Digits);



 double RSI= iRSI(_Symbol,_Period,RSIperiod,AppliedPrice,Shift);



 bar1sizeBULL=NormalizeDouble((close1-open1)/_Point),0);

   bar2sizeBULL=NormalizeDouble((open2-close2)/_Point),0);   

   bar1sizeBEAR=NormalizeDouble((open1-close1)/_Point),0);

   bar2sizeBEAR=NormalizeDouble((close2-open2)/_Point),0);



   if(open2>open1 && open2<close1 && close2<close1 && bar1sizeBULL>(bar2sizeBULL*2) && RSI>MinValBuy && RSI<MaxValBuy && NewBar())

        {

         Alert(Symbol()+" TF:"+string(Period())+" bullish: "+string(NormalizeDouble(Ask,Digits)));

}

   RefreshRates();           

    if(open2<open1 && open2>close1 && close2>close1 && bar1sizeBEAR>(bar2sizeBEAR*2) && RSI<MinValSell && RSI>MaxValSell && NewBar())

        {

Alert(Symbol()+" TF:"+string(Period())+" bearish: "+string(NormalizeDouble(Ask,Digits)));

}


What is weong with this  code?


Thanks in advance.

Keith Watford
Moderator
30000
Keith Watford  
Please edit your post and use the code button (Alt+S) when pasting code.
EDIT your original post, please do not just post the code correctly in a new post.

Wilailak Worabuth
130
Wilailak Worabuth  
Keith Watford:
Please edit your post and use the code button (Alt+S) when pasting code.
EDIT your original post, please do not just post the code correctly in a new post.

Sorry about that. Is that ok?

Keith Watford
Moderator
30000
Keith Watford  

Yes.

Why do you think that it is not reading the RSI values?

Wilailak Worabuth
130
Wilailak Worabuth  
Keith Watford:

Yes.

Why do you think that it is not reading the RSI values?

I have no idea it was suppose to be just numbers that Ichoose in the inputs. Is there any other way or a correct way to do it?

it gives me the alerts  too much oversold I need to filter it