It is when you use an invalid call that doesn't even compile | iMA - Technical Indicators - MQL4 Reference | |
---|---|---|
iMA( NULL, 0, 0, 0, MODE_SMA, PRICE_CLOSE >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ) | double iMA( string symbol, // symbol int timeframe, // timeframe int ma_period, // MA averaging period int ma_shift, // MA shift int ma_method, // averaging method int applied_price, // applied price int shift // shift ); |

- docs.mql4.com
hello,
I'm just going step by step through an introducaton by a good russian expert how to build an EA.
Now, I'm used to MT4 only. How do I get the values of a custom indicator(let's say Bar 0) --- in an EA? (and an indicator displayed)
Since it's sunday and no real time data at the moment I put
int OnInit()
{Comment("ABC"); return(INIT_SUCCEEDED); the comment function works like in MT4 > shows "ABC"
} but when I replace ABC by iMA(NULL,0,0,0,MODE_SMA,PRICE_CLOSE) the comment shows "-1" which can't be a value of this MA!
I finally want to replace this iMA by a custom indicator (which I already have in MT5 and it works)
The design is basically: iCustom(NULL,0,"custom name",paramterNr1,Nr2,3,4,Nr5,0,0); in MT4 the last 0 adresses the BAR and the one before that the buffer
my custom indicator has 3 buffers(0-2), I need buffer 1 and 2 for EA signals
If anyone knows how to solve it thanks in advance
you can read the iCustom section or iMA section
you have to ensure the indicator input sequence are correct, the last 2 input is indicator buffer and bar index
iCustom(NULL,0,"custom name",paramterNr1,Nr2,3,4,Nr5,0,0)
- whroeder1:
It is when you use an invalid call that doesn't even compile iMA - Technical Indicators - MQL4 Reference iMA(
NULL,
0,
0, // Zero period?
0,
MODE_SMA,
PRICE_CLOSE
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
)double iMA(
string symbol, // symbol
int timeframe, // timeframe
int ma_period, // MA averaging period
int ma_shift, // MA shift
int ma_method, // averaging method
int applied_price, // applied price
int shift // shift
); - Detailed explanation of iCustom - MQL4 forum
well, thanks for the fast feedback, folks, but
in MT4
Comment( iMA(NULL,0,13,8,MODE_SMMA,PRICE_MEDIAN,0)); works ... and it shows the value of the MA
whereas in MT 5 (same code copied) I get "worng parameters count" ?? and that indicator is a default one..
--
after I get this resolved I'd like to adress and check/ show by comment function the value of my custom indicator
iCustom(NULL,0,"custom name",paramterNr1,Nr2,3,4,Nr5,0,0); in MT5!! (since I got those things in MT4 for a long time)

- www.mql5.com
Of course it does. MT5 isn't the same. RTFM Technical Indicators / iMA - Reference on algorithmic/automated trading language for MetaTrader 5 OnInit creates a MA handle and OnCalculate uses it.
Of course it does. MT5 isn't the same. RTFM Technical Indicators / iMA - Reference on algorithmic/automated trading language for MetaTrader 5 OnInit creates a MA handle and OnCalculate uses it.
so should one use this part of the manual ("The function returns the handle of the Moving Average indicator") in the declaration part of the EA (MT5)?
int iMA(
string symbol, // symbol name
etc......
ENUM_APPLIED_PRICE applied_price // type of price or handle
);
and then using the command
iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE)
in the OnTick() part to adress it brings "function must have a body" = error ??
fxnew5: and then using the command
| What part of "MA handle and OnCalculate uses it," was unclear? |
Thanks WH, but does one have to integrate - the complete - code on https://www.mql5.com/en/docs/indicators/ima
i.e. from "Example" downward..?
in a new MT5 EA to use (or adress) the simple iMA function?
I doubt it, cause that would be really cumbersome compared to the iCustom use in MT4 where you only got to have the function in the specific indicator folder and then use
the iCustom(xxxxx) properly to adress the parameter you want to retrieve in an MT4 EA...

- www.mql5.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hello,
I'm just going step by step through an introducaton by a good russian expert how to build an EA.
Now, I'm used to MT4 only. How do I get the values of a custom indicator(let's say Bar 0) --- in an EA? (and an indicator displayed)
Since it's sunday and no real time data at the moment I put
int OnInit()
{Comment("ABC"); return(INIT_SUCCEEDED); the comment function works like in MT4 > shows "ABC"
} but when I replace ABC by iMA(NULL,0,0,0,MODE_SMA,PRICE_CLOSE) the comment shows "-1" which can't be a value of this MA!
I finally want to replace this iMA by a custom indicator (which I already have in MT5 and it works)
The design is basically: iCustom(NULL,0,"custom name",paramterNr1,Nr2,3,4,Nr5,0,0); in MT4 the last 0 adresses the BAR and the one before that the buffer
my custom indicator has 3 buffers(0-2), I need buffer 1 and 2 for EA signals
If anyone knows how to solve it thanks in advance