vx0532:
I just want to get some value from Indicator "ZigZag" by iCustom(), but always fail
My EA code is as below: When I test it on history data and live data, iCustom() returns all 0; I don;t know why?
Examples here https://www.mql5.com/en/forum/144092.
You don't call the zigzag indicator. ???
sorry, In the fact, I copy codes of zigzag to test_Ind.
I have know the matter after view the post which is suggested by "buzen ".
I think the key point is that:
in Indicator, we can set array to receive the value returned by iCustom(); and In EA, we can't use array but variable to receive the value returned by iCustom(), since in EA if we use array x[i] to receive the return value, " buffers and you have to find value of i at what bar the top or bottom will be" said be by deVries at https://www.mql5.com/en/forum/144092/page2.
So I think iCustom not simply return one value but other somethings which can recognize what receive it.
if that, MT4 platform must take the responsibility to recognize iCustom() be used in EA or Indicator.
int i=100; while(i<100) // i==100 loop exits iCustom is NEVER called
while(i<100) { if(iCustom(NULL,0,"Test_Ind",12,5,3,1,i_0)!=0){ x[i_0]=iCustom(NULL,0,"Test_Ind",12,5,3,1,i_0);i_0++;}
What is the purpose of i when you don't use it in the loop?- Where are you resetting i_0 ...
- What is the purpose of i when you don't use it in the loop?
- Where are you resetting i_0 ...
sorry, int i=100; should be int i=0; now it is ok; and in EA array also can receive iCustom()'s return.
Thanks.
Now I know. In the fact the arrays, like x[], only can be used in Indicator not in EA;
iCustom()'s return value can be received by both double variable and double array, both in EA and Indicator; but if its return value should be received by double array, in EA the array should be the type "double x[n]; arrayinitialize(x,0.0); in Indicator the array should be the type "double x[]; SetIndexBuffer(0,x);" or "double x[n];"
sorry, int i=100; should be int i=0; now it is ok; and in EA array also can receive iCustom()'s return.
Thanks.
Now I know. In the fact the arrays, like x[], only can be used in Indicator not in EA;
No, that is not correct unless you are talking about a buffer ? there is a difference between buffers and arrays. You can declare an array such as x[] in an EA but you need to resize it before you use it otherwise it has zero elements.
thank you
so when we use array in EA, the array must be confirmed its size before its use; but in Indicator, that is an other story.
in the addition, in EA and Indicator shall we resize array, such as x[n]?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
My EA code is as below:
When I test it on history data and live data, iCustom() returns all 0; I don;t know why?