Problems with MA indicator

 

Please help,

I'm trying to code an indicator which will involve a MA.

The coding I have come up with for the MA itself is the following:

 double ONEHRMA=iMA(Symbol(),PERIOD_H1,200,0,MODE_EMA,PRICE_CLOSE,i);


I then want it set a bearish indication on the screen if the price on close is less than the MA value. 

I have come up with this:


if (Close[i+1]<ONEHRMA)

 down[i]=High[i];


I can't figure out why, but it's not working. For one, instead of setting a bearish indicator, it's giving me bullish indicators. There are also many indicators in places where the close price is greater than the MA value and I can't figure it out either.


Can anyone help?


Thanks.

 
creskita:

Please help,

I'm trying to code an indicator which will involve a MA.

The coding I have come up with for the MA itself is the following:


Did you check the timeframe? You use PERIODE_H1 in your MA and perhaps your chart is other than H1 chart.