# How to get same time values of H1 & H4

166

```//H1 Calculations
H1HaOpen=iCustom(NULL,PERIOD_H1,"Heiken Ashi",Red,White,Red,White,2,1);
H1HaClose=iCustom(NULL,PERIOD_H1,"Heiken Ashi",Red,White,Red,White,3,1);
H1EMAprev = NormalizeDouble(iMA(NULL,PERIOD_H1,14,0,MODE_EMA,PRICE_CLOSE,1), Digits());

//H4 Calculations
H4HaOpen=iCustom(NULL,PERIOD_H4,"Heiken Ashi",Red,White,Red,White,2,1);
H4HaClose=iCustom(NULL,PERIOD_H4,"Heiken Ashi",Red,White,Red,White,3,1);
H4EMAprev = NormalizeDouble(iMA(NULL,PERIOD_H4,14,0,MODE_EMA,PRICE_CLOSE,1), Digits());```

Hello,

From above code when I am accessing previous candle on H1 it is give me values of 10:00 am candle but in H4 it is giving me values of 4:00 am candle. According to code its right but logically it should give me same time value.

What logic should I use for getting H1 & H4 value of same time?

Moderator
8388

```datetime time_H1=iTime(_Symbol,PERIOD_H1,bar_number);

datetime time_H4=iTime(_Symbol,PERIOD_H4,bar_number);```
166

Marco vd Heijden:

its showing date. What I am suppose to do is I want to check if

H1 HA Last Candle Close value > H1 Last Candle EMA

&&

H4 HA Last Candle Close value > H4 Last Candle EMA

• This logic is fine Say suppose right now H1 current active candle is 10am candle but in H4 current active candle is 8am in that candle I am getting data of 10am which is fine.
• When in H1 I access last candle value it will give me value of 9am candle which is also fine Now when in H4 I will try to access value of last candle I will get data of 4am candle. Now the problem begin If i will compare 9am candle values with 4am candle values now you can think what disaster my EA can create in this situation.
HOW CAN I SORT OUT THIS?
Moderator
8388

kumaillakhani:

Hello,

What logic should I use for getting H1 & H4 value of same time?

You can compare datetimes but in this case there is no use to that.

Unless you understand this:

```datetime time_H1=iTime(_Symbol,PERIOD_H1,bar_number);

datetime time_H4=iTime(_Symbol,PERIOD_H4,bar_number);```

And then

```if(time_H1 == time_H4)
{
Print("Same Candle Time");
}```

for a close use

`double close=iClose(_Symbol,PERIOD_H4,bar_number);`