Why EA order placing when condition not met?

 

Hi!

I use RSI to filter the trend to place new order.

here is i added condition for RSI to filter.

here is my condition to filter the trade:

If RSI(14)>60 >> Buy

If RSI(14)<40 >> Sell

see the image below:

it seems working wrong. Please suggest me to solve the issue. i use shift value as "0"

my code is given below:

    if (iRSI(NULL, NULL,14,PRICE_CLOSE,0) > 60)
    {
        //Buy call
        
    }
    if (iRSI(NULL, NULL,14,PRICE_CLOSE,0) < 40)
    {
        //Sell call
        
    }



 

Maybe it was below 40 at some time when the bar was current.

I will only mention using NULL for the time-frame and not comment as I have no idea whether NULL is interpreted as the current time-frame or not. 

 
  1. TF is an enumeration not a string. NULL is wrong. Use zero or PERIOD_CURRENT.
  2. Value will change multiple times as bar zero forms. If you don't want multiple signals use bar one.
Reason: