Download MetaTrader 5
To add comments, please log in or register
Did you like the article? Share it with your friends!
amando 2014.12.28 16:26 



i try to run my EA on a 1H chart, but i calculate an EMA on daily basis,

so i use this code to get the daily EMA


double EMA500 = iMA(_Symbol,PERIOD_D1,50,0,MODE_EMA,PRICE_CLOSE);
double EMA501 = iMA(_Symbol,PERIOD_D1,50,1,MODE_EMA,PRICE_CLOSE);

  The interresting thing,


EMA500 result is 10

EMA501 result is 11


does anyone have an idea whats wrong?



Alain Verleyen
Alain Verleyen 2014.12.28 16:38  

Did you try to read the documentation ?

Returned value

Returns the handle of a specified technical indicator,  in case of failure returns INVALID_HANDLE. The computer memory can be freed from an indicator that is no more utilized, using the IndicatorRelease() function, to which the indicator handle is passed.

See this article

MQL5 for Newbies: Guide to Using Technical Indicators in Expert Advisors
MQL5 for Newbies: Guide to Using Technical Indicators in Expert Advisors
  • 2010.03.18
  • Sergey Pavlov
In order to obtain values of a built-in or custom indicator in an Expert Advisor, first its handle should be created using the corresponding function. Examples in the article show how to use this or that technical indicator while creating your own programs. The article describes indicators that are built n the MQL5 language. It is intended for those who don't have much experience in the development of trading strategies and offers simple and clear ways of working with indicators using the offered library of functions.
amando 2014.12.28 19:22  

what does this means exactly?

im not a professional coder


how i get right values for iMA? in general i see its an integer, so i cant get double values.


but how i can handle the function right?



amando 2014.12.29 09:44  

when i want to use this code from the MovingAvarege.mqh


double ExponentialMA(const int position,const int period,const double prev_value,const double &price[])
   double result=0.0;
//--- calculate value
      double pr=2.0/(period+1.0);


what its meaning with

const int position: ??

const int period: is this Period_D1 and others ???

const double prev_value: ??

const double &price[]: is this PRICE_CLOSE ???? 

To add comments, please log in or register