highest range code

 

hello,

i'm trying to code an indicator to give me signals when the bar range is the highest of a specified period. ihighest[iatr ...] doesn't seem to work and i don't know where to start looking.

any idea?

thanks

 

i tried to compile ur code & it works just fine

hoops there is no code

 

was trying another way than the ihighest[atr... still doesn't work proper :

  {
   int t = 0;
   for (int n=t;n<t+period;n++)
    { 

     double Mid = (High[t] + Low[t]) / 2.0;
     double Range = High[t]-Low[t];
     double Nrange = High[n]-Low[n];
      {
      if (Range >= Nrange) Signal[t] = Mid;
      }
    }
   }

can anyone give a hand here?

thanks

 

iHighest

Returns the shift of the maximum value over a specific number of bars depending on type.

not the price

 

OP is after Biggest Range ?

if t is always 0 ( as it appears to be here) then following should work ..

// not mql - pseudo code!

int t=0;

int bestRange =t;

double Range = High[t] - Low[t];

for each candle 'n' before  {

   set Nrange ...

   if (Range < Nrange ) { 
      bestRange = n;  
      break; 
    }

}

if (bestRange == t) Signal[t] = Range/2;
 
double Mid = (High[t] + Low[t]) / 2.0;

B.T.W.

iMA(Symbol(), Period(), 1, 0, MODE_SMA, PRICE_MEDIAN, shift) = Mid
Reason: