How to find 'Calling Method' to an indicator class !!!

 

Dear Fellows

Greetings. I have created an indicator class and following methods are defined to get value on single index bar.

//+-----------------------------------------------------------------------------------------------------------------------------+
//| METHOD:                     GetIndexTSV()
//| APPLICATION:  To return TSV value at specified index
//+-----------------------------------------------------------------------------------------------------------------------------+
double CiTSV::GetIndexTSV(int pIndex) {

          double arrayData[1];                                                                                                                                  // LOCAL STATIC BUFFER TO RETURN SINGLE INDEX VALUE

                ResetLastError();
          if(CopyBuffer(mHandleTSV,0,pIndex,1,arrayData) < 1) {                 // Indicator bufferNo for TSV = 0
      string vMethod = "[" + mSymbol + "," + EnumToString(mTimeFrame) + "] " + __FUNCTION__;
            PrintFormat("%s ErrorLog[#%i] getting iTSV BufferTSV Index[%i]",vMethod,GetLastError(),pIndex);
            return(0);
          }

        return(NormalizeDouble(arrayData[0],0));                                                                        // instead of returning 'int' value, 'double' rounded to ZeroDigit

} // END Of method GetIndexTSV()
//+-----------------------------------------------------------------------------------------------------------------------------+
//| METHOD:                     GetIndexEMA()
//| APPLICATION:  To return EMA of TSV at specified index
//+-----------------------------------------------------------------------------------------------------------------------------+
double CiTSV::GetIndexEMA(int pIndex) {

          double arrayData[1];                                                                                                                                  // LOCAL STATIC BUFFER TO RETURN SINGLE INDEX VALUE

                ResetLastError();
          if(CopyBuffer(mHandleTSV,2,pIndex,1,arrayData) < 1) {                 // Indicator bufferNo for TSV EMA = 2
      string vMethod = "[" + mSymbol + "," + EnumToString(mTimeFrame) + "] " + __FUNCTION__;
            PrintFormat("%s ErrorLog[#%i] getting iTSV BufferEMA Index[%i]",vMethod,GetLastError(),pIndex);
            return(0);
          }

        return(NormalizeDouble(arrayData[0],0));                                                                        // instead of returning 'int' value, 'double' rounded to ZeroDigit

} // END Of method GetIndexEMA()

I am now getting following error, which I now is caused by calling -1 index. How can I identify (or find out the calling method to this, e.g. __FUNCTION__).

Since this call is made from multiple methods, I am not sure which one is causing the issue. Hope there is a way to find out!!!

2023.10.01 18:08:11.795 iVSA CPatterns (US30,H1)        [US30,PERIOD_H1] CiTSV::GetIndexTSV ErrorLog[#4806] getting iTSV BufferTSV Index[-1]
2023.10.01 18:08:11.795 iVSA CPatterns (US30,H1)        [US30,PERIOD_H1] CiTSV::GetIndexEMA ErrorLog[#4806] getting iTSV BufferEMA Index[-1]
 
Check the index before call the method.
 
Samuel Manoel De Souza #:
Check the index before call the method.

Hi Samuel

I did not get what you mean!!!

 

You added a Print inside the method. Instead, add prints before you call the method (outside).

Or use the debugger to step outside.

 
William Roeder #:

You added a Print inside the method. Instead, add prints before you call the method (outside).

Or use the debugger to step outside.

@William Roeder Thanks man

I will try these methods, for now however I did find it by running each of my method separately.