Thanks Alan, the problem is not with the EA but seems to be with the history provided by the broker. I tried it on ICmarkets and it went well.
Regards
The Academy’s free courses take you from a demo account to your first Expert Advisor, taught by the traders who answer here.