How to get first price of day

 

Hi,

I am doing an indicator for stock market that starts at 9 AM. So I want get the first price of day and start or restart the calculation at 9 AM.

I have tried this into OnCalculate, but it is not working

MqlDateTime curDate;
TimeCurrent(curDate);
   
   if (curDate.hour < 9)
      return 0;

I appreciate any help.

 
void OnStart()
  {
   MqlDateTime curDate;
   TimeCurrent(curDate);

   if(curDate.hour==9)
     {
      Print("Do somethig");

     }
   else
     {
      Print("It is not 9 O'Clock yet");
     }

  }
//+------------------------------------------------------------------+
 
Thanks. But this must be done into OnCalculate, because I am doing a chart indicator.
 
MqlDateTime curDate;
datetime dt=iTime(NULL,0,0);
TimeToStruct(dt,curDate);
This should work in OnCalculate (untested.)
 
         int hora_inicio_trading=9;
         hora_actual_local=TimeHour(TimeLocal());
         if(hora_actual_local==hora_inicio_trading && TimeMinute(TimeLocal())==0)
           {
           }

This is what I use. Although the code is for a robot you would easily modify it for use in an indicator.