Finding the time of lowest and highest price in an hourly price bar

 

Hello everybody,

I want to find the exact time of lowest and highest price in bar. Is it possible?

If so how?

My second question is how to get details bars of an H1 price bar? I need to get my current H1 bar decomposed into M5 Bars. How?

Could you please help?

 

Uh, use lower timeframe to find details of higher timeframe

 

How?

How can get a list of lower time frame price bars for a given higher timeframe price bar?

 

Here is a sample, run on 1 min chart to get data for 1 hour bars over the last day.

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start(){
    int oldHour, i;
    double highest, lowest;
    datetime highTime, lowTime;
    
        // init     oldHour = TimeHour(Time[0]);
    highest = High[0];    lowest  = Low[0];        for(i = 0; i <= 1440; i++){
        if(TimeHour(Time[i]) == oldHour){
            if(High[i] > highest){
                highest  = MathMax(High[i], highest);
                highTime = Time[i];
            }
            if(Low[i] < lowest){
                lowest   = MathMin(Low[i], lowest);
                lowTime  = Time[i];
            }
        }
    
        if(TimeHour(Time[i]) != oldHour){
            Print("Highest and Lowest for hour ", oldHour, ":00  ", 
                   TimeToStr(highTime, TIME_MINUTES), "  ", highest,"  ",
                   TimeToStr(lowTime,  TIME_MINUTES), "  ",lowest);
            // reset variables, new hour found            
            highest = High[i];
            highTime = Time[i];
            lowest   = Low [i];
            lowTime  = Time[i];
            oldHour  = TimeHour(Time[i]);
        }
    }
    return(0);
}
 

Thank you very much Phy.

Reason: