Closing price from another time-frame?

 

Hi,

I'm an amateur MQL4 programmer, so this question may sound very foolish to you, but I had to ask this, as I need the answer.


I'm coding an EA based on Daily time frame, and I know that Close[i] returns the closing price of the specified bar of that chart ("Daily" in this case).


But I also need the closing price values, of H4 time frame bars for my strategy, how can I do it, when I'm working on Daily charts?


Please help. I have come here to become "less foolish".


Thanks,

Siddhant Batra

 

Hi,

call iClose(Symbol(),PERIOD_H4,shift); You can call this from any TF. Use iBarshift on the Time[i] you're interested in. And insert it as shift on iClose.

H4 opens on 00:00:00, 04:00:00, 08:00:00, ..., 20:00:00 ~ closes at 03:59:59, 07:59:59, ....., 23:59:59 <-- to describe the range, but as you know, bar may closes a little late depending on tick arrival.

 
cameofx:

Hi,

call iClose(Symbol(),PERIOD_H4,shift); You can call this from any TF. Use iBarshift on the Time[i] you're interested in. And insert it as shift on iClose.

H4 opens on 00:00:00, 04:00:00, 08:00:00, ..., 20:00:00 ~ closes at 03:59:59, 07:59:59, ....., 23:59:59 <-- to describe the range, but as you know, bar may closes a little late depending on tick arrival.

The generosity of this forum never ceases to amaze me. In two simple lines, cameofx has given us priceless information. Thank you, cameofx.
 
You're welcome engcomp. Nice to hear some appreciation :)
 

Thanks a lot camoefx,


As a temporary remedy, I used iMA(Symbol(), PERIOD_H4, 1, 0, MODE_SMA, PRICE_CLOSE, 1); that is, a 1 day simple moving average of the H4 period.


But, obviously, yours is the right and logical approach and would follow that only.


Thanks a lot!

Regards,
Siddhant Batra

 

cameofx:

Hi,

call iClose(Symbol(),PERIOD_H4,shift); You can call this from any TF. Use iBarshift on the Time[i] you're interested in. And insert it as shift on iClose.

H4 opens on 00:00:00, 04:00:00, 08:00:00, ..., 20:00:00 ~ closes at 03:59:59, 07:59:59, ....., 23:59:59 <-- to describe the range, but as you know, bar may closes a little late depending on tick arrival.

i don't get it, how to get close price of higher/lower time frame in specific timeframe ?

at timeframe M5, i want to make indicator that count bollinger and closing price of higher timeframe M15 or M30

i try these but isn't working  closePrice15 = iClose(NULL,15,0);

                                         closePrice15 = iClose(NULL,15,iBarShift(NULL,15,Time[i]));

                                         upperBand15 = iBands(NULL,15,20,2,0,PRICE_CLOSE,MODE_UPPER,i);

                                         lowerBand15 = iBands(NULL,15,20,2,0,PRICE_CLOSE,MODE_LOWER,i);

example or code please.....


 
santosos, you should pass a different period to the indicators....