Hi
The code below fails to do the second CopyBuffer and thus the rviSignalBuffer size is always zero. Is this compound condtion evaluation expression allowed? Thanks
if the 1st copying is good then it should do the 2nd copying since the 1st condition will evaluate to false thus forcing the 2nd condition evaluation, isn't that the case?
there is no sense in this phrase...
there is no sense in this phrase...
if the first condition "CopyBuffer" works, then this condition will evaluate to false, which is expected to activate the || "or" which will force the evaluatioin of the second "CopyBuffer" ;)
Hi
The code below fails to do the second CopyBuffer and thus the rviSignalBuffer size is always zero. Is this compound condtion evaluation expression allowed? Thanks
if the 1st copying is good then it should do the 2nd copying since the 1st condition will evaluate to false thus forcing the 2nd condition evaluation, isn't that the case?
Have you tested the two conditions separately? (at least to make sure that buffer number 1 exists...)
What is the GetLastError()? No harm moving the print statement out of the braces just for testing... to make sure there is no error during the second call to CopyBuffer.
Have you tested the two conditions separately? (at least to make sure that buffer number 1 exists...)
What is the GetLastError()? No harm moving the print statement out of the braces just for testing... to make sure there is no error during the second call to CopyBuffer.
Have you tested the two conditions separately? (at least to make sure that buffer number 1 exists...)
What is the GetLastError()? No harm moving the print statement out of the braces just for testing... to make sure there is no error during the second call to CopyBuffer.
The following code works fine i.e. I am able to get values from the second array (rviBuffer or rviSignalBuffer), no clue why the first did not...
Even when I used the first code, and switch the buffer arrays around, only the first buffer gets filled but not the second.
These buffers arrays are member variables of a class in a xxx.mqh file and no processor directive is used.
if(CopyBuffer(rviHandle, 0, 0, 3, rviBuffer) <= 0) { Print("could not copy rvi for ea2 ",GetLastError() ); } if(CopyBuffer(rviHandle, 1, 0, 3, rviSignalBuffer) <= 0) { Print("could not copy rvi for ea2 ",GetLastError() ); }
The following code works fine i.e. I am able to get values from the second array (rviBuffer or rviSignalBuffer), no clue why the first did not...
Even when I used the first code, and switch the buffer arrays around, only the first buffer gets filled but not the second.
These buffers arrays are member variables of a class in a xxx.mqh file and no processor directive is used.
Right... one last check - can you move your print statement outside of the 'if' body, and see if there's any error when the 2nd CopyBuffer is not copying anything?
As far as I understand, your code with double conditions looks legitimate. One possible explanation that I can think of, now, is that there is conflict of resource when "two CopyBuffers to the same indicator" are done that close together - bottleneck could be in how mql5 handles 'if' conditions, and how CopyBuffer handles the Indicators...
Right... one last check - can you move your print statement outside of the 'if' body, and see if there's any error when the 2nd CopyBuffer is not copying anything?
As far as I understand, your code with double conditions looks legitimate. One possible explanation that I can think of, now, is that there is conflict of resource when "two CopyBuffers to the same indicator" are done that close together - bottleneck could be in how mql5 handles 'if' conditions, and how CopyBuffer handles the Indicators...
Well, that will take some work since the Strategy tester does not allow printing. so to do a manual work around, I attached the code to the OnClick event, but will not compile with the following error
if(CopyBuffer(rviHandle, 0, 0, 3, rviBuffer) <= 0 || CopyBuffer(rviHandle, 1, 0, 3, rviSignalBuffer) <= 0 ) { } if(ArraySize(rviBuffer)<1){ // <<<<<<<<<<<<<<<<<<<<<<<<<< parameter conversion not allowed Print("rviBuffer size: ", ArraySize(rviBuffer) , " ",GetLastError() );// <<<<<<<<<<<<<<<<<<<<<<<<<< parameter conversion not allowed } if(ArraySize(rviSignalBuffer)<1){// <<<<<<<<<<<<<<<<<<<<<<<<<< parameter conversion not allowed Print("rviBuffer size: ", ArraySize(rviSignalBuffer) , " ",GetLastError() );// <<<<<<<<<<<<<<<<<<<<<<<<<< parameter conversion not allowed }
Well, that will take some work since the Strategy tester does not allow printing. so to do a manual work around, I attached the code to the OnClick event, but will not compile with the following error
if(CopyBuffer(rviHandle, 0, 0, 3, rviBuffer) <= 0 || CopyBuffer(rviHandle, 1, 0, 3, rviSignalBuffer) <= 0 ) {} Print(GetLastError() );
Try this will do... just a very quick check to see if there's any error... if there is, it must have resulted from the 2nd CopyBuffer , since you've said that the first CopyBuffer works.
Try this will do... just a very quick check to see if there's any error... if there is, it must have resulted from the 2nd CopyBuffer , since you've said that the first CopyBuffer works.
Update - I just did the same thing with iBands, and iCustom with the "Heiken_Ashi" indicator, and both works properly - no error and all arrays filled. Here's how i tested:
int handle = iCustom(Symbol(),0,"Examples\\Heiken_Ashi"); Print ("Get handle Error : ", GetLastError()); double Buf1[], Buf2[]; if (CopyBuffer(handle,1,0,7,Buf1)<=0 || CopyBuffer(handle,2,0,7,Buf2)<=0) {} Print ("Error : ", GetLastError()); for (int i=0; i<7; i++) Print ("i = ", IntegerToString(i), ", Buf1[] = ", Buf1[i], ", Buf2[] = ", Buf2[i]);
As such, the most likely culprit now is your rvi indicator...
Well, that will take some work since the Strategy tester does not allow printing. so to do a manual work around, I attached the code to the OnClick event, but will not compile with the following error
Please declare rviBuffer and rviSignalBuffer properly before you go on.
double rviBuffer[]; // <-- dynamic double array
Printing is not disabled in strategy tester, just open the right log.
This worked fine however I don't know why it is working now but did not later, I only removed the Print statemet.
if(CopyBuffer(rviHandle, 0, 0, 3, rviBuffer) <= 0 || CopyBuffer(rviHandle, 1, 0, 3, rviSignalBuffer) <= 0 ) {}
And yes, the dynamic double array has be declared in the class private variables.
- 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
The code below fails to do the second CopyBuffer and thus the rviSignalBuffer size is always zero. Is this compound condtion evaluation expression allowed? Thanks
if the 1st copying is good then it should do the 2nd copying since the 1st condition will evaluate to false thus forcing the 2nd condition evaluation, isn't that the case?