How to debug a Custom Indicator

 

Hello,

I programmed a custom indicator

int start()
  {
   int    limit;
   int    counted_bars=IndicatorCounted();
    //---- check for possible errors
   if(counted_bars<0) return(-1);
   //---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
     
   for(int k=0; k<limit; k++) 
   {
//..... calculation the values with iBands in a for-loop: for (int i=1;i<=G;i++)

    SumBuffer[k]  = ...
    Sum2Buffer[k] = ...
   }
   }

But when I put the indicator on my underlying I get always the same value for my indicator. (I know that the calculation works, because I use it in my EA).

How can I find the error? I can't use the Print-function here, or?

 

You can use Print() even in an indicator. The only problem with Print() is when there is printed too much in a short time it will be delayed and generally the output of Print() in the experts log is not very easy to follow.


For solving this annoyance of Print() I have done the following: http://www.forexfactory.com/showthread.php?p=3866205#post3866205

It is also part of the free common_functions function library.