Download MetaTrader 5

Send Order each day at hour 01:00

To add comments, please log in or register

Hello guys,

I have been working on a little script for days and I can't make it to work in my strategy tester. This is the concept:

1) If time = 01:00, sendorder()

2) if time = 23:00, closeorders()

3) no trading in weekends


The problem is that I can't find any good working IF statement that triggers the IF 01 hour or the IF 23hour. Please, could anybody just give me a step in the good direction?

Thanks if highly appreciated!!!


//==================================== my program
int start()  
if(Hour()==01)				//start loop at time 01:00
   if(OrdersTotal()<1){			//place only 1 order	
}//end start

//==================================== functions

int placeorders(){

int    ticket;//,expiration;
double point;

double TakeProfitLevel;
double StopLossLevel;
int et = TimeCurrent()+86400; //24hours
   TakeProfitLevel = Ask + TakeProfit*Point*10;   //0.00001 * 10 = 0.0001
   StopLossLevel = Ask - StopLoss*Point*10;
      ticket=OrderSend(Symbol(),OP_BUY, 0.01, Ask, 10*10, StopLossLevel, TakeProfitLevel, "My 1st Order!",et,clrNONE); 
      if(ticket<=0){ Print("De Error is volgende = ",GetLastError());}
      else { Print("ticket = ",ticket);  }
      //---- 10 seconds wait
//Print("new expiration time = ",TimeToStr(et,TIME_DATE|TIME_SECONDS));
Keith Watford
Keith Watford  

That is not the code that you are testing.

You declare your function as an integer, but do not return a value. It will not compile. 

To add comments, please log in or register