invalid integer number as parameter 2 for 'iCustom' function

 

Hi all, I created a simple indicator as the difference between the Stoch(5.3.3) and his signal line.

//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 1
#property  indicator_color1  PowderBlue
#property  indicator_width1  2


//---- indicator buffers
double    Histogram[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int init()
  {
//---- indicator buffers mapping
   SetIndexBuffer(0,Histogram);  

//---- drawing settings
   SetIndexStyle(0,DRAW_HISTOGRAM);

//---- line shifts when drawing

 
   // SetIndexDrawBegin(0,Periodo);
   IndicatorDigits(Digits+1);


//---- name for DataWindow and indicator subwindow label

 
   IndicatorShortName("Stoch_Difference");
   SetIndexLabel(0,"Stoch_Difference");

 

//---- initialization done

   // return(0);
  }

//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+

int start()
  {
   int limit;
   int counted_bars=IndicatorCounted(); 

//---- last counted bar will be recounted

   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;   

//---- calcolo entry_long 

   for(int i=0; i<limit; i++)
      Histogram[i] = iStochastic(NULL,0,5,3,3,MODE_SMA,STO_LOWHIGH,0,i)-iStochastic(NULL,0,5,3,3,MODE_SMA,STO_LOWHIGH,1,i) ;
   
   return(0);



//---- done

  }

 The indicator works well in his window, if I print the value I seem it's ok.

If I use the indicator in an expert as iCustom(NULL,0,"Stoch Difference",0,2) I obtain the error "invalid integer number as parameter 2 for 'iCustom' function".

Where is the problem? Thank you! 

 
Alberto_jazz: If I use the indicator in an expert as iCustom(NULL,0,"Stoch Difference",0,2) I obtain the error "invalid integer number as parameter 2 for 'iCustom' function".
  1. A compile error in an EA is a problem with the EA. Why show us the indicator code?
  2. Detailed explanation of iCustom - MQL4 forum
 

This is how I call the indicator in the expert 

double Stoch_Diff = iCustom(NULL,NULL,"Stoch Difference",0,1) ;

When I compile the expert I have no errors, but when I apply the expert to the chart I obtain "invalid integer number as parameter 2 for 'iCustom' function".

 
Alberto_jazz:

This is how I call the indicator in the expert 

double Stoch_Diff = iCustom(NULL,NULL,"Stoch Difference",0,1) ;

When I compile the expert I have no errors, but when I apply the expert to the chart I obtain "invalid integer number as parameter 2 for 'iCustom' function".

 

 

 

 

'That is because NULL is not a valid parameter for the time-frame
 
Alberto_jazz:

This is how I call the indicator in the expert 

double Stoch_Diff = iCustom(NULL,NULL,"Stoch Difference",0,1) ;

When I compile the expert I have no errors, but when I apply the expert to the chart I obtain "invalid integer number as parameter 2 for 'iCustom' function".

 

 

 

 

Try 

double Stoch_Diff = iCustom(NULL,0,"Stoch Difference",0,1) ;
 
honest_knave:

Try 

thanks lot. me too had same problem with my indicator. after putting 0. it is working well.
 
  • You can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, MarketInfo does not. OrderSend does not.
  • Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
  • Zero is the same as PERIOD_CURRENT which means _Period. Don''t hard code numbers.
  • No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
Reason: