Calling a function to execute only at a certain time?

 

I'm trying to get the high and low of the previous day on a 1 hour chart (the last 24 bars) so I can use them during the day. I want this process to be done everyday of trading.

Currently I put this process in the following functions:

double Higher (double Top)
{
static int i;
for(i=1;i<History;i++)
{
if(High[i]>Top)
Top=High[i];
}
return (Top);
}
double Lower (double Bottom)
{
static int j;
for(j=1;j<History;j++)
{
if(Low[j]<Bottom)
Bottom=Low[j];
}
return (Bottom);
}

...within the "start" portion...

double Peak, Valley;

if(Time[0]==D'00:00:00')
{
Peak = Higher (0.00000);
Valley = Lower (200.00000);
}

The variables "Peak" and "Valley" are used later. But nonetheless, am I complicating this? All I want are the high and low of the previous day (of course, that would change day-to-day). How would I code this? Thanks.

 
renner1984 wrote >>

I'm trying to get the high and low of the previous day on a 1 hour chart (the last 24 bars) so I can use them during the day. I want this process to be done everyday of trading.

Currently I put this process in the following functions:

double Higher (double Top)
{
static int i;
for(i=1;i<History;i++)
{
if(High[i]>Top)
Top=High[i];
}
return (Top);
}
double Lower (double Bottom)
{
static int j;
for(j=1;j<History;j++)
{
if(Low[j]<Bottom)
Bottom=Low[j];
}
return (Bottom);
}

...within the "start" portion...

double Peak, Valley;

if(Time[0]==D'00:00:00')
{
Peak = Higher (0.00000);
Valley = Lower (200.00000);
}

The variables "Peak" and "Valley" are used later. But nonetheless, am I complicating this? All I want are the high and low of the previous day (of course, that would change day-to-day). How would I code this? Thanks.

One more thing, "History" is defined above as "extern int 24;" at the top of the program.

Reason: