Store Current Price

 
When a time is hit, I want to store the current price in a attribute. That attribute does not change.

I know to use datetime, and Bid. But Bid will refresh on every tick, I assume.

It is for data release buy/sell stop strategy. The second data is released, store currentprice. Then set sell/buy orders. When one order is hit, set its SL to the currentprice.

I hope one will understand, thank you
 
#property strict

#define DAY 86400
#define HOUR 3600
#define MIDNIGHT (TimeCurrent()-TimeCurrent()%DAY)

int    when = 6*HOUR; // 06:00
double stored_price = 0;

int OnInit()
  {
   EventSetTimer(1);
   return(INIT_SUCCEEDED);
  }

void OnTimer()
  {
   static datetime next_check = TimeCurrent()%DAY > when ? MIDNIGHT+when+DAY:
                                                           MIDNIGHT+when;
   if(TimeCurrent() >= next_check)
     {
      stored_price = Bid;
      next_check = MIDNIGHT+when+DAY;
      printf("Price updated: %f Next check %s",stored_price,TimeToString(next_check));
     }
  }

void OnTick()
  {
   // do whatever you need with stored_price
  }
 
honest_knave:
May I ask you, why have you declared a static variable inside the function?