Problem with Times

 

Hi,


I would like to scan the last 24 hourly bars and find the 9 o'clock bar then store its open. Is there a function that return only the hour for each bar something like iTime(NULL,0,i)? How else can I solve the problem of finding the 9 o'clock bar?


Many thanks

 

Hour()

 
are you an idiot or you pretend to be one?
 
1Mill:
are you an idiot or you pretend to be one?


u right i'm an idiot

TimeHour()

 
int iBarShift(  string symbol, int timeframe, datetime time, bool exact=false)
 
  1. find the 9 o'clock bar then store its open
    for(int hrBar=0; TimeHour(iTime(NULL, PERIOD_H1, hrBar)) != 9; hrBar++){}
    double open9AM=iOpen(NULL,PERIOD_H1, hrBar);

  2. iBarShift(strToDate("9:00")) is more complicated and won't work if its earlier than 9AM. (OP wants the last 9AM)
 
wow thanks WHRoeder, you solved the problem! You are a true programmer!
Reason: