Robert H.
Robert H.

Reputation: 3

iCustom function mql4

I have an mt4 indicator that shows values in the data window that I want to access. I only have the ex4 file and not the source code file mq4, Is it possible for me to access those data values using the mql4 iCustom function, and use them in a different indicator?

I used the iCustom funtion in a seperate indicator trying to get the data from the data window for a indicator called waves-indicator. I have no idea on how to set up the parameters of this function. The parameters I used did not make any errors when compiled, but I was not able to aquire the correct values. The mql4 manual's explaination is worthless for me. Help please.

Upvotes: 0

Views: 2459

Answers (3)

Mahdi Ahmadifard
Mahdi Ahmadifard

Reputation: 14

You could access indicators buffers value via iCustom function. In mql4 indicators having different array to save values for calculation and drawing. So, to gain the correct value you should now its buffer index. For instance, an Indicator name "Sample Indicator" has three lines each stored in three buffers, to access the first buffer value you should write:

double buffer1 = iCustom(Symbol , Period, "Sample Indicator", 0, 1 );

In the above code 0 is the index of the buffer and 1 is the shift of the value. If you want to change the input of the indicators you should palace its values between "Sample Indicators" and 0 in the above code. Keep in mind that you should set values based on the order they have in an inputs of the indicators.

Note that as you see iCustom return type is double so, for instance, if the buffer type is boolean it is automatically being converted to double. As a result, that could be the reason that for some buffers the numbers returned by the iCustom make no sense to you.

Upvotes: 0

agas tyahadi
agas tyahadi

Reputation: 1

This sample is using iCustom for Heiken Ashi and Half Trend Indicator

double HA = NormalizeDouble(iCustom(Symbol(),PERIOD_CURRENT,"Heiken Ashi",PERIOD_CURRENT,0,1),4);

or

double ha_open = iCustom(NULL, 0, "Heiken_Ashi", 0, 0);
double ha_close = iCustom(NULL, 0, "Heiken_Ashi", 0, 1);
double prev_ha_open = iCustom(NULL, 0, "Heiken_Ashi", 0, 2);
double prev_ha_close = iCustom(NULL, 0, "Heiken_Ashi", 0, 3);

other sample

double B1 = NormalizeDouble(iCustom(Symbol(),PERIOD_CURRENT,"Half Trend",0,0),4);
double B2 = NormalizeDouble(iCustom(Symbol(),PERIOD_CURRENT,"Half Trend",0,1),4);

you can find the information about how many indicator buffer that available, just check it in indicator.mq4 file like half trend.mq4:

IndicatorShortName("Half Trend");
IndicatorDigits(Digits);
IndicatorBuffers(7); // +1 buffer - trend[]

Upvotes: 0

Yasin İPEK
Yasin İPEK

Reputation: 70

enter image description here

 double value0=NormalizeDouble(iCustom(Symbol(),PERIOD_CURRENT,"indicatorName.ex4",0,1),Digits);
 double value1=NormalizeDouble(iCustom(Symbol(),PERIOD_CURRENT,"indicatorName.ex4",1,1),Digits);
 double value2=NormalizeDouble(iCustom(Symbol(),PERIOD_CURRENT,"indicatorName.ex4",2,1),Digits);

Upvotes: 0

Related Questions