Download MetaTrader 5

Daily Range for a particular day in the week?

To add comments, please log in or register
vladrac
27
vladrac  

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  

whroeder1
14785
whroeder1  
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.
To add comments, please log in or register