EA send Order at same time all days

 

Dear All,

first of all thank you for this community. It is very interesting to read articles and suggestion.

I would like to have a very simple EA that send a SELL order on EU at 12.30 GMT time for some lots and different SL and TP.

Anyone can write me this little article?

Here my EAis not working .. some people can explain me or write it?

//+------------------------------------------------------------------+
//| Michele Ainardi |
//| Example of Time fixed orders |
//+------------------------------------------------------------------+

extern double TimeSell = 12.30; // It is the time when I want to Sell a pair
extern double Lots = 0.1;
extern double TakeProfit = 20;
extern double StopLoss =50;


//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{

int Cur_Hour=Hour();
double Cur_Min =Minute();
double Cur_time=Cur_Hour + Cur_Min/60;

if (Cur_time==TimeSell)
{
OrderSend(Symbol(),OP_SELL,0.1,Bid,3,Ask+StopLoss*Point,Ask-TakeProfit*Point);
}

}
// the end.

Thank you,

Michele

 
michele_ainardi:

Dear All,

first of all thank you for this community. It is very interesting to read articles and suggestion.

I would like to have a very simple EA that send a SELL order on EU at 12.30 GMT time for some lots and different SL and TP.

Anyone can write me this little article?

Here my EAis not working .. some people can explain me or write it?

//+------------------------------------------------------------------+
//| Michele Ainardi |
//| Example of Time fixed orders |
//+------------------------------------------------------------------+

extern double TimeSell = 12.30; // It is the time when I want to Sell a pair
extern double Lots = 0.1;
extern double TakeProfit = 20;
extern double StopLoss =50;


//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{

int Cur_Hour=Hour();
double Cur_Min =Minute();
double Cur_time=Cur_Hour + Cur_Min/60;

if (Cur_time==TimeSell)
{
OrderSend(Symbol(),OP_SELL,0.1,Bid,3,Ask+StopLoss*Point,Ask-TakeProfit*Point);
}

}
// the end.

Thank you,

Michele

Hello Michele,


in fact I am trying to solve the same problem: to send orders at a preset time every day.

I readed your EA, but I think the format of time "12.30" is wrong. I read quite a few examples of EA on the net, and I would try to declare the time with the datetime type of variables, or string.

So it would look like: 

string timestart = "12:30:00" ;

or datetime starttime = D'2008.09.15 12:30';


Like I said, I am still learning how to write the language...but at least try.


If you find the solution, could you keep me informed? Thanks in advance.


Steph1371

 
michele_ainardi wrote >>

Dear All,

first of all thank you for this community. It is very interesting to read articles and suggestion.

I would like to have a very simple EA that send a SELL order on EU at 12.30 GMT time for some lots and different SL and TP.

Anyone can write me this little article?

Here my EAis not working .. some people can explain me or write it?

//+------------------------------------------------------------------+
//| Michele Ainardi |
//| Example of Time fixed orders |
//+------------------------------------------------------------------+

extern double TimeSell = 12.30; // It is the time when I want to Sell a pair
extern double Lots = 0.1;
extern double TakeProfit = 20;
extern double StopLoss =50;


//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{

int Cur_Hour=Hour();
double Cur_Min =Minute();
double Cur_time=Cur_Hour + Cur_Min/60;

if (Cur_time==TimeSell)
{
OrderSend(Symbol(),OP_SELL,0.1,Bid,3,Ask+StopLoss*Point,Ask-TakeProfit*Point);
}

}
// the end.

Thank you,

Michele

Use the following code:

if (Hour()==12 && Minute()==30) OrderSend(.......);

You must refer to server time. Cheers.

Reason: