CurTime() problems - build 186

 
Hi,

There seems to be an intermittent problem with the CurTime() function. Most of the time, it appears to work fine - however occasionally it returns a 0.

I discovered this because some of my orders were coming back with "order not placed - invalid trade parameters". I added in some code to display the various variables that are used to create an order and most of the time, the orders are place without a problem (see Expert log below). The "Attempting to place order" and "Expiry details" lines are the lines I added to the code to try and determine what the problem is. The expiry date is calculated using the following line of code:

dateTime expiry = CurTime() + (cancelOrderAfterPeriods * Period() * 60);

The log line "Expiry Details" basically displays CurTime(), cancelOrderAfterPeriods, Period(), and the total of the variables between the brackets (TotAdded), as shown below:

=================================================
11:58:48 Trader GBPCHF,H4: Attempting to place order: GBPCHF 3 2.80000000 2.25970000 2.26440000 2.25040000 1133107250
11:58:48 Trader GBPCHF,H4: Expiry details: CurTime(): 1132704050 canOrdAftPer: 28 Period(): 240 TotAdded: 403200
11:58:49 Trader GBPCHF,H4: open #2570276 sell limit 2.80 GBPCHF at 2.2597 sl: 2.2644 tp: 2.2504 ok

11:58:50 Trader EURCHF,H4: Attempting to place order: EURCHF 2 6.60000000 1.54790000 1.54590000 1.55180000 1132977652
11:58:50 Trader EURCHF,H4: Expiry details: CurTime(): 1132704052 canOrdAftPer: 19 Period(): 240 TotAdded: 273600
11:58:51 Trader EURCHF,H4: open #2570277 buy limit 6.60 EURCHF at 1.5479 sl: 1.5459 tp: 1.5518 ok

11:59:05 Trader USDJPY,H4: Attempting to place order: USDJPY 3 3.50000000 119.16000000 119.50000000 118.49000000 1132963267
11:59:05 Trader USDJPY,H4: Expiry details: CurTime(): 1132704067 canOrdAftPer: 18 Period(): 240 TotAdded: 259200
11:59:05 Trader USDJPY,H4: open #2570299 sell limit 3.50 USDJPY at 119.1600 sl: 119.5000 tp: 118.4900 ok
==================================================

However, sometimes curTime() seems to return a 0, as shown in the log results below. This then ends up creating a dateTime number that doesn't really make sense, resulting in the "invalid trade parameters" error. If another attempt is then made to place that same order, it generally works fine again (see below):

====================================================
23:57:59 Trader GBPCHF,H4: Attempting to place order: GBPCHF 2 3.00000000 2.25760000 2.25320000 2.26640000 403200
23:57:59 Trader GBPCHF,H4: Expiry details: CurTime(): 0 canOrdAftPer: 28 Period(): 240 TotAdded: 403200
23:58:00 stdlib GBPCHF,H4: loaded successfully
23:58:00 Trader GBPCHF,H4: Alert: GBPCHF-H4 - BUY order could not be placed! invalid trade parameters
23:58:01 Trader GBPCHF,H4: Alert: START(): Warning Error...\nGBPCHF-H4 - BUY order could not be placed! invalid trade parameters

23:58:01 Trader GBPCHF,H4: Attempting to place order: GBPCHF 2 3.00000000 2.25760000 2.25320000 2.26640000 1133150403
23:58:01 Trader GBPCHF,H4: Expiry details: CurTime(): 1132747203 canOrdAftPer: 28 Period(): 240 TotAdded: 403200
23:58:01 Trader GBPCHF,H4: open #2577502 buy limit 3.00 GBPCHF at 2.2576 sl: 2.2532 tp: 2.2664 ok
================================
 
Hi

I also get it that CurTime return 0 or "1970.01.01 00:00" but it is very rare ( about once or twice per day per pc ) what broker's server do you use ? I've seen it mainly on Interbank

Barry


Coen van waar is jy ?
 
any details?
may be reconnect or change account
 
Hi Slawa,

Afraid I've got no more details than that.. It definitely isn't a "change account" and since the Expert must be running to put out the above log file information, it definitely can't be a disconnect/reconnect...

As Barrys also mentions above, it happens quite rarely (in my case, several times a week when running an Expert continuously) so would probably be quite difficult to track down. If I find any more clues to the problem, I'll let you know. Maybe it's possible at your end to set up a PC that runs an Expert that just runs CurTime() and writes the results to a log file together with a date/time stamp?
 
Hi Barrys,

I'm experiencing these problems with MetaQuotes own server - I'm basically just running my Expert on a demo account at the moment on one of their servers...

En op antwoord op je andere vraag - ik woon tegenwoordig in Nieuw Zeeland.
 
Hi Slawa,

Well, I've just had the problem again.. The only possible clue to that problem that I can see at this stage is that it only seems to occur close to an hour change. In the above example, the time was 23:58. When the problem occurred again today, it was 11:58 (see below)....

11:58:10 Trader USDCHF,H4: Attempting to place order: USDCHF 2 2.90000000 1.31810000 1.31360000 1.32720000 100800
11:58:10 Trader USDCHF,H4: Expiry details: CurTime(): 0 canOrdAftPer: 7 Period(): 240 TotAdded: 100800
11:58:11 stdlib USDCHF,H4: loaded successfully
11:58:11 Trader USDCHF,H4: Alert: USDCHF-H4 - BUY order could not be placed! invalid trade parameters
11:58:27 Trader USDCHF,H4: Alert: START(): Warning Error...\nUSDCHF-H4 - BUY order could not be placed! invalid trade parameters
11:58:27 Trader USDCHF,H4: Attempting to place order: USDCHF 1 2.90000000 1.32030000 1.32480000 1.31120000 0
11:58:27 Trader USDCHF,H4: Expiry details: CurTime(): 1133136026 canOrdAftPer: 7 Period(): 240 TotAdded: 100800
11:58:27 Trader USDCHF,H4: open #2610856 sell 2.90 USDCHF at 1.3203 sl: 1.3248 tp: 1.3112 ok
 
Oh yeah - This problem only started appearing after either build 182, 183 or 184 - before that I hadn't had the problem and I've been running exactly the same expert over all this time - i.e. nothing has changed as far as my Expert is concerned.
 
Good day to all,
I also have noticed this behavior. I write fake indicators to test behavior of given functions. I print results and examin log files. I was also supprised when CurTime() returned 0.
I suppose, it is time for MetaQuotes to do some explaining and/or fixing.
 
problem is known. we cannot fix it because cannot reproduce it
 
reproduced and fixed
 
Hi Slawa,
I would appreciate you sharing your findings.