Help with create global condition

 

Hi  Everyone,

I want to create a compound variable for my program so that in the code, I can call its value instead of write that long code for it again.

Previously, I wrote that upbar and body variable and put it below the buffer section. It works. 

later all i need is call upbar(i) 

int   upbar(int b)
{  if(Close[b]>Open[b])
      return(1);
   else  
      return(0);
}
double body(int c)
{  return(MathAbs(Close[c]-Open[c]));}

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {

 

This time, I make it 1 more step further as below where I try to find which bar ADX move at least 20 point.

The error notice is:'}' - not all control paths return a value 

int   adxmove20(int b)
{  if(iADX(NULL,0,14,PRICE_CLOSE,MODE_MAIN,b)>50)
   {  for(int c=b+1;c<=b+30;c++)
      {  if(MathAbs(iADX(NULL,0,14,PRICE_CLOSE,MODE_MAIN,b)-iADX(NULL,0,14,PRICE_CLOSE,MODE_MAIN,c))>19)
         {  return(1);
            break;
         }
      }
   }
   else  
      return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   

 Could you please help me with a proper way to create such variable?

 Thank you,

SCFX 

 
hhchenfx:

Hi  Everyone,

I want to create a compound variable for my program so that in the code, I can call its value instead of write that long code for it again.

Previously, I wrote that upbar and body variable and put it below the buffer section. It works. 

later all i need is call upbar(i) 

 

This time, I make it 1 more step further as below where I try to find which bar ADX move at least 20 point.

The error notice is:'}' - not all control paths return a value 

 Could you please help me with a proper way to create such variable?

 Thank you,

SCFX 

iAdx () reports the pointer to the indicator data. Not provide data directly.

int handleADX= 0;		//global vars
//...
void OnInit()
{
   //...
   handleADX= iADX(symbol, periodTF, adx_period);
   //...
}

void OnTick()
{
   //...
   double bufferDats[];
   int nCopy= CopyBuffer( handleADX, bufferNum, startPos, quantity, bufferDats);
   bool correct= nCopy==quantity;
   //...

}

 The Indicator datas are now on bufferDats[]

 
josemiguel1812:

iAdx () reports the pointer to the indicator data. Not provide data directly.

 The Indicator datas are now on bufferDats[]

It's probably mql4.
 
hhchenfx:

Hi  Everyone,

I want to create a compound variable for my program so that in the code, I can call its value instead of write that long code for it again.

Previously, I wrote that upbar and body variable and put it below the buffer section. It works. 

later all i need is call upbar(i) 

 

This time, I make it 1 more step further as below where I try to find which bar ADX move at least 20 point.

The error notice is:'}' - not all control paths return a value 

 Could you please help me with a proper way to create such variable?

 Thank you,

SCFX 

Remove the "else" line.
 
angevoyageur:
Remove the "else" line.

Yes, Thanks.

SCFX