// Return the closing prices of the bars during the n previous // trading days before a given Date (expressed in DateNum() format). // The resulting array contains Null cells everywhere except for the // bars within the chosen interval. I find it useful with // intraday data to get the prices of the few previous days. function lastNDaysBeforeDate(arg_N, arg_Date) { local i, stop, CurrentDay,DatesBeforeDate; // get all dates before 'arg_date' DatesBeforeDate = IIf(DateNum()=0)AND(stop>=0);i--) { // only interesting when non-empty values if (!IsEmpty(DatesBeforeDate[i])) { // count the number of changes of the value of CurrentDay // to know where to stop if (CurrentDay!=DatesBeforeDate[i]) { CurrentDay = DatesBeforeDate[i]; // _TRACE("Day " + NumToStr(CurrentDay,1.0)); stop--; } if (stop>=0) RESULT[i]=Close[i]; } } return RESULT; }