Download MetaTrader 5
To add comments, please log in or register
Do you wonder how to use widgets? Read the article!
Alberto Tortella
481
Alberto Tortella 2014.11.17 15:40 

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! 

whroeder1
13644
whroeder1 2014.11.17 18:05  
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
Alberto Tortella
481
Alberto Tortella 2014.11.18 07:29  

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".

Keith Watford
Moderator
7990
Keith Watford 2014.11.18 07:51  
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
honest_knave
969
honest_knave 2014.11.18 07:52  
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) ;
/
To add comments, please log in or register