View Single Post
  #19 (permalink)  
Old 07-22-2009, 01:55 PM
apparelink apparelink is offline
Junior Member
 
Join Date: Jun 2009
Posts: 2
apparelink is on a distinguished road
Average Daily Range (ADR) Indicator

Quote:
Originally Posted by zeinoun View Post
Hi all
Attached please find an indicator giving this definition. But, the problem is it gives only the data for the last day. If somebody can help to modify it to produce historical data in order to use it for historical testing.

Zeinoun
Here is the Average Range indicator that allows you to enter a fast and slow period. You need to put all three files in the correct locations and compile both mq4 files in that order:

HelpFunctions.mqh must be put in the include folder
HelpFunctions.mq4 must be put in the libraries folder and compiled
Average Range.mq4 must be put in the indicators folder and compiled

It calculates the average range (AR) in pips using the past N trading days. AR is the same as ADR (Average Daily Range) when the timeframe is set to PERIOD_D1. This function is written for code reusability so it can also be used for other timeframes as well.



You may also want to set the OptimizePerformance option to true. This limits the number of bars used for calculation to 400 by default (you can change this number to suit). Otherwise it would take a very long time to calculate the AR for all bars downloaded from the History Center.




My test results are consistent with the findings on this site: Most Volatile Active Traded Currency Pairs

In return please share your experience in using Average Range in your trading strategy.

Scott
Attached Files
File Type: mq4 Average Range.mq4 (6.3 KB, 39 views)
File Type: mqh HelperFunctions.mqh (1.4 KB, 34 views)
File Type: mq4 HelperFunctions.mq4 (13.5 KB, 37 views)
Reply With Quote