High/low last bar of yesterday and first bar of today

58

Hi everyone,

I'd like to get the high/ low of 3 candles (last bar of previous days and the first two bars of the current day) for a given timeframe
I'm getting a bit stuck with a piece of mql4 code. I tried  to do it this way:

```datetime now  = Time[0],
bod  = now - now % (24*60*60); // Beginning of the day
int      iBod = iBarShift(NULL,0, bod),
nH3  = 3 * 60 / Period(), // Number of bars for 3 hours
iH3  = iBod - nH3 + 1;
if (iH3 <= 0) return;
double HH = iHighest(NULL,0, MODE_HIGH,nH3,iH3)
double LL =  iLowest(NULL,0, MODE_LOW, nH3,iH3) ```

But it's just give me the high/low of first three candle of current day.
How  can I achieve what I want, please.
Regards
5493

bodojan468:
Hi everyone,

I'd like to get the high/ low of 3 candles (last bar of previous days and the first two bars of the current day) for a given timeframe
I'm getting a bit stuck with a piece of mql4 code. I tried  to do it this way:

But it's just give me the high/low of first three candle of current day.
How  can I achieve what I want, please.
Regards

use iBarShift  to get the bar indexes for start and end of the period required

feed that to iHighest and iLowest to get the bar index of highest and lowest

feed that to iHigh iLow to get the final values

24205

bodojan468: But it's just give me the high/low of first three candle of current day.
```         nH3  = 3 * 60 / Period(), // Number of bars for 3 hours
iH3  = iBod - nH3 + 1;```

Because that is what you asked for (nH3=3). You want to read [iBod+1 … iBod-2] (2 bars in the current chart.)

```if (iBod <= 2) return; // Not yet two bars completed.
double HH = iHighest(NULL,0, MODE_HIGH,3,iBod-2);```
Find bar of the same time one day ago - MQL4 programming forum 2017.10.06
58

Paul Anscombe:

use iBarShift  to get the bar indexes for start and end of the period required

feed that to iHighest and iLowest to get the bar index of highest and lowest

feed that to iHigh iLow to get the final values

Thanks for your answer.  I just realized I wasn't use good indexes

William Roeder:

Because that is what you asked for (nH3=3). You want to read [iBod+1 … iBod-2] (2 bars in the current chart.)

Find bar of the same time one day ago - MQL4 programming forum 2017.10.06Thanks Wil

Thanks W. Roeder

```datetime now  = Time[0],