I am not after average true range but average daily range. They are not the same BorrowBoy, but thanks for your reply.
honkin
Files:
thegreedypigradrfv6.mq4
14 kb
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.
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!
- 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
- 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.
- 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.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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