First, fix your broken code; CopyBuffer does not return a boolean. Your test will not show a failure.
double CMyClass::MACDGet(const int buffer, const int index) { double MACD_buffer[]; ArraySetAsSeries(MACD_buffer,true); //--- reset error code ResetLastError(); //--- fill a part of the MACD array with values from the indicator buffer that has 0 index if(CopyBuffer(handle_MACD,buffer,index,1,MACD_buffer)<0) { //--- if the copying fails, tell the error code PrintFormat("Failed to copy data from the MACD indicator, error code %d",GetLastError()); //--- quit with zero result - it means that the indicator is considered as not calculated return(222); } return(MACD_buffer[0]); }
it returns "int" ...sorry about that !
yet still returns the same error 4806
what perplexes me is that the same function if I take it outside the class performs correctly as expected....
I am using it in OnTick event ...I suspect the tick frequency has something to do with the error !
You keep saying that, but your original code would not have printed anything, therefor your error must be elsewhere.
Forum on trading, automated trading systems and testing trading strategies
Alain Verleyen, 2020.04.23 03:11
That's a Justin Mcridge issue.
PrintFormat(" Point :%d",m_symbol.Point());
Read the documentation please. You are using %d all over to print double value. %d is for an INT !
Possible you have the same issue.
And even in your other topic https://www.mql5.com/en/forum/338056
![unexplained return of a simple function unexplained return of a simple function](https://c.mql5.com/36/34/unexplained-return-of-a-simple.jpg)
- 2020.04.20
- www.mql5.com
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
CopyBuffer unexpected results!!
this seemingly sound code gives a reading error
MACD =432932703