hi
first of all, thanks for reading this article,
this code i have taken from a mql5 EA, in this EA moving average indicator is used, and i am fascinated by its use,
i want to try it in mt4
https://docs.mql4.com/indicators/iMA | double iMA(string symbol, int timeframe, int period, int ma_shift, int ma_method, int applied_price, int shift) Calculates the Moving average indicator and returns its value |
https://www.mql5.com/en/docs/indicators/ima | int iMA( string symbol, ENUM_TIMEFRAMES period, int ma_period, int ma_shift, ENUM_MA_METHOD ma_method, ENUM_APPLIED_PRICE applied_price); The function returns the handle of the Moving Average indicator. |
raptorUK do you want to help ? or do mischief?
Next time I see you ask for help I won't bother . . . but for now . . .
From build 610 help file . . .
|
iMA
Calculates the Moving Average indicator and returns its value.
double iMA( |
Parameters
symbol
[in] Symbol name on the data of which the indicator will be calculated. NULL means the current symbol.
timeframe
[in] Timeframe. It can be any of ENUM_TIMEFRAMES enumeration values. 0 means the current chart timeframe.
ma_period
[in] Averaging period for calculation.
ma_shift
[in] MA shift. Indicators line offset relate to the chart by timeframe.
ma_method
[in] Moving Average method. It can be any of ENUM_MA_METHOD enumeration values.
applied_price
[in] Applied price. It can be any of ENUM_APPLIED_PRICE enumeration values.
shift
[in] Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).
Returned value
Numerical value of the Moving Average indicator.
Example:
AlligatorJawsBuffer[i]=iMA(NULL,0,13,8,MODE_SMMA,PRICE_MEDIAN,i); |
hi
RaptorUK sorry for my mischief!
sorry i did not read the mt4 article as you said, but actually i know how to introduce the iMA moving average indicator in mql4, the real problem is that i have not understood the mql5 array codes, how to implement them in mql4, below are the codes
if(MA_RED[3] > MA_YEL[3] && MA_RED[1] < MA_YEL[1] && MA_RED[0] < MA_YEL[0] && MACD[1] < 0)
only this above line i dont know how to make it work in mql4
hope i get help :)
if(MA_RED[3] > MA_YEL[3] && MA_RED[1] < MA_YEL[1] && MA_RED[0] < MA_YEL[0] && MACD[1] < 0)
double MA_RED[4], MA_YEL[4], MACD[4]; // Arrays must have a size. : void OnTick(){ for(int iBar=0; iBar <= 3; iBar++){ MA_RED[iBar] = iMA(NULL, 0, MA_RED_PERIOD, 0, MODE_EMA, PRICE_CLOSE, iBar); MA_YEL[iBar] = iMA(NULL, 0, MA_YEL_PERIOD, 0, MODE_EMA, PRICE_CLOSE, iBar); MACD[iBar] = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, iBar); } if(MA_RED[3] > MA_YEL[3] && MA_RED[1] < MA_YEL[1] && MA_RED[0] < MA_YEL[0] && MACD[1] < 0)
iMA() returns a double not an int . . . read the mql4 help in MetaEditor
Looks to me like the integer ma_red_handle is a pointer, not related to the return value type of of the iMA. I am assuming ...while knowing very little about mql5 pointers/handles, perhaps it is supposed to be an integer ...

- 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
first of all, thanks for reading this article,
this code i have taken from a mql5 EA, in this EA moving average indicator is used, and i am fascinated by its use,
i want to try it in mt4