Download MetaTrader 5

How to get 1hr candle high/low values in 30m chart?

To add comments, please log in or register
Download MetaTrader 5 mobile version and trade from anywhere in the world!
Sherif Hasan
7290
Sherif Hasan 2013.11.27 20:07 

Hi,

I have written EA using 2 strategies.

one is using custom indicator with 30 minute timeframe. another strategy is no indicators. its pure breakout system. i take first 10 1hr candle high/low and place buystop/sellstop with highest/lowest price .my custom indicator startegy works well with 30min timeframe.i don't like to write different EA for breakout.so i coded combined 2 strategies.

when i test the ea with 30min timeframe it takes only 10 30min candles high/low.

here is code where i take highest/lowest price.

Please support me to get solved.

#define  ZEROAM 00
#define ELEVENAM 11
elevenAM=0; while( TimeHour(Time[elevenAM]) != ELEVENAM ) elevenAM++;
High0To11 = High[iHighest(NULL,0,MODE_HIGH, ELEVENAM-ZEROAM+1,elevenAM)];
Low0To11 = Low[iLowest(NULL,0,MODE_LOW, ELEVENAM-ZEROAM+1,elevenAM)];
Keith Watford
Moderator
9624
Keith Watford 2013.11.27 23:18  
Looking at your code, it appears to find the high and low of the first 12 candles of each day on the H1 chart
Sherif Hasan
7290
Sherif Hasan 2013.11.28 05:16  
GumRai:
Looking at your code, it appears to find the high and low of the first 12 candles of each day on the H1 chart

Yes. but i apply EA in 30min timeframe. so it takes last 12 candles 30min. not 1hour.


Any one support!

Simon Gniadkowski
Moderator
18001
Simon Gniadkowski 2013.11.28 08:12  
sheriffonline:

Yes. but i apply EA in 30min timeframe. so it takes last 12 candles 30min. not 1hour.


Any one support!

Read the documentation for iHighest() and iLowest() and specify the correct timeframe . . . PERIOD_H1 and then read the documentation for iHigh() and iLow()
Sherif Hasan
7290
Sherif Hasan 2013.11.29 06:26  
RaptorUK:
Read the documentation for iHighest() and iLowest() and specify the correct timeframe . . . PERIOD_H1 and then read the documentation for iHigh() and iLow()


Yes.i changed timeframe for1hour.but still it reads 30min tf datas.


High0To11 = High[iHighest(NULL,PERIOD_H1,MODE_HIGH, ELEVENAM-ZEROAM+1,elevenAM)];
Low0To11 = Low[iLowest(NULL,PERIOD_H1,MODE_LOW, ELEVENAM-ZEROAM+1,elevenAM)];
Simon Gniadkowski
Moderator
18001
Simon Gniadkowski 2013.11.29 08:44  
sheriffonline:

Yes.i changed timeframe for1hour.but still it reads 30min tf datas.

You need to read all the information I posted . . .

RaptorUK:
. . . . and then read the documentation for iHigh() and iLow()
Keith Watford
Moderator
9624
Keith Watford 2013.11.29 08:45  
sheriffonline:

Yes.i changed timeframe for1hour.but still it reads 30min tf datas.



With your code it reads the shift of the current chart, not H1.

eg if the highest bar is shift 5 on the H1 chart, you are reading High[5] on the M30 chart which is obviously not what you want.

Raptor has already pointed you towards iHigh and iLow

Sherif Hasan
7290
Sherif Hasan 2013.11.29 13:35  
RaptorUK:

You need to read all the information I posted . . .


Yes. got it. works fine.


High0To11 = iHigh(NULL,PERIOD_H1,iHighest(NULL,PERIOD_H1,MODE_HIGH, ELEVENAM-ZEROAM+1,elevenAM));
Low0To11 = iLow(NULL,PERIOD_H1,iLowest(NULL,PERIOD_H1,MODE_LOW, ELEVENAM-ZEROAM+1,elevenAM));
To add comments, please log in or register