-
macdData[num_history_macd_data - i - 1]=iMACD(MySymbol, MyTimeFrame, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, i);
Why did you post your MT4 question in the MT5 EA section instead of the MQL4 section, (bottom of the Root page)?
General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
Next time, post in the correct place. The moderators will likely move this thread there soon. Your code if (someCondition == 1) { MyInitialized = true; } else { MyInitialized = false; }
Simplified. MyInitialized = someCondition == 1;
- bin1496: The code works normally in daytime. but when it across a new day(0:00, GMT), the value of macdData in MyInit() function appears to be very strange
Do you really expect an answer? There are no mind readers here and our crystal balls are cracked.
Always post all relevant code (using Code button) or attach the source file.
How To Ask Questions The Smart Way. (2004)
Be precise and informative about your problem -
Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
Code debugging - Developing programs - MetaEditor Help
Error Handling and Logging in MQL5 - MQL5 Articles (2015)
Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi everyone
I'm trying to write an EA based on MACD indicator. Below is my framework. It works almost okay, but has a very strange bug I couldn't handle. I did much effort to search some posts but found nothing helpful.
The code works normally in daytime. but when it across a new day(0:00, GMT), the value of macdData in MyInit() function appears to be very strange when no position opened(positions=0), which leads to a false signal activation. eg: right data(0.00021, 0.00020, 0.00019, ...) VS wrong data(0.0023, 0.0021, 0.0024). I try to find the relationship between these two series of data but failed.
Then I will stop the EA and restart it again. This time it works normally whole day, until the next new day (0:00, GMT), again and again.
I write same framework in MQL5(like below), it works perfectly, nothing bad happen when crossing a new day(0:00, GMT)
Anyone can help me to figure out the problems.
Thank you so much.