Download MetaTrader 5

EMA return incorrect value

To add comments, please log in or register
Naruephon Klongngoen
425
Naruephon Klongngoen  

Hi,

I'm trying to modify HA indicator by adding EMA as another condition.

I need to arrow up on white candle and haHigh>EMA14 but it look seem EMA return incorrect value

I have try for long hours to find out but really could not see where I was wrong

 

  for(i=pos; i<rates_total; i++)

     {

      haOpen=(ExtOpenBuffer[i-1]+ExtCloseBuffer[i-1])/2;

      haClose=(open[i]+high[i]+low[i]+close[i])/4;

      haHigh=MathMax(high[i],MathMax(haOpen,haClose));

      haLow=MathMin(low[i],MathMin(haOpen,haClose));

      

      

      EMA14 = iMA(NULL, 0, 14, 0, MODE_EMA, PRICE_CLOSE, i);

      //Alert(EMA14+" i="+i);

      

      if(haOpen<haClose)

        {

         ExtLowHighBuffer[i]=haLow;

         ExtHighLowBuffer[i]=haHigh;

        }

      else

        {

         ExtLowHighBuffer[i]=haHigh;

         ExtHighLowBuffer[i]=haLow;

        }

      ExtOpenBuffer[i]=haOpen;

      ExtCloseBuffer[i]=haClose;

      

      if(Close[i]>EMA14)

      {

         CrossUp[i] = EMA14;

      }

     }

 

 

Please advise

Thanks in advance  

Files:
HAArrow.mq4 6 kb
To add comments, please log in or register