Daily Range for a particular day in the week?

Back to topics list To post a new topic, please log in or register
avatar
1
vladrac 2015.10.05 19:22
 

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  

avatar
12984
WHRoeder 2015.10.05 20:14 #
 
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.

Back to topics list  

To add comments, please log in or register