# How do you find the high/low of a certain period?

144

Hello all,

I'm new to coding and I'm really not finding a way to get what I'm looking for. Maybe one cool/savior programmer out there can help.

I'm trying to find out the high/low for a certain period. The period is fixed. Let me explain a bit better. I'm trying to find out the highest high and the lowest low of 3 months, for example, January, February and March of 2010 (or whatever year I need). I'm not looking for 3 highs/lows, I'm looking for the highest high and lowest low of the "group" of months. So if I want to find out the highest high and lowest low of July, August, and September, the indicator will comment on chart this, "Highest high for those months is xxx and the lowest low is yyy"

I tried looking up at the code base and the book but the Period ends in MN1, which is based on current bar or before. I needed something a bit more specific for the month and year. What's the best way to find the highest high/lowest low of a specific month or group of months in mql4?

2584

you need to use iHighest() and iLowest()

63

This is the easy way:

High = iHigh(NULL, 0, iHighest(NULL,0,MODE_HIGH,PERIOD,0) );

Low = iLow(NULL, 0, iLowest(NULL,0, MODE_LOW,PERIOD,0) );

bye

15577

felipefxr 2011.01.14 23:56

I tried looking up at the code base and the book but the Period ends in MN1, which is based on current bar or before. I needed something a bit more specific for the month and year. What's the best way to find the highest high/lowest low of a specific month or group of months in mql4?

```High = iHigh(NULL, 0, iHighest(NULL,0,MODE_HIGH,PERIOD,0) );
Low  =  iLow(NULL, 0, iLowest(NULL,0, MODE_LOW,PERIOD,0) );```

This will return H/L on the current chart for PERIOD bars back.

You need find the first and last bars in the period your interested in, either by counting or iBarsShift a specific date.

```datetime fromDT = ...,
toDT = ...;
int      fromBar = iBarShift(NULL, 0, fromDT),
toBar = iBarShift(NULL, 0,   toDT),
length = fromBar - toBar + 1,
HHbar = iHighest(NULL,0, MODE_HIGH, length, toBar),
LLbar =  iLowest(NULL,0, MODE_LOW,  length, toBar);
double     HH    = High[HHbar], // iHigh(NULL,0, HHbar)
LL    =  Low[LLbar]; //  iLow(NULL,0, LLbar)```
If you are looking back beyond the number of bars on the chart (i.e, months back but on a M1 chart) then you'll have to use a higher TF to get the data, E.G. replace NULL,0 with NULL, PERIOD_W1
144

Thanks a lot guys I figure out with all your help. :)
64

Finally, i have found the solution here... I needed to use [B]iBarShift[/B] function: