MQL4 and iCustom with large number of bars

 
I wrote an EA and I use
iCustom

function to get information from an external indicator. The problem arises when I've to get information of the las 30 bars or more. So, I write:

double rm00 = iCustom(.....)
double rm01 = iCustom(.....)
(...)
double rm030 = iCustom(....)

 if the indicator has more than 1 line drawn, I've to repeat the operation above twice or even more times.

Is there a way to prevent this and make a shorter code? Or I have to declare each value indepentdenly as I do? 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Indicator Constants / Drawing Styles
  • www.mql5.com
Standard Constants, Enumerations and Structures / Indicator Constants / Drawing Styles - Documentation on MQL5
 

Hello Felix,

Your question is about mql4 programming  so it is better placed   at     mql4.com 

I think your question is not clear enough, to know what you mean.....   so it will be hard to answer

 

About iCustom

 

double iCustom( string symbol, int timeframe, string name, ..., int mode, int shift)

Calculates the specified custom indicator and returns its value. The custom indicator must be compiled (*.EX4 file) and be in the terminal_directory\experts\indicators directory.

Parameters:

symbol - Symbol the data of which should be used to calculate indicator. NULL means current symbol.
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe.
name - Custom indicator compiled program name.
... - Parameters set (if necessary). The passed parameters and their order must correspond with the desclaration order and the type of extern variables of the custom indicator.
mode - Line index. Can be from 0 to 7 and must correspond with the index used by one of SetIndexBuffer functions.
shift - Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).

Sample:
  double val=iCustom(NULL, 0, "SampleInd",13,1,0);



You can say that in the sample the indicator is called 'SampleInd'  

It has one parameter you can fill in   '13'
val      gives the value of buffer[]   no '1' for bar '0'
     on the chart where the EA is attached   so the indicatorvalue is for chartSymbol   chart timeframe

If you wanna know the val of bar 10   then you have to take another  double  val_10 = iCustom.....

 
Timeframes - MQL4 Documentation
  • docs.mql4.com
Timeframes - MQL4 Documentation
 
fjesq:

Is there a way to prevent this and make a shorter code? Or I have to declare each value indepentdenly as I do? 

You could use an array instead and do this on one line of code . .
 
RaptorUK:
You could use an array instead and do this on one line of code . .

Thanks,

After looking to some codes, I thought that was the way. 

Reason: