Alain Verleyen #:
Your code is really not good, inappropriate use of indicator handle (should be initialized in OnInit), no error checking, bad usage of PositionXXX functions.
You were lucky it did something useful in the past.
I'm still learning and developing it though. Thanks a lot for the input. Much appreciated. I will improve on it as I advance further. But what about the trade not exiting below or above the moving average. Does it still have to do with my code? Because it worked before.
Hi! I don’t really understand that… if anybody can enlighten me… how come OnSell() function is called in Ontick() function… but Onsell() contains everything it is in Ontick()… why?
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello. I'm noticing something a bit strange about my trades on MT5. My EA has been working perfectly until now. I noticed that a certain functionality no longer work. I contacted my broker and was told that they've thoroughly checked my account and confirmed that there are no limitations for me to apply for EA, and that I should check with the MetaQuotes team. But unfortunately, I can only make non-financial complaints only on this forum.
I made a functionality on my EA to close or exit trade when a candle closes below the 50 Moving Average for buy trade, and also exit trade when it closes above the 50 Moving Average for sell trade.
This was working very well when I traded live before. Now it doesn't work anymore. I switched over to Strategy Tester and made it run. It worked. I did same on Demo, It worked also. But it never did on my Live account.
Now when my EA enters a trade, I have to close it manually when that condition is met. This is really frustrating, and not what I intended. Is this now the norm or an error? Below is the code. Any help will be much appreciated.