void OnTick() { … int EMA13Def = iMA(_Symbol, _Period, 13, 0, MODE_EMA, PRICE_CLOSE); ArraySetAsSeries(EMA13Array, true); CopyBuffer(EMA13Def, 0 , 0, 3, EMA13Array);
Perhaps you should read the manual, especially the examples.
How To Ask Questions The Smart Way. 2004
How To Interpret Answers.
RTFM and STFW: How To Tell You've Seriously Screwed Up.
Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 2020.03.08
How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 2020.07.05
How to call indicators in MQL5 - MQL5 Articles 12 March 2010
Actually
int EMA13Def = iMA(_Symbol, _Period, 13, 0, MODE_EMA, PRICE_CLOSE);
iMA returns the value depends on the index and it is double. Your last parameter is missing (the index).
Call it directly as
((iMA(_Symbol, _Period, 13, 0, MODE_EMA, PRICE_CLOSE, 2) > Rates[2].open) && (iMA(_Symbol, _Period, 13, 0, MODE_EMA, PRICE_CLOSE, 2) < Rates[2].close))
Georgi Gaydarov: Call it directly as
((iMA(_Symbol, _Period, 13, 0, MODE_EMA, PRICE_CLOSE, 2) > Rates[2].open) && (iMA(_Symbol, _Period, 13, 0, MODE_EMA, PRICE_CLOSE, 2) < Rates[2].close))
Are your books one column but two feet wide? No because that is unreadable. They are 6 inches, sometimes two columns, so you can read it easily. So should be your code. I'm not going to go scrolling (or moving my eyes) back and forth trying to read it. Don't copy and paste code (iMAs), write self documenting code.
double ma2 = iMA(_Symbol, _Period, 13, 0, MODE_EMA, PRICE_CLOSE, 2); bool openedBelow = ma2 > Rates[2].open, closedAbove = ma2 < Rates[2].close, crossedUp = openedBelow && closedAbove;
Thanks for responding. I really appreciate it. I will read the docs.
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
Hi.
A function in my EA function should return true when EMA 13 crosses the previous two candles. The idea is to see if the EMA value was between the candle's open and close price. It doesn't work.
Here's an ASCII visual of the candles and EMA.
++
++ ++
++ ++ ---------
---++---++---
++ ++ ++
++ ++ ++
P2 P1 Current Candle