Hi all,
I'm trying to collect the return values from a function a put them into array.
I've the doubt if it make sense to collect the values in the function itself or outside?
On the other hand once the values are collected they can be used in array function (as arraymax) right?
this is the function code:
thank you in advance for the insights.
best
André
Declaration of the Array depends on what you want to use it with; Declaring it inside or outside a function will change its Scope.
Yes, these Array Related Functions can access Array Values; as long as they are visible where the Function Call is made.
Declaration of the Array depends on what you want to use it with; Declaring it inside or outside a function will change its Scope.
Yes, these Array Related Functions can access Array Values; as long as they are visible where the Function Call is made.
Thank you Jeremie.
I have been trying to call the function from into another an arraymax function but i've been struggling to add the past values.
I think as the code is (yellow background), i'm only collecting the current value in the array, correct?
If i try to include the (i), it return an error - Wrong parameters count
Crossed1(i);
int ArrayCalcMax() { int bars = 5; int malookback=bars; double madaily[5]; double dllv; for(int i = 0; i < malookback; i++) madaily[i] = Crossed1(); Print(" array[",i,"] = ",madaily[i]); int maxPos = ArrayMaximum(madaily,malookback,0); // Check the "maxPos" to make sure it is in range as it could be "-1" if it fails Print(" maxPos = ", maxPos ); if( maxPos >= 0 ) { dllv = madaily[maxPos]; // Please note that "dllv" is a local variable that will be discarded as soon as you return Print(" dllv = ", dllv ); } else Print("Something is wrong!"); return(dllv); }
Any thoughts?
Best
André
Hi again,
The error on the array function is solved, it was missing the { } after the for settence.
Nonetheless the value doesn't store in the next calculation:
17:10:44.622 2019.08.23 12:20:00 BBReverse V1 EURUSD,H4: array[0] = 1 17:10:44.622 2019.08.23 12:20:00 BBReverse V1 EURUSD,H4: array[1] = 0 17:10:44.622 2019.08.23 12:20:00 BBReverse V1 EURUSD,H4: array[2] = 0 17:10:44.622 2019.08.23 12:20:00 BBReverse V1 EURUSD,H4: array[3] = 0 17:10:44.622 2019.08.23 12:20:00 BBReverse V1 EURUSD,H4: array[4] = 0 17:10:44.622 2019.08.23 12:20:00 BBReverse V1 EURUSD,H4: maxPos = 0 17:10:44.622 2019.08.23 12:20:00 BBReverse V1 EURUSD,H4: dllv = 1
the result for the array [1] should be 1 but appears the value zero.
17:10:44.622 2019.08.23 12:40:00 BBReverse V1 EURUSD,H4: array[0] = 0 17:10:44.622 2019.08.23 12:40:00 BBReverse V1 EURUSD,H4: array[1] = 0 17:10:44.622 2019.08.23 12:40:00 BBReverse V1 EURUSD,H4: array[2] = 0 17:10:44.622 2019.08.23 12:40:00 BBReverse V1 EURUSD,H4: array[3] = 0 17:10:44.622 2019.08.23 12:40:00 BBReverse V1 EURUSD,H4: array[4] = 0 17:10:44.622 2019.08.23 12:40:00 BBReverse V1 EURUSD,H4: maxPos = 0 17:10:44.622 2019.08.23 12:40:00 BBReverse V1 EURUSD,H4: dllv = 0
Thanks André
Anyone?? really stuck here. :(
https://www.mql5.com/en/docs/basis/function/parameterpass
- www.mql5.com
Thank you both for the tips.
I've been able to solve the issue.
Best
André
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all,
I'm trying to collect the return values from a function a put them into array.
I've the doubt if it make sense to collect the values in the function itself or outside?
On the other hand once the values are collected they can be used in array function (as arraymax) right?
this is the function code:
thank you in advance for the insights.
best
André