Download MetaTrader 5

How to get a time of High/Low of previous day?

To add comments, please log in or register
Marky
27
Marky  

Hi,

I'm trying to automate analizing charts and to develop some tools for that purpose.

But I can't find a time (lets say an Hour) of High/Low of previous day on the H1 chart.

I used iHigh and iLow functions to find extremes on a D1 chart, but I have no idea how to find a particular time of them. :(

Do you have any idea how to do it? 

Simon Gniadkowski
Moderator
18036
Simon Gniadkowski  
marky_74:

Hi,

I'm trying to automate analizing charts and to develop some tools for that purpose.

But I can't find a time (lets say an Hour) of High/Low of previous day on the H1 chart.

I used iHigh and iLow functions to find extremes on a D1 chart, but I have no idea how to find a particular time of them. :(

Do you have any idea how to do it? 

Use iHighest() & iLowest() to get the bar numbers of the High and Low bars and then you can use Time[bar_number] or iTime()
whroeder1
16105
whroeder1  
marky_74:
But I can't find a time (lets say an Hour) of High/Low of previous day on the H1 chart.
I used iHigh and iLow functions to find extremes on a D1 chart, but I have no idea how to find a particular time of them. :(
  1. As long has you have D1 history (for the tester, and handle ERR_HISTORY_WILL_UPDATED for live) you can use:
    double HHyest = iHigh(NULL, PERIOD_D1, 1);

  2. Alternatively, (for offline charts, etc)
    #define HR2400      86400           // 24 * 3600
    datetime TimeOfDay(datetime when){  return( when % HR2400          );       }
    datetime DateOfDay(datetime when){  return( when - TimeOfDay(when) );       }
    //////
    datetime  now   = TimeCurrent(),
             bod    = DateOfDay(now),
             yest   = DateOfDay(bod-1);
    int      iBod   = iBarShift(NULL,0, bod),
             iYest  = iBarShift(NULL,0, yest),
             iHHy   = iHighest(NULL,0,MODE_HIGH, iYest-iBod, iBod+1);
    double   HHyest = High[iHighest];

Marky
27
Marky  
RaptorUK:
Use iHighest() & iLowest() to get the bar numbers of the High and Low bars and then you can use Time[bar_number] or iTime()


Thanks a lot :)

Nice idea. I tried it and it works:)  

Marcus Roberts
139
Marcus Roberts  
Can give an idea of how to stop iHighest/iLowest  from giving a signal past the last higest/lowest, ie... lowest on an uptrend? Any help would be much appreciated. Thanks.
Keith Watford
Moderator
10614
Keith Watford  
sssolepro:
Can give an idea of how to stop iHighest/iLowest  from giving a signal past the last higest/lowest, ie... lowest on an uptrend? Any help would be much appreciated. Thanks.
I don't understand what you are asking for.
To add comments, please log in or register