last "n" high/low price values

 

Hello,

I would like to to be able to find previous 'N" value of on indicator (in particular "last N high/low price values") 

Any help, is appreciated !

Thanks in advance ! 

 
tenlau:

Hello,

I would like to to be able to find previous 'N" value of on indicator (in particular "last N high/low price values") 

Any help, is appreciated !

Thanks in advance ! 

Hello tenlau, what indicator is it? Have you done anything so far? Do you have any piece of code to show us?

Please give us more details, so we can help you. 

 
Malacarne:

Hello tenlau, what indicator is it? Have you done anything so far? Do you have any piece of code to show us?

Please give us more details, so we can help you. 

No, I didn't write any code yet. I thought at a generic code as an example; to be able to adapt later on my own needs.

As I said in the first post: lets find, let say, the highest value of SMA(20) in the previous 15 bars. Of course, "20" and "15" has to be inputs

 
tenlau:

No, I didn't write any code yet. I thought at a generic code as an example; to be able to adapt later on my own needs.

As I said in the first post: lets find, let say, the highest value of SMA(20) in the previous 15 bars. Of course, "20" and "15" has to be inputs

Please show your attempts.
 
tenlau:

Hello,

I would like to to be able to find previous 'N" value of on indicator (in particular "last N high/low price values") 

Any help, is appreciated !

Thanks in advance ! 

This function returns the largest value of n bars...

//+---------------------------------RETORNA EL MAYOR VALOR DE nBARRAS----------------------+
double iHighest(string simb, ENUM_TIMEFRAMES marcoTmp, int modo, int nBars, int nVela= 0)
{
   double resp= 0, arPrecios[];
   ulong arVolum[];
   int posicion=0, nCopiado= 0;
   ArrayResize(arPrecios, nBars);
   ArrayResize(arVolum, nBars);
   ArraySetAsSeries(arPrecios, true);
   ArraySetAsSeries(arVolum, true);
   switch(modo)
     {
      case 0 :
         nCopiado= CopyOpen(simb,marcoTmp,nVela,nBars,arPrecios);
         break;
      case 1 :
         nCopiado= CopyClose(simb,marcoTmp,nVela,nBars,arPrecios);
         break;
      case 2 :
         nCopiado= CopyHigh(simb,marcoTmp,nVela,nBars,arPrecios);
         break;
      case 3 : 
         nCopiado= CopyLow(simb,marcoTmp,nVela,nBars,arPrecios);
         break;
      case 4 :
         nCopiado= CopyTickVolume(simb,marcoTmp,nVela,nBars,arVolum);
         break;
      case 5 :
         nCopiado= CopyRealVolume(simb,marcoTmp,nVela,nBars,arVolum);
         break;
     }
     if(nCopiado==nBars)
     {
        if(modo<4)
        {
           posicion= ArrayMaximum(arPrecios,0,WHOLE_ARRAY);
           resp= arPrecios[posicion];
        }
        else
        {
           posicion= ArrayMaximum(arVolum,0,WHOLE_ARRAY);
           resp= (double)arVolum[posicion];
        }
     }
   return(resp);
}
 
josemiguel1812:

This function returns the largest value of n bars...

Thank you !

Indeed a real helping hand ! 

Reason: