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

 

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?

Please help!! :)

 

you need to use iHighest() and iLowest()

 

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

 
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
 
Thanks a lot guys I figure out with all your help. :)
 
Finally, i have found the solution here... I needed to use [B]iBarShift[/B] function:
http://www.forexfactory.com/showthread.php?p=2351580#post2351580


   ii = iBarShift(NULL, TargetPeriod, iTime(NULL,0,i))+1;
   bHIGH    =(iHigh(NULL,TargetPeriod,ii));
 
whroeder1:

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.

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

Thank you.

 
Hi Everyone!

I am trying to make a simple asia session code, which is get for me every day the asia session high and low. How should I do that? like server time 0h-8h highest and lowest points.
 
atesz5870 #:
Hi Everyone!

I am trying to make a simple asia session code, which is get for me every day the asia session high and low. How should I do that? like server time 0h-8h highest and lowest points.
You can use the 4H candles and get the first 2 candles of a day, then you check the low and high of these 2 candles.

If you don't know how to do that, then I suggest you switch to MT5, and learn MQL5 language.

There is a book on this page to get you started with MQL5.
 
Dominik Egert #:
You can use the 4H candles and get the first 2 candles of a day, then you check the low and high of these 2 candles.

If you don't know how to do that, then I suggest you switch to MT5, and learn MQL5 language.

There is a book on this page to get you started with MQL5.

thank you Dominik!


Reason: