how to compare numbers and iCustom value

 
int x[] =
{
iCustom(NULL, NULL, "XXX",0,i)
,
66
,
22
,
99
}
;

int maxValue = ArrayMaximum(x);

Hi

I try to compare values of the external indicator and numbers.

is it correct to compare numbers and iCustom return value?

Is it any other way to do this?

thanks

 
int x will be the indicator handle please see: https://www.mql5.com/en/docs/indicators/icustom
Documentation on MQL5: Technical Indicators / iCustom
Documentation on MQL5: Technical Indicators / iCustom
  • www.mql5.com
[in]  The name of the custom indicator, with path relative to the root directory of indicators (MQL5/Indicators/). If an indicator is located in a subdirectory, for example, in MQL5/Indicators/ [in] input-parameters of a custom indicator, separated by commas. Type and order of parameters must match. If there is no parameters specified, then...
 
Marco vd Heijden:
int x will be the indicator handle please see: https://www.mql5.com/en/docs/indicators/icustom
#property indicator_separate_window
#property indicator_buffers 4



#property indicator_color1 DeepSkyBlue
#property indicator_color2 Red

#property indicator_color3 DodgerBlue
#property indicator_color4 Crimson


#property indicator_level1 0
#property indicator_levelcolor White
#property indicator_levelstyle 0

//------------------------------------------------------

extern int width0=4;

extern int width1=10;

extern int width2=12;


//------------------------------------------------------

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];





int AA; 
//------------------------------------------------------
int ExtCountedBars=0;
//------------------------------------------------------

int init()
{
//------------------------------------------------------
   SetIndexStyle(0,DRAW_HISTOGRAM, 0, width1);
   SetIndexBuffer(0, ExtMapBuffer1);
   IndicatorDigits(Digits-5);
   
   SetIndexStyle(1,DRAW_HISTOGRAM, 0, width1);
   SetIndexBuffer(1, ExtMapBuffer2);
   IndicatorDigits(Digits-5);
   
   
   
   SetIndexStyle(2,DRAW_HISTOGRAM, 0, width0);
   SetIndexBuffer(2, ExtMapBuffer3);
   IndicatorDigits(Digits-5);
   
   SetIndexStyle(3,DRAW_HISTOGRAM, 0, width0);
   SetIndexBuffer(3, ExtMapBuffer4);
   IndicatorDigits(Digits-5);
   


//------------------------------------------------------
   SetIndexDrawBegin(0,0);
   SetIndexDrawBegin(1,0);
   
   SetIndexDrawBegin(2,0);
   SetIndexDrawBegin(3,0);
   


   

   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexBuffer(1,ExtMapBuffer2);
   
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexBuffer(3,ExtMapBuffer4);
   
//------------------------------------------------------

return(0);
}
//+------------------------------------------------------------------+                    |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}



int start()
{



if(Bars<=10) return(0);
ExtCountedBars=IndicatorCounted();

   
//---- check for possible errors
if
(ExtCountedBars<0)
return(-1);

   
//---- last counted bar will be recounted
if
(ExtCountedBars>0)
ExtCountedBars--;
//+------------------------------------------------------------------+ 
//+------------------------------------------------------------------+ 
//+------------------------------------------------------------------+ 

int pos=Bars-ExtCountedBars-1;
while(pos>=0)
//+------------------------------------------------------------------+ 
//+------------------------------------------------------------------+ 

{
if
(
iCustom(NULL, NULL, "MT4_INDIK\\candles-celi_masivi_00",0,pos)>0
&&
iCustom(NULL, NULL, "MT4_INDIK\\candles-celi_masivi_00",0,pos+1)==0
)

{
AA = iCustom(NULL, NULL, "MT4_INDIK\\candles-celi_masivi_00",0,pos);


int x_up[] =
{
AA
,
66
,
22
,
99
}
;

int maxValue = ArrayMaximum(x_up);

{
ExtMapBuffer1[pos]=x_up[maxValue];
ExtMapBuffer2[pos]=0;
            
ExtMapBuffer3[pos]=0;
ExtMapBuffer4[pos]=0;
}

}

//+------------------------------------------------------------------+ 
pos--;
}
return(0);
}

this is mq4 - i forgot.

AA- constant expression required.
if I type number instead of "AA" there is no errors and the code works.

where is my mistake?

 
Have you tried printing the return value of iCustom directly ?
 

You can't use a variable in array initializer:


int x_up[] =
{
AA   <-- Wrong
,
66
,
22
,
99
}
;

 Instead, set some constant there and then assign a value to the x_up[0]

int x_up[] = { 0 , 66 , 22 , 99 } ;

x_up[0] = AA;

 
Drazen Penic:

You can't use a variable in array initializer:


 Instead, set some constant there and then assign a value to the x_up[0]

great! this is what i'm asking for! thanks!


"Have you tried printing the return value of iCustom directly ?"

print have been works with numbers but not with variables in array (which is the my mistake).