The answers to your questions are as follows:
-
No, you do not need to call m_open.Refresh() before signal.Open(0) when working within the Standard Library framework. The framework already ensures that the necessary series are refreshed.
-
Yes, CopyBuffer() always retrieves up-to-date data. However, once a refresh has been performed, GetData() is typically faster for repeated element access because it works directly with the internal buffers.
I hope this helps clarify the distinction, though please note this is based on my understanding and interpretation.
The answers to your questions are as follows:
-
No, you do not need to call m_open.Refresh() before signal.Open(0) when working within the Standard Library framework. The framework already ensures that the necessary series are refreshed.
-
Yes, CopyBuffer() always retrieves up-to-date data. However, once a refresh has been performed, GetData() is typically faster for repeated element access because it works directly with the internal buffers.
I hope this helps clarify the distinction, though please note this is based on my understanding and interpretation.
Looking at the code of Indicators::GetData, it already calls CopyBuffer internally.
// FROM StandardLib "Indicator.mqh" //+------------------------------------------------------------------+ //| API access method "Copying the buffer of indicator by specifying | //| a start position and number of elements" | //+------------------------------------------------------------------+ int CIndicator::GetData(const int start_pos,const int count,const int buffer_num,double &buffer[]) const { //--- check if(m_handle==INVALID_HANDLE) { SetUserError(ERR_USER_INVALID_HANDLE); return(-1); } if(buffer_num>=m_buffers_total) { SetUserError(ERR_USER_INVALID_BUFF_NUM); return(-1); } //--- return(CopyBuffer(m_handle,buffer_num,start_pos,count,buffer)); }
Therefore, I don't understand why the documentation recommends always calling indicator.Refresh() when working with indicator.GetData() (https://www.mql5.com/en/docs/standardlibrary/technicalindicators/cindicators/cindicator/cindicatorrefresh). That's confusing..
- www.mql5.com
Looking at the code of Indicators::GetData, it already calls CopyBuffer internally.
Therefore, I don't understand why the documentation recommends always calling indicator.Refresh() when working with indicator.GetData() (https://www.mql5.com/en/docs/standardlibrary/technicalindicators/cindicators/cindicator/cindicatorrefresh). That's confusing..
There are several GetData() method for CIndicator, and you are mixing them. The one the documentation is talking about is not the same as the one you posted the code. Check the function signatures.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
According to https://www.mql5.com/en/docs/standardlibrary/technicalindicators/cindicators/cindicator/cindicatorrefresh, it is recommended to always call Refresh() when retrieving data with GetData(). However, looking at the standard lib code (e.g., ExpertBase.mqh),it does not follow this pattern:
First Question: Does this mean, that I should I call m_open.Refresh() before calling signal.Open(0), e.g.:
Second Question: Am I right in saying that using CopyBuffer() eliminates the need to call Refresh()? If so, would the CopyBuffer() method be faster than the GetData() method?