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:
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:
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?
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.