please expose exact source! following program works properly
int start() { double d1, d2; if (MyFunc(d1,d2)) Print(d1, d2); } bool MyFunc(double& dRtn, double& dPerc) { dRtn = 10; dPerc = 20; return (true); }
int start() { double d1=1, d2=2, b[6]; b[0] = 10000; b[1] = 9000; b[2] = 8500; b[3] = 11000; b[4] = 8000; b[5] = 12000; MaxDrawDown(b, d1, d2); Print("TestDD: ", d1 , " - ", d2); } //+------------------------------------------------------------------+ double MaxDrawDown(double dVal[], double& dRtn, double& dPerc) { int nSize = ArraySize(dVal); int i; double diff, test; dRtn = 0; for (i=0; i < (nSize-1); i++) { test = dVal[i+1] - dVal[i]; if (test <= 0) diff = diff + test; else if (dRtn > diff) { dRtn = diff; dPerc = Div(MathAbs(diff),dVal[i]+MathAbs(diff))*100; diff = 0; } else { diff = 0; } Print("Diff: ", diff); } dRtn = MathAbs(dRtn); Print("MaxDrawDown: ", dRtn, " : ", dPerc); return (dRtn); }
Ok the above code works as intended.
What I have done is created a library file and put the MaxDrawdown function in it. Then create a library include file which imports the library.ex4 file and exposes the function definition.
Then in the script I include the library include file.
Doing it this way the function does not return the correct values
Your help on this is greatly appreciated.
Pedro
works properly
16:09:06 Expert test: loaded successfully 16:09:06 Expert 'test' (,) : Diff: -1000 16:09:06 Expert 'test' (,) : Diff: -1500 16:09:06 Expert 'test' (,) : Diff: 0 16:09:06 Expert 'test' (,) : Diff: -3000 16:09:06 Expert 'test' (,) : Diff: 0 16:09:06 Expert 'test' (,) : MaxDrawDown: 3000 : 27.2727 16:09:06 Expert 'test' (,) : TestDD: 3000 - 27.2727 16:09:06 Expert 'test' (,) : removed
what the build do You use?
Hi Slawa,
Can I confirm that you created a library with the MaxDrawDown function in it. Created a Include file importing the library and having the definition of MaxDrawDown. Then creating a script including the library include file and calling MaxDrawDown from their. When I do this it fails. The function works correctly but the variables passed into the function when returned are as their original values.
I am using Build 171
Thanks
Can I confirm that you created a library with the MaxDrawDown function in it. Created a Include file importing the library and having the definition of MaxDrawDown. Then creating a script including the library include file and calling MaxDrawDown from their. When I do this it fails. The function works correctly but the variables passed into the function when returned are as their original values.
I am using Build 171
Thanks
yes. we are redesigning our compiler now. it will be ready in 2-3 month time
Thanks Slawa,
Great news. Keep up the good work.
Pedro
Great news. Keep up the good work.
Pedro
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I think this was working prior to the last update, but I really need to understand what is possible when declaring functions.
So I expect that when this is declared by defining the variable type with & is means the address of the variable enabling to the ability to set its values ie.
so the values for d1 would be 10 and d2 would be 20. But when I do this both d1 & d2 are equal to 0
I know it works for passing arrays as I am currently doing this.
Is this a bug or is it just not possible?
Pedro