You can't "extract" double array from your struct array.
If you want to fill field Fastest in each struct in your array, you will have to declare helper array in your function, fill that array with CopyBuffer and then copy those values into the struct array.
Something like this:
Code is not tested, but you should get the idea.
Hi Drazen
I have tried it and works well ...
It also gave me opportunity to Normalize the out values to a specified digits, which I was not able to do earlier in CopyBuffer().
bool Ci_VWMACD::Get_Data(int pBarCount,struct_VWMACD &pVWMACD[])
{
if(m_Handle == INVALID_HANDLE)
Init_Handle();
//--- Array to be filled and returned with Volume Weighted MACD valuesdouble pMACDOsMA[], pMACDMain[], pMACDSignal[];
ArrayResize(pMACDOsMA,pBarCount+1);
ArrayResize(pMACDMain,pBarCount+1);
ArrayResize(pMACDSignal,pBarCount+1);
ArraySetAsSeries(pMACDOsMA,true);
ArraySetAsSeries(pMACDMain,true);
ArraySetAsSeries(pMACDSignal,true);
//--- Copy Buffer values from Custom Indicator "iFx VWMACD"ResetLastError();
if(!CopyBuffer(m_Handle,0,m_BarStart,pBarCount,pMACDOsMA) ||
!CopyBuffer(m_Handle,2,m_BarStart,pBarCount,pMACDMain) ||
!CopyBuffer(m_Handle,3,m_BarStart,pBarCount,pMACDSignal))
{
Print(__FUNCTION__,": FAILED Copy Buffers from Ci_VWMACD handle. Error Code ",GetLastError());
return(false);
}
//--- XXXXArrayResize(pVWMACD,pBarCount+1);
ArraySetAsSeries(pVWMACD,true);
for(int i = m_BarStart; i < pBarCount; i++)
{
pVWMACD[i].OsMA = NormalizeDouble(tempOsMA[i],5);
pVWMACD[i].Main = NormalizeDouble(tempMain[i],5);
pVWMACD[i].Signal = NormalizeDouble(tempSignal[i],5);
}
ArrayFree(pMACDOsMA);
ArrayFree(pMACDMain);
ArrayFree(pMACDSignal);
//---return(true);
} // END Of Get_Data() method
Yes, but you should think about Alain's suggestion because you now use CopyBuffer to copy data into temporary arrays, and then you copy that data into array of struct - you move the same data two times.
Measure the performance. If it is slow, then consider struct of arrays that Alain suggested.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
You can't "extract" double array from your struct array.
If you want to fill field Fastest in each struct in your array, you will have to declare helper array in your function, fill that array with CopyBuffer and then copy those values into the struct array.
Something like this:
Code is not tested, but you should get the idea.
Hi Drazen
I have tried it and works well ...
It also gave me opportunity to Normalize the out values to a specified digits, which I was not able to do earlier in CopyBuffer().
Hi Drazen
I have tried it and works well ...
Yes, but you should think about Alain's suggestion because you now use CopyBuffer to copy data into temporary arrays, and then you copy that data into array of struct - you move the same data two times.
Measure the performance. If it is slow, then consider struct of arrays that Alain suggested.