your strategy is interesting, so i tried plotting EMA7 on s&p 500 using yahoo finance https://yhoo.it/2OG296C some observations though it seem to work better when stocks are moving in a rather strong uptrend or downtrend, however during periods where prices are trading in a wavy but flat sideways or high volatility but marginally declining price trend, EMA7 apparently gets caught in the whipsaw as well then there are also periods when prices are literally 'hugging' EMA7 that may be an issue as since the candles threads along EMA7 it could close one day below EMA7 and next day above EMA7. nevertheless thanks for sharing, this is quite an interesting finding but EMA7 alone won't be adequate as a catch all rule the other thing is the rather large number of trades, if cost of each trade is significant the returns may be smaller than the simulation suggest
There are free resources on the net. Just type hidden markov model in R in google and you will find plenty of helpful resources.
i've trained a HMM before, what inputs did you feed into yours? Probably going to do the next version in Python