- Ask!
- Dolly system
- CatFx50
Have you found a solution?
I am looking for an indicator that gives the past 7 trading days average daily range. Can you help?
Best
H. Y.
Sorry, may be too late... but this is a suggestion and sorry for my very bad English.
extern bool IncludeSunday = false; //---- indicator parameter
//……
int DaysToSunday[7] = { 6, 1, 2, 3, 4, 5, 6 }; // days to Sunday ( from today = DayOfWeek() )
/* How do to skip the Sunday?
If you are on Sunday (DayOfWeek=0) or Saturday (DayOfWeek=6) the index bar = 1 belong to Friday, 2 to thersday, etc.
then, you must count from 1 to 5, skip the 6 (Sunday), from 7 to 11, skip 12 (Sunday too), from 13 to 17, skip 18, etc.
If you are on Monday you must skip the 1, count from 2 to 6, skip 7, ...etc.
If you are on Friday you must count from 1 to 4, skip 5, 11, 17... and so on. */
// and then:
int IsSunday = DaysToSunday[DayOfWeek()]; // bar index of the more close Sunday, to skip if IncludeSunday = False.
bool IsYesterday = true;
int nDays = 0 ; int iH_iL ;
for(i=1;i<=Third_av;i++) // Max. Average Period
{
nDays++;
if (!IncludeSunday)
{
if (i==IsSunday)
{
i++; // Skip Sunday
IsSunday += 6; // Index of next Sunday (Saturday has not data)
}
}
iH_iL = NormalizeDouble( (iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/Point, 0 ) ;
if (nDays==1) // only first time is yesterday
{
R1 = iH_iL ; // Yesterday daily Range in points
}
if(nDays<=First_av) R5 = R5 + iH_iL ; // Daily Range last First_av days, in points
if(nDays<=Second_av) R10 = R10 + iH_iL ; // Daily Range last Second_av days, in points
if(nDays<=Third_av) R20 = R20 + iH_iL ; // Daily Range last Third_av days, in points
}
//...... etc. ....................
Best
Eduardo
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use