Average Daily Range Indicator

 

I am looking foir an indicator for MT4 that can calculate the annual average daily range of any currency pair. I have seen plenty out there with no inputs at all or some that can do up to 100 days etc, but want to be able to calculate the ADR for 1 trading year and have it just show in a corner as pips.

Anyone know of such an indicator?

cheers

honkin

 

H

Look at the MetaTrader ATR built-in indicator - set it to what you want or modify it

-BB-

 

I am not after average true range but average daily range. They are not the same BorrowBoy, but thanks for your reply.

honkin

 

I took some code from Forum on www.ForexFactory.com and cleaned it up a bit.

Files:
 

Try this:

double AverageBarLen(int ParamPer) {

   return(iMA(NULL,PERIOD_D1,ParamPer,0,MODE_SMA,PRICE_HIGH,1)-iMA(NULL,PERIOD_D1,ParamPer,0,MODE_SMA,PRICE_LOW,1));

}

The parameter is the number of lookback periods.

 
Try this
double AverageDailyRange(int length, int iStart=0){
    return( AverageRange(PERIOD_D1, length, iStart) ); }
double AverageRange(int TF, int length, int iStart=0){
    int nBars   = iBars(NULL, TF),
        iLimit  = iStart + length;  if (iLimit > nBars) iLimit = nBars;
    double  sum=0;
    for(int iPos = iStart; iPos < iLimit; iPos++){
        double  H = iHigh(NULL, TF, iPos),
                L =  iLow(NULL, TF, iPos);
        sum += H-L;
    }
    return( sum/(iLimit-iStart) );
}
Not compiled, not tested.
 

thank you for your indi!

can u program it to choose the opening hour?

Thanks!

TheGreedyPig:

I took some code from Forum on www.ForexFactory.com and cleaned it up a bit.

 
coconu:
can u program it to choose the opening hour?
  1. Yes I can, can you?
  2. No Slaves here, learn to code or pay someone. We're not going to code it FOR you. We are willing to HELP you.
 

no intention to offend or to be disrespectful! i'm not lazy nor looking for a slave.

just looking for an answer to my problem.

Thank you!

 
  1. Same request: (MQL4) How to find average daily move in PIPS only between 10:00 and 18:00 in the past year only? - MQL4 forum
  2. not lazy nor looking for a slave.
    Did you post your code? No. Did you offer to pay? No. You want someone to code it for you, for free - definition of a slave.
  3. No Slaves here, learn to code or pay someone. We're not going to code it FOR you. We are willing to HELP you.
 
double ADR(int length, int iStart=1){
    
    return( AverageRange(PERIOD_D1, length, iStart) ); 
}
//////////////////////////////////////////////////////////////////////
double AverageRange(int TF, int length, int iStart){

    int nBars   = iBars(NULL, TF),
        iLimit  = iStart + length;  if (iLimit > nBars) iLimit = nBars;

    double  sum=0; 
    for(int iPos = iStart; iPos < iLimit; iPos++){
      if (TimeDayOfWeek(iTime(NULL,TF,iPos))!=0){ 
        double  H = iHigh(NULL, TF, iPos),
                L =  iLow(NULL, TF, iPos);
                print("high - low " + DoubleToString(H-L));
        sum += H-L;
      }
     else {
     iLimit ++;
     iStart ++;
     }
    }
    
    return( (sum/(iLimit-iStart))/pip );
};
////////////////////////////////////////////////////////////////////
double CurrentDayRange(int TF){

   double  H = iHigh(NULL, TF, 0),
           L =  iLow(NULL, TF, 0);
   
   return((H-L)/pip);
};

Not quite what you guys were looking for but I thought I would share my code that excludes Sundays that some have been looking for. This can be easily edited to add time but it's not something that I am currently interested in.

Reason: