Download MetaTrader 5

Problems with MA indicator

To add comments, please log in or register
creskita
63
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:

 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.

Zee Zhou Ma
1585
Zee Zhou Ma  

Possible to show screenshot to illustrate your point on why your code makes it become a bullish indicator instead of bearish?

If however your indicator is proprietary, and you do not want to show screenshot, my only thinking now is that MA is actually a lagging indicator that depends on the period used.

You may want to use another faster moving average indicator like EMA (Exponential Moving Average), or HMA (Hull Moving Average), and try again with the same code.

Irwan Adnan
934
Irwan Adnan  
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.
To add comments, please log in or register