double PrevDayClose()
{
double _prevclose = 0;
try
{
DateTime _prevday = Time[0].AddDays(-1);
// make sure prior day is always mon-fri never sat or sun
if (Time[0].DayOfWeek == DayOfWeek.Monday)
_prevday = Time[0].AddDays(-3);
if (Time[0].DayOfWeek == DayOfWeek.Sunday)
_prevday = Time[0].AddDays(-2);
_prevclose = Close[0][GetBar(new DateTime(_prevday.Year, _prevday.Month, _prevday.Day, 16, 15, 0); // where 16,15,0 means 4:15:00pm based on local PC time
}
catch(Exception e)
{
Print (e.ToString()); // just incase index is exceeded somewhere
}
return _prevclose;
}
Comment