Errors, bugs, questions - page 74

 

While testing the Expert Advisor, I accidentally came across the Sleep() function in the tester which I think does not work correctly. The point is as follows:

the Expert Advisor closes all positions at 23:00 if the total profit is higher than the specified one (the CloseAll() function). After the next position is closed, a 10 second delay is introduced by Sleep(10000).

Here is what we have in the log:

FP 0 PriceChannel_multi (2) (EURUSD,H1) 04:31:04 CloseAll Profit: 3030.66
JD 0 Trade 04:31:04 instant sell 0.80 EURAUD at 1.56474 (1.56474 / 1.56558 / 1.56474)
JH 0 Trades 04:31:04 deal #85 sell 0.80 EURAUD at 1.56474 done (based on order #85)
HL 0 Trade 04:31:04 deal performed [#85 sell 0.80 EURAUD at 1.56474]
HI 0 Trade 04:31:04 order executed sell 0.80 EURAUD at 1.56474 [#85 sell 0.80 EURAUD at 1.56474]
QE 0 PriceChannel_multi (2) (EURUSD,H1) 04:31:04 position by EURAUD to be closed
PN 0 PriceChannel_multi (2) (EURUSD,H1) 04:31:04 23:0:0
FG 0 PriceChannel_multi (2) (EURUSD,H1) 04:31:04 Sleep 10 cek.
RO 0 PriceChannel_multi (2) (EURUSD,H1) 04:31:04 23:0:0
QD 0 Trade 04:31:04 buy 1.00 USDJPY at 90.444 (90.417 / 90.444 / 90.417)
NS 0 Trades 04:31:04 deal #86 buy 1.00 USDJPY at 90.444 done (based on order #86)
MJ 0 Trade 04:31:04 deal performed [#86 buy 1.00 USDJPY at 90.444]
JS 0 Trade 04:31:04 order executed buy 1.00 at 90.444 [#86 buy 1.00 USDJPY at 90.444]
JL 0 PriceChannel_multi (2) (EURUSD,H1) 04:31:04 position by USDJPY to be closed
JI 0 PriceChannel_multi (2) (EURUSD,H1) 04:31:04 23:0:0
PN 0 PriceChannel_multi (2) (EURUSD,H1) 04:31:04 Sleep 10 cek.
DF 0 PriceChannel_multi (2) (EURUSD,H1) 04:31:04 23:0:0
QN 0 Trade 04:31:04 buy 0.80 AUDUSD at 0.90001 (0.89967 / 0.90001 / 0.89967)
IH 0 Trades 04:31:04 deal #87 buy 0.80 AUDUSD at 0.90001 done (based on order #87)
KQ 0 Trade 04:31:04 deal performed [#87 buy 0.80 AUDUSD at 0.90001]
RL 0 Trade 04:31:04 order executed buy 0.80 at 0.90001 [#87 buy 0.80 AUDUSD at 0.90001]
EG 0 PriceChannel_multi (2) (EURUSD,H1) 04:31:04 position by AUDUSD to be closed
LP 0 PriceChannel_multi (2) (EURUSD,H1) 04:31:04 23:0:0
JI 0 PriceChannel_multi (2) (EURUSD,H1) 04:31:04 Sleep 10 cek.

NQ 0 PriceChannel_multi (2) (EURUSD,H1) 04:31:04 23:0:0

As we can see, the time before and after the lag is the same. But it only happens if TimeCurrent() == 0.

If not, the slip works fine. For example:

MD 0 PriceChannel_multi (2) (EURUSD,H1) 04:30:39 CloseAll Profit: 3382.28
KQ 0 Trade 04:30:39 ET ET 0.70 EURUSD at 1.44090 (1.44090 / 1.44108 / 1.44090)
IE 0 Trades 04:30:39 deal #27 sell 0.70 EURUSD at 1.44090 done (based on order #27)
CI 0 Trade 04:30:39 deal performed [#27 sell 0.70 EURUSD at 1.44090]
EL 0 Trade 04:30:39 order executed sell 0.70 at 1.44090 [#27 sell 0.70 EURUSD at 1.44090]
DH 0 PriceChannel_multi (2) (EURUSD,H1) 04:30:39
JR 0 PriceChannel_multi (2) (EURUSD,H1) 04:30:3923:0:7
MK 0 PriceChannel_multi (2) (EURUSD,H1) 04:30:39 Sleep 10 cek.
EP 0 PriceChannel_multi (2) (EURUSD,H1) 04:30:3923:0:15
DE 0 Trade 04:30:39 ET 0.80 AUDUSD at 0.91951 (0.91951 / 0.91993 / 0.91951)
CJ 0 Trades 04:30:39 deal #28 sell 0.80 AUDUSD at 0.91951 done (based on order #28)
HR 0 Trade 04:30:39 deal performed [#28 sell 0.80 AUDUSD at 0.91951]
HH 0 Trade 04:30:39 order executed sell 0.80 AUDUSD at 0.91951 [#28 sell 0.80 AUDUSD at 0.91951]
LS 0 PriceChannel_multi (2) (EURUSD,H1) 04:30:39 AUDUSD to be closed
QL 0 PriceChannel_multi (2) (EURUSD,H1) 04:30:3923:0:15
ED 0 PriceChannel_multi (2) (EURUSD,H1) 04:30:39 10 cek Sleep.
LO 0 PriceChannel_multi (2) (EURUSD,H1) 04:30:3923:0:25
DD 0 Trade 04:30:39 buy 0.60 EURAUD at 1.56727 (1.56632 / 1.56727 / 1.56632)
LN 0 Trades 04:30:39 deal #29 buy 0.60 EURAUD at 1.56727 done (based on order #29)
FK 0 Trade 04:30:39 deal performed [#29 buy 0.60 EURAUD at 1.56727]
IR 0 Trade 04:30:39 order executed buy 0.60 at 1.56727 [#29 buy 0.60 EURAUD at 1.56727]
RM 0 PriceChannel_multi (2) (EURUSD,H1) 04:30:39 position by EURAUD to be closed
FE 0 PriceChannel_multi (2) (EURUSD,H1) 04:30:3923:0:25
GN 0 PriceChannel_multi (2) (EURUSD,H1) 04:30:39 Sleep 10 cek.

QE 0 PriceChannel_multi (2) (EURUSD,H1) 04:30:3923:0:35

Code for closing a position:

if(m_trade[j].PositionClose(m_symbol[j].Name()))
           {
            PosCloseCount--;
            printf("Position by %s to be closed",m_symbol[j].Name());
            MqlDateTime  dt_struct;
            TimeCurrent(dt_struct);
            printf("%u:%u:%u",dt_struct.hour,dt_struct.min,dt_struct.sec);
            Sleep(10000);
            Print("Sleep 10 cek.");
            TimeCurrent(dt_struct);
            printf("%u:%u:%u",dt_struct.hour,dt_struct.min,dt_struct.sec);
           }

CloseAll function call:

   MqlDateTime  dt_struct;
   TimeCurrent(dt_struct);
   if(dt_struct.hour==2 3 && m_account.Profit()>InpProfitToClose)
     {
      Trade=false;Print("CloseAll Profit: ",m_account.Profit());
      while(PositionsTotal()>0)
         CloseAll();

If we change the condition to

if(dt_struct.hour==23 && dt_struct.min>0 && m_account.Profit()>InpProfitToClose)
there is no error.
Документация по MQL5: Общие функции / Sleep
Документация по MQL5: Общие функции / Sleep
  • www.mql5.com
Общие функции / Sleep - Документация по MQL5
 
joo:
So, my message is not in vain, as I already thought?

Yes. We've fixed the StringToTime behaviour. Thank you.

 
Valmars:

While testing the Expert Advisor, I accidentally came across the Sleep() function in the tester which I think does not work correctly. The point is as follows:

Very interesting. Let's see.
 
I open the "News" tab and there's... - it's the wrong news. Am I missing something?
 
x100intraday:
I open the "News" tab and there... - it's the wrong news. Am I missing something?

Set the languages in which you want to receive the news.


 
Rosh:

Set the languages in which you want to receive the news.


It's not. It's kinda sprinkled with mt5 forum "news", it has nothing to do with forex news. Not just pro-auto updates recently, but I downloaded the mt5 distribution afresh and installed it, it's been almost a week now. I don't know how it was during the week, because I didn't go into the "News" tab, but I've discovered it now:

Weird financial news

 
x100intraday:

It's not. It's kind of sprinkled with mt5 forum "news", it has nothing to do with forex news. I haven't just pro-auto-uploaded it recently, I downloaded the mt5 distribution again and installed it, it's been almost a week now. I don't know how it was during the week because I didn't get into the "News" tab, but I've discovered it now:

This is our demo server broadcasting MQL5.com news instead of missing forex news (we have no right to distribute someone else's news for free).

If you don't want to see them, just uncheck the appropriate box in the news categories section of the right-click menu.

 

After the automatic update, the previously working EA started giving messages that it could not copy the timeseries. The problem was solved by unloading the EA and loading it again. Question: should this result of automatic update be expected always or is it a terminal error, which will be eliminated?

Документация по MQL5: Программы MQL5 / Выполнение программ
Документация по MQL5: Программы MQL5 / Выполнение программ
  • www.mql5.com
Программы MQL5 / Выполнение программ - Документация по MQL5
 
Yedelkin:

After the automatic update, the previously working EA started giving messages that it could not copy the timeseries. The problem was solved by unloading the EA and loading it again. Question: should this result of automatic update be expected always or is it a terminal error, which will be eliminated?

Please give more details (logs, screenshots, etc.).

Without this, it is not possible to give an informed answer.

 
Renat:

Provide more details (logs, screenshots, etc.), please.

Without this, it is impossible to give a reasonable answer.

OK. Demo account on MQ server, log file is attached (2010729.log), time of start of automatic update is 20:54, at 22:36 I deleted Expert Advisor myself and uploaded it after one minute.

There is a simple type check in EA:

if(CopyHigh(Symbol(),0,0,bars,high)<bars || CopyClose(Symbol(),0,0,bars,close)<bars || CopyLow(Symbol(),0,0,bars,low)<bars || CopyTime(Symbol(),0,0,bars,time)<bars)
  {
   Print("Can't copy timeseries!");
   return;
  }

Accordingly, after automatic update messages went (file 20100729copy.log). In general, this has occurred before, but somehow did not pay attention.

After reloading the Expert Advisor, the lines of open and stop-loss prices in the chart have also disappeared.

May I add anything else to what has been said?

Reason: