Daily Range for a particular day in the week?

 

hello Forum,

 Im trying to figure out how to calculate the average daily move of a pair in a particular day of the week.

 I do have a code that can calculate the average of X number of days, or the last day , but cant figure out how would I compute only the average of Mondays, Tuesdays, etc.

 appreciate your help.

 Regards,

Vladimir  

 
vladrac: but cant figure out how would I compute only the average of Mondays, Tuesdays, etc.
Not compiled, not tested.
double TodaysDailyRange(int length=14){
   int dow = DayOfWeek();
   int count=0;
   double sum=0;
   for(int iD1 = 1; count < length; ++iD1){
      datetime when = iTime(_Symbol, PERIOD_D1, iD1);
      if( TimeDayOfWeek(when) != dow) continue;
      sum += iHigh(_Symbol, PERIOD_D1, iD1) - iLow(_Symbol, PERIOD_D1, iD1);
      ++count;
   }
   return sum / length;
}
Not compiled, not tested.
Reason: