mq4...oh sorry i can't help , I have forgotten all about mql4 ....
- Balint Rubovszky: I have written an MQL4 Expert Advisor code:
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. - Balint Rubovszky: When EMA12 gets = EMA28, i
ExponentialMovingAverage12[2] - ExponentialMovingAverage28[2] == 0
Doubles are rarely equal. Understand the links in:
The == operand. - MQL4 programming forum #2 (2013)
-
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. -
Doubles are rarely equal. Understand the links in:
The == operand. - MQL4 programming forum #2 (2013)
double ExponentialMovingAverage12[2]; double ExponentialMovingAverage28[2];
You declared the wrong array number.
Instead of:
double ExponentialMovingAverage12[2]; double ExponentialMovingAverage28[2];
Use this array number to declare:
double ExponentialMovingAverage12[3]; double ExponentialMovingAverage28[3];
Then everythings gonna be OK 😊
Have a nice coding!
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have written an MQL4 Expert Advisor code: It should open a BUY position, if the EMA12 crosses above the EMA28, and then a SELL position, when the EMA12 crosses below the EMA28. It examines this condition at the close of every 1 minute candle. Only one BUY and one SELL should be traded, so I used a flag variable to achieve that. When EMA12 gets = EMA28, it is also considered a crossing. The EA should only operate from a begin time. This is only a test code, so instead of trade orders, only alert messages are sent. When I compile the code and run it on MT4, it does not work! It should give an alert message at the beginning of every minute "one minute has passed", but it does not do that. It should also give an alert message on BUY and SELL, but it does not do that! Why is that? Please, help!
Here is the code, which I have written: