ICustom Question

 

I've been trying to import values from an indicator into my EA, without success. iCustom imports values stored in buffers 0,1,2,3 etc. from an indicator. So far, these values are either 0.00000 or 2147483647.00000 ( empty value). I've tried adding additional buffers to the indicator and assigning the values, I need, which are realized from within the code, in hopes of bringing them into my EA, with no luck. Just get the same two values. Am I doing something wrong or missing something? Any advise would be greatly appreciated!

Thanks!

 

https://www.mql5.com/en/forum/173108

Yellowbeard:
I've been trying to import values from an indicator into my EA, without success. iCustom imports values stored in buffers 0,1,2,3 etc. from an indicator. So far, these values are either 0.00000 or 2147483647.00000 ( empty value). I've tried adding additional buffers to the indicator and assigning the values, I need, which are realized from within the code, in hopes of bringing them into my EA, with no luck. Just get the same two values. Am I doing something wrong or missing something? Any advise would be greatly appreciated! Thanks!

Try reading this post for a start.....

https://www.mql5.com/en/forum/173108

https://www.mql5.com/en/forum/173589

 
Yellowbeard:
I've been trying to import values from an indicator into my EA, without success. iCustom imports values stored in buffers 0,1,2,3 etc. from an indicator. So far, these values are either 0.00000 or 2147483647.00000 ( empty value). I've tried adding additional buffers to the indicator and assigning the values, I need, which are realized from within the code, in hopes of bringing them into my EA, with no luck. Just get the same two values. Am I doing something wrong or missing something? Any advise would be greatly appreciated! Thanks!

Usuallu when you get 0 it means that there is a problem with an iCustom call (wrong custom indicator name or some of the parameters). When you get an empty value as an answer, then usually you are referring to the wrong buffer

 

Here is how I've used iCustom to call the values of the buffers into my EA.

double Zigzag = iCustom(NULL,0,"ZigZag",0,0); //---- ZigzagBuffer[]

double ExtHigh = iCustom(NULL,0,"ZigZag",1,0); //---- HighBuffer[];

double ExtLow = iCustom(NULL,0,"ZigZag",2,0); //---- LowBuffer[]

double WhatlookFor = iCustom(NULL,0,"ZigZag",3,0); //---- whatlookforBuffer[]

These have produced either 0.00000 or 2147483647.00000. Do these seem to be the right use of iCustom?

 
Yellowbeard:
Here is how I've used iCustom to call the values of the buffers into my EA.

double Zigzag = iCustom(NULL,0,"ZigZag",0,0); //---- ZigzagBuffer[]

double ExtHigh = iCustom(NULL,0,"ZigZag",1,0); //---- HighBuffer[];

double ExtLow = iCustom(NULL,0,"ZigZag",2,0); //---- LowBuffer[]

double WhatlookFor = iCustom(NULL,0,"ZigZag",3,0); //---- whatlookforBuffer[]

These have produced either 0.00000 or 2147483647.00000. Do these seem to be the right use of iCustom?

Yellowbeard

zig zag has only 3 buffers (not 4)

Anyway, the easiest way to find out what is zig zag showing for current bar (you are using 0 in a shift parameter so I assume that you want to test the current bar zig zag state) would be something like this :

double Zigzag = iCustom(NULL,0,"ZigZag",0,0); //---- ZigzagBuffer[]

if (Zigzag!=0)

if (Zigzag==High[0])

// code for upper leg end

else // code for lower leg end

So, all you have to test if the first buffer is different from zero

 

I added this buffer. double WhatlookFor = iCustom(NULL,0,"ZigZag",3,0); //---- whatlookforBuffer[] It returns (-1) for High and (1) for Low. This buffer is returning correct value. The other three 0.00000 each.

Thanks!

 

There are other values, such as lasthigh, lastlow, curhigh and curlow. I've added additional buffers to try and bring these values into my EA. With no luck. Is there another way to accomplish this. Or am I just not using iCustom right.

 
Yellowbeard:
There are other values, such as lasthigh, lastlow, curhigh and curlow. I've added additional buffers to try and bring these values into my EA. With no luck. Is there another way to accomplish this. Or am I just not using iCustom right.

Yellowbeard

With iCustom() you can access only buffer values - you can not access values of internal variables

 

Can I create additional buffers within the indicator? Assign the values to the buffers, then, call them into my EA via iCustom?

 
Yellowbeard:
Can I create additional buffers within the indicator? Assign the values to the buffers, then, call them into my EA via iCustom?

Yellowbeard

Yes. And now with new metatrader 4, you can have up to 512 buffers (with iCustom() you can read a value from a buffer that is not drawn on chart too)

 

So how do I get the value of, like say, ZigzagBuffer[], which is set at index 0, when it's value is determined within a series of loops within the code and based on a variety of conditions. Then is reset to 0. I can assign it's value to a variable ( ZigzagBuff = ZigzagBuffer; ) to bring the value out of the loop. Insert an Alert outside the series of loops ( Alert("OUT ZigzagBuffer = ",DoubleToStr(ZigzagBuff,Digits)); ) and presto I have my value. But, try and call the value of ZigzagBuffer with ( double Zigzag = iCustom(NULL,0,"ZigZag",0,0); //---- ZigzagBuffer[] ) and I get 0.000000. The only other option that I could try is to write the value to a file, when it occurs, within the indicator and the read it into my EA. Not sure if this would be the most practical way to solve this.

Reason: