Download MetaTrader 5

highest range code

To add comments, please log in or register
joe
63
joe  

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

qjol
3243
qjol  

i tried to compile ur code & it works just fine

hoops there is no code

joe
63
joe  

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

qjol
3243
qjol  

iHighest

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

not the price

ydrol
593
ydrol  

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;
qjol
3243
qjol  
double Mid = (High[t] + Low[t]) / 2.0;

B.T.W.

iMA(Symbol(), Period(), 1, 0, MODE_SMA, PRICE_MEDIAN, shift) = Mid
To add comments, please log in or register