Discussion of article "Step-by-Step Guide to Writing an Expert Advisor in MQL5 for Beginners" - page 10

 
pisenysh:

when compiling it gives an error

return value of 'OrderSend' should be checked my_first_ea.mq5 211 10

what could be wrong?

Is this an error for sure?
 
pisenysh:

when compiling it gives an error

return value of 'OrderSend' should be checked my_first_ea.mq5 211 10

what can be wrong?

The compiler says that it is necessary to process the result of the trade function execution.
 

Hello! Can I ask you a question? Does the Expert Advisor trade with accuracy up to seconds? That is, if I need to open and close trades not just in a certain hour and minute, but also in a certain second?

 
Grenjohn:

Hello! Can I ask you a question? Does the Expert Advisor trade with accuracy up to seconds? That is, if I need to open and close trades not just in a certain hour and minute, but also in a certain second?

A minute consists of a hundred seconds - which one do you want?
 
server:
A minute consists of a hundred seconds - which one do you want ?
It's in the annals ;)
 

I don't get it!? A minute consists of 60 seconds. I program the Expert Advisor to open a position for example at 12:30 and I need it to trigger at 45 seconds. When I set 12:30 everything works, the deal is opened, but when I try to add seconds it doesn't work!!!??

 

Here is the code itself:

extern int tp = 1000;

extern int sl = 1000;
extern double Lots = 0.01;
int ticket;
int start()
{
if(OrdersTotal( )==0 && Hour ( )==23 && Minute ( )==02 && Seconds ( )==30)
{

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,0,Bid-sl*Point,Bid+tp*Point,"",123,0,Red);
}
if (OrdersTotal( )==1 && Hour( )==23 && Minute( )==03 && Seconds ( )==30))
{
OrderSelect(ticket, SELECT_BY_TICKET,MODE_TRADES);
OrderClose(ticket,Lots,Bid,20,Green);
}
}
 
Grenjohn:

Here is the code itself:

extern int tp = 1000;

extern int sl = 1000;
extern double Lots = 0.01;
int ticket;
int start()
{
if(OrdersTotal( )==0 && Hour ( )==23 && Minute ( )==02 && Seconds ( )==30)
{

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,0,Bid-sl*Point,Bid+tp*Point,"",123,0,Red);
}
if (OrdersTotal( )==1 && Hour( )==23 && Minute( )==03 && Seconds ( )==30))
{
OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
OrderClose(ticket,Lots,Bid,20,Green);
}
}
Gy. Set the check Seconds() >= 30, because one second may slip quickly and not a single tick will arrive during it. PS It is desirable to style the code with the code style (SRC button).
 
Yes it works now, thank you very much! The real problem was the speed of the second, the tick didn't have time to go through it.
 

Can you tell me more please! Is it possible to open and close positions in Expert Advisors, clearly by time in seconds, regardless of ticks, like a regular timer. That is, if the clock is 12:52:25, then the position would open, and not wait for a new tick, as well as with closing?