How can I determin daily candlestick up or down

 

I am new to the mt4 programming. Can anyone please help me with this?


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

 

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");
   

}
 
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 }
 
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.

Could you please help me?

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];
      }
      
   }
   
 
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.

Could you please help me?

I do not know - whether I understood you correctly?

int currentHour=Hour();

for(int cnt=0;cnt<currentHour;cnt++)
{
   if(iOpen(NULL,PERIOD_D1,0)<iClose(NULL,PERIOD_H1,cnt)) { hour closed above the opening of the day }
   else { hour closed below the opening of the day }
}
Reason: