Can anyone correct my code? this code sometimes buy when candle close below EMA20 but Above SMA 200

 
if (Close[3] > iMA(Symbol(),0,20,0,MODE_EMA, PRICE_CLOSE,0)  )//if candle close above EMA20//
   {
      if (Close[3] > iMA(Symbol(),0,200,0,MODE_SMA, PRICE_CLOSE,0)  )// if candle close above SMA200 //
         {
           //So.. open position BUY//
         OrderSend(Symbol(),OP_BUY,jumlahot, Ask, Slippage, Bid-StopLoss*Point, Ask+TakeProfit*Point, "BELI", 12345, 0, Green); 
         }
   }
 else
 if (Close[3] < iMA(Symbol(),0,20,0,MODE_EMA, PRICE_CLOSE,0)  ) // if candle close below EMA20 //
   {
      if (Close[3] < iMA(Symbol(),0,200,0,MODE_SMA, PRICE_CLOSE,0)  )// if candle close below SMA200 //
      //So .. open position SELL//
      OrderSend(Symbol(),OP_SELL,jumlahot, Bid, Slippage, Ask+StopLoss*Point, Bid-TakeProfit*Point, "JUAL", 12345, 0, Red);
   }
}


can anyone corect my code? why sometimes it will buy when candle close below EMA20 but above SMA200 otherwise it happen in OP SELL

 
last7ban: can anyone corect my code? why sometimes it will buy when candle close below EMA20 but above SMA200 otherwise it happen in OP SELL
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
              Messages Editor

  2. Your test has nothing to do with close below 20EMA
Reason: