How to - Execute once a day at certain hour?

Hi guys.
Got a small question.
I want to execute a cetain code block just once a day at 00:01.
Its Daily time frame - if its importent.
How do I do that?

Thanks !!


int 
   Open_Hr = 0;

int start()
{
   if(New_Bar()){
      if(Hour()==Open_Hr){
      ..............do your code here........
      }
   }
   return(0);
}
//+------------------------------------------------------------------+
bool New_Bar()
{
   static datetime New_Time=0;
   if(New_Time!=Time[0]){
      New_Time=Time[0];
      return(true);
   }
   return(false);
}

This will do your code at the open of the 00:00 bar…will that extra minute make a difference?

Run on the hourly TF.

No the extra minute is not that importent but why cant I run it on Daily TF?

Thank you.

Actually, you can run it on the daily TF, however, by running the hourly TF, you can have it open a trade once a day at the hour of your choice, rather than when the broker’s time clocks over to the next day.

If you use the D1 TF then you don’t need this line :-

if(Hour()==Open_Hr){

and its associated ‘}’ bracket.

Okay, Ill take your advice and stick with the H1 TF.

Thanks a lot !

Got another question.

I need to find out the close and open price of the previous day candle.
So I wrote this line :

double Dclose = Close[iClose(NULL,0,1)];

And for some reason I got an error messege says:

"’[’ - array index is to be an integer.
same story for the open price line.

Any ideas why?

Yeah, iClose() returns a price(ie a double) and Close[] is expecting a candle number(ie an integer).

Use iClose if you are wanting data from an instrument or TF other than the current chart.

Just use Close[1] if you want last bar close on current pair & TF

Again thanks you so much =]

For some reason I got ordersend error 130 and I double checked SL and TP values.
But no metter Ill try figure it out.