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

Back to topics list To post a new topic, please log in or register
avatar
8
soccernatic 2011.01.14 23:56
 

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!! :)


 
avatar
1815
SDC 2011.01.15 03:34 #
 

you need to use iHighest() and iLowest()

avatar
780
giaras 2011.01.15 09:00 #
 


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


 
avatar
13010
WHRoeder 2011.01.15 19:36 #
 
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
 
avatar
8
soccernatic 2011.05.10 21:43 #
 
Thanks a lot guys I figure out with all your help. :)
avatar
16
tazosmr 2015.11.09 09:18 #
 
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));

Back to topics list  

To add comments, please log in or register