Discussion of article "Step-by-Step Guide to Writing an Expert Advisor in MQL5 for Beginners" - page 11
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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 be opened, not waiting for a new tick, the same with closing?
Start a timer with the required frequency and check the occurrence of the required time in it.
Or calculate how long it needs to trigger (12:52:25 - start time) and set the exact interval.
Just don't run into a trade ban, the timer will trigger even when the market is closed.
And how to start the timer or how to set the exact interval, it should be written in the EA code?
Can I ask you if it is possible to program an Expert Advisor to open an Expert Advisor on a specific day of the week, so that it opens and closes positions on a specific day of the week?
Can I ask you if it is possible to program an Expert Advisor to open an Expert Advisor on a specific day of the week, so that it opens and closes positions on a specific day of the week?
Can I ask you if it is possible to program an Expert Advisor to open an Expert Advisor on a specific day of the week, so that it opens and closes positions on a specific day of the week?
We can.
Thank you, but I understood that when such and such an event occurs (the time I specified), the function should work, but for some reason it doesn't work.
The position does not open!!!?
extern int tp = 1000;
extern int sl = 1000;
extern double Lots = 0.2;
int ticket;
void OnStart()
{
datetime date1=D'2014.10.28.13.22.13';
if(OrdersTotal()==0)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,0,Bid-sl*Point,Bid+tp*Point,"",123,0,Red);
}
if (OrdersTotal( )==1 && Hour( )==13 && Minute( )==23 && Seconds ( )>=00)
{
bool select1=OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
bool close1=OrderClose(ticket,Lots,Bid,20,Green);
}
return(0);
}
Let me explain that I need that every week (once a week), on such and such a day, at such and such an hour, at such and such a second, a position is opened and then closed a few seconds later.