How to find error, when GetErrorCode returns 0!!!

 

Hi

I have created an indicator class and when run it on a testing EA, following methods returns correct values:

double CiPivots::GetIndexPivots(int pBuffer,int pIndex) {

                string vMethod = "[" + mSymbol + "," + EnumToString(mPivotTimeFrame) + "] " + __FUNCTION__;
                double arrayData[1];                                                                                                    // LOCAL STATIC BUFFER TO RETURN SINGLE INDEX VALUE

                if(CopyBuffer(mHandlePivots,pBuffer,pIndex,1,arrayData) == -1) {
                        ResetLastError();
                  PrintFormat("%s: Error[#%i] getting iPivots for _buffer[#%i] value at Index[%i]",vMethod,GetLastError(),pBuffer,pIndex);
                  return(0.00);
                }
                return(NormalizeDouble(arrayData[0],mDigits));

} // END Of method GetIndexPivots()
2023.09.11 15:53:12.200 US30,Daily: testing of Experts\AlgoBulls\EAdvisors\TestAdvisors\EA iPivots.ex5 from 2023.09.01 00:00 to 2023.09.11 00:00 started
2023.09.11 15:53:12.261 2023.09.01 01:00:00   [US30,PERIOD_D1] OnTick [2023.09.01 00:00] CPR Top[34806.6] Pivot[34861.1] Bottom[34915.7]
2023.09.11 15:53:12.271 2023.09.04 01:00:00   [US30,PERIOD_D1] OnTick [2023.09.04 00:00] CPR Top[34824.0] Pivot[34834.7] Bottom[34845.3]
2023.09.11 15:53:12.278 2023.09.05 01:00:00   [US30,PERIOD_D1] OnTick [2023.09.05 00:00] CPR Top[34811.9] Pivot[34829.1] Bottom[34846.3]
2023.09.11 15:53:12.288 2023.09.06 01:00:00   [US30,PERIOD_D1] OnTick [2023.09.06 00:00] CPR Top[34697.3] Pivot[34732.9] Bottom[34768.4]
2023.09.11 15:53:12.297 2023.09.07 01:00:00   [US30,PERIOD_D1] OnTick [2023.09.07 00:00] CPR Top[34460.6] Pivot[34476.1] Bottom[34491.6]
2023.09.11 15:53:12.307 2023.09.08 01:00:00   [US30,PERIOD_D1] OnTick [2023.09.08 00:00] CPR Top[34498.3] Pivot[34474.9] Bottom[34451.4]

However when I am using it in an another class it keeps returning error 0. I have checked there is no error of indicator handle (INVALID_HANDLE)

Any clues how can I find out what is going wrong!!!

Thanks in advance.

'periodD1' is from custom ENUM_TIMEFRAMES and on buffer no 4,5,6 have been called.

2023.09.11 15:48:38.132 iVSA (US30,H1)  [US30,periodD1] CiPivots::GetIndexPivots: Error[#0] getting iPivots for _buffer[#4] value at Index[6]
2023.09.11 15:48:38.132 iVSA (US30,H1)  [US30,periodD1] CiPivots::GetIndexPivots: Error[#0] getting iPivots for _buffer[#5] value at Index[6]
2023.09.11 15:48:38.132 iVSA (US30,H1)  [US30,periodD1] CiPivots::GetIndexPivots: Error[#0] getting iPivots for _buffer[#6] value at Index[6]
2023.09.11 15:48:38.132 iVSA (US30,H1)  [US30,periodD1] CiPivots::GetIndexPivots: Error[#0] getting iPivots for _buffer[#4] value at Index[5]
2023.09.11 15:48:38.132 iVSA (US30,H1)  [US30,periodD1] CiPivots::GetIndexPivots: Error[#0] getting iPivots for _buffer[#5] value at Index[5]
2023.09.11 15:48:38.132 iVSA (US30,H1)  [US30,periodD1] CiPivots::GetIndexPivots: Error[#0] getting iPivots for _buffer[#6] value at Index[5]
2023.09.11 15:48:38.132 iVSA (US30,H1)  [US30,periodD1] CiPivots::GetIndexPivots: Error[#0] getting iPivots for _buffer[#4] value at Index[4]
2023.09.11 15:48:38.132 iVSA (US30,H1)  [US30,periodD1] CiPivots::GetIndexPivots: Error[#0] getting iPivots for _buffer[#5] value at Index[4]
2023.09.11 15:48:38.132 iVSA (US30,H1)  [US30,periodD1] CiPivots::GetIndexPivots: Error[#0] getting iPivots for _buffer[#6] value at Index[4]
2023.09.11 15:48:38.132 iVSA (US30,H1)  [US30,periodD1] CiPivots::GetIndexPivots: Error[#0] getting iPivots for _buffer[#4] value at Index[3]
2023.09.11 15:48:38.132 iVSA (US30,H1)  [US30,periodD1] CiPivots::GetIndexPivots: Error[#0] getting iPivots for _buffer[#5] value at Index[3]
2023.09.11 15:48:38.132 iVSA (US30,H1)  [US30,periodD1] CiPivots::GetIndexPivots: Error[#0] getting iPivots for _buffer[#6] value at Index[3]
2023.09.11 15:48:38.132 iVSA (US30,H1)  [US30,periodD1] CiPivots::GetIndexPivots: Error[#0] getting iPivots for _buffer[#4] value at Index[2]
2023.09.11 15:48:38.132 iVSA (US30,H1)  [US30,periodD1] CiPivots::GetIndexPivots: Error[#0] getting iPivots for _buffer[#5] value at Index[2]
2023.09.11 15:48:38.132 iVSA (US30,H1)  [US30,periodD1] CiPivots::GetIndexPivots: Error[#0] getting iPivots for _buffer[#6] value at Index[2]
2023.09.11 15:48:38.132 iVSA (US30,H1)  [US30,periodD1] CiPivots::GetIndexPivots: Error[#0] getting iPivots for _buffer[#4] value at Index[1]
2023.09.11 15:48:38.132 iVSA (US30,H1)  [US30,periodD1] CiPivots::GetIndexPivots: Error[#0] getting iPivots for _buffer[#5] value at Index[1]
2023.09.11 15:48:38.132 iVSA (US30,H1)  [US30,periodD1] CiPivots::GetIndexPivots: Error[#0] getting iPivots for _buffer[#6] value at Index[1]
2023.09.11 15:48:38.132 iVSA (US30,H1)  [US30,periodD1] CiPivots::GetIndexPivots: Error[#0] getting iPivots for _buffer[#4] value at Index[0]
2023.09.11 15:48:38.132 iVSA (US30,H1)  [US30,periodD1] CiPivots::GetIndexPivots: Error[#0] getting iPivots for _buffer[#5] value at Index[0]
2023.09.11 15:48:38.132 iVSA (US30,H1)  [US30,periodD1] CiPivots::GetIndexPivots: Error[#0] getting iPivots for _buffer[#6] value at Index[0]
2023.09.11 15:48:38.132 iVSA (US30,H1)  [US30,PERIOD_H1] CScanVSA::UpdateData [2023.09.11 12:00] ArraySize[8] CPR[0].top[0.0] CPR[0].pivot[0.0] CPR[0].bottom[0.0]
 
double CiPivots::GetIndexPivots(int pBuffer,int pIndex) {

                string vMethod = "[" + mSymbol + "," + EnumToString(mPivotTimeFrame) + "] " + __FUNCTION__;
                double arrayData[1];                                                                                                    // LOCAL STATIC BUFFER TO RETURN SINGLE INDEX VALUE

                if(CopyBuffer(mHandlePivots,pBuffer,pIndex,1,arrayData) == -1) {
                        ResetLastError();
                  PrintFormat("%s: Error[#%i] getting iPivots for _buffer[#%i] value at Index[%i]",vMethod,GetLastError(),pBuffer,pIndex);
                  return(0.00);
                }
                return(NormalizeDouble(arrayData[0],mDigits));

} // END Of method GetIndexPivots()


You are resetting error code to zero before printing. 

Use code styler or manually fix indentation and it will be easier to spot potential problems.

 
Drazen Penic #:


You are resetting error code to zero before printing. 

Use code styler or manually fix indentation and it will be easier to spot potential problems.

Thanks a lot @Drazen Penic

It was really a silly mistake by me.

I have moved ResetLastError() above if(CopyBuffer) and get the error code now.

Ragards