iRSI - Close All Orders

 

When the iRSI gets to XX value I attempting to Close Out all Open Orders however its not executing...

I believe a 'if' condition is not being met? Cheers!

   if(iRSI(NULL,0,21,PRICE_CLOSE,0)==50)
   {
      for(cnt=OrdersTotal();cnt>=0;cnt--)
      {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
       if (OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) 
         {
         if (OrderType()==OP_BUY) { OrderClose(OrderTicket(),OrderLots(),Bid,slippage,Yellow); }
         if (OrderType()==OP_SELL) { OrderClose(OrderTicket(),OrderLots(),Ask,slippage,Yellow); }
         Alert("iRSI @ 50 Closing All Orders");
         //return(0);
         }
      }
   }
 
You are checking whether RSI equals to 50, what rarely happens. Check whether it has crossed the 50 level instead.
 

That is exactly what I'm after... As a rookie how do I checked that it's crossed? Use the greater than / less than expressions?

 

if it is less than 50 on bar 2 and greater than 50 on bar 1, then it crossed up

using bar 0 will give unstable results as price changes. You can use bar 1 and 0, but be aware.

so (using bars 1 and 2)

if((iRSI(NULL,0,21,PRICE_CLOSE,2) <= 50) && (iRSI(NULL,0,21,PRICE_CLOSE, 1) > 50)){

 
Ahh phy I'm speechless... it works...
Reason: