# How can I determin daily candlestick up or down

84

I'd like to know whether a daily candlestick is up or down. How to achieve in the programming?

84

So far, i only got the following codes:

```void start()
{
double dayOpen,hourClose;
int currentHour,currentMin;

double highHourClose;

currentHour=Hour();
currentMin=Minute();
dayOpen=iOpen(NULL,PERIOD_D1,0);
hourClose=iClose(NULL,PERIOD_H1,0);
if(currentHour==0&&currentMin==0)Print("New day start");

}
```
23210

phoenix1911:

I'd like to know whether a daily candlestick is up or down. How to achieve in the programming?

```if(iOpen(NULL,PERIOD_D1,0)<iClose(NULL,PERIOD_D1,0)) { current daily candlestick is up }
else { current daily candlestick is down }```
84

Alexander Voronkov:

Alex, Thank you so much.

Yes, this is the way to get daily open and close price. However, it wont be able to get the close price until the day ends.

So is it possible to compare hour candlesticks to find whether it is up or down?

e.g. I want to compare the hour close price with the day open price. The first hour the close price is higher than open price, meaning it up. And the second hour the close price is higher than the first close price, meaning it is up.

Till the time the hour candlestick close price is lower than day open price, meaning the day candlestick is down.

```void start()
{
double dayOpen,dayClose;
int currentHour,currentMin;

double hourClose[];
double highHourClose=0;

currentHour=Hour();
currentMin=Minute();
dayOpen=iOpen(NULL,PERIOD_D1,0);
dayClose=iClose(NULL,PERIOD_D1,0);

for(int cnt=0;cnt<23;cnt++)
{
hourClose[cnt]=iClose(NULL,PERIOD_H1,0);
if(hourClose[cnt]>=highHourClose)
{
highHourClose=hourClose[cnt];
}

}
```
23210

phoenix1911:

Alex, Thank you so much.

Yes, this is the way to get daily open and close price. However, it wont be able to get the close price until the day ends.

So is it possible to compare hour candlesticks to find whether it is up or down?

e.g. I want to compare the hour close price with the day open price. The first hour the close price is higher than open price, meaning it up. And the second hour the close price is higher than the first close price, meaning it is up.

Till the time the hour candlestick close price is lower than day open price, meaning the day candlestick is down.

```int currentHour=Hour();