Errors, bugs, questions - page 2238

 
fxsaber:

It happens that the last tick received 16 seconds ago is not seen as relevant to OrderSend. This must be a bug after all.

This bug

Forum on trading, automated trading systems & strategy testing

Libraries: MT4Orders

fxsaber, 2018.07.24 09:46

Updated script in app. Quickly finds, for example, problems like this
2018.07.24 10:24:19.177 Trades  '35247942': market buy 0.01 USDHKD
2018.07.24 10:24:19.246 Trades  '35247942': failed market buy 0.01 USDHKD [No prices]
2018.07.24 10:24:19.246 Trades  '35247942': buy limit 0.01 USDHKD at 7.83618
2018.07.24 10:24:19.315 Trades  '35247942': failed buy limit 0.01 USDHKD at 7.83618 [No prices]
2018.07.24 10:24:19.316 Trades  '35247942': buy stop 0.01 USDHKD at 7.85618
2018.07.24 10:24:19.384 Trades  '35247942': failed buy stop 0.01 USDHKD at 7.85618 [No prices]

In about a minute you can reproduce with this script on ForexTimeFXTM-Demo01 if you enable all symbols in Market Overview before running.

 
Ilyas:

This is a system limitation (WinAPI).

Here are the correct flags to make your code work:

come on )

we checked - Windows can open the file, but the script cannot. the problem is with the FILE_SHARE_READ flag

 
fxsaber:

Please fix FileLoad

Thanks for the post.

Added FILE_FLAG_SHARE_READ | FILE_FLAG_SHARE_WRITE flags to FileLoad/FileSave function implementation

Be careful, when writing and reading the same file at the same time, the synchronisation has to be organised correctly, because the result of reading will be undefined.

 
Ilyas:

Thanks for the message.

Added FILE_FLAG_SHARE_READ | FILE_FLAG_SHARE_WRITE flags to FileLoad/FileSave function implementation

Be careful, when writing and reading the same file at the same time, the synchronisation has to be organised correctly, because the result of reading will be undefined.

Thanks for the correction, the timing rake shouldn't be affected.

 
TheXpert:

come on )

The problem is with the FILE_SHARE_READ flag.

I recommend reading https://docs.microsoft.com/en-us/windows/desktop/FileIO/creating-and-opening-files

Creating and Opening Files
Creating and Opening Files
  • 2018.05.31
  • Michael Satran
  • docs.microsoft.com
Considerations for creating or opening a file by using the CreateFile function.
 

How to deal with this fact?

Forum on trading, automated trading systems and trading strategy testing

Bugs, bugs, questions

fxsaber, 2018.07.23 16:48

Clearly a bug as with such flags third party applications read the file without any problem.


Such files.

FILE_READ | FILE_WRITE | FILE_IS_TEXT | FILE_SHARE_READ

I view in TotalCommander without FileClose. Without FILE_SHARE_READ it doesn't work.

 
Ilyas:

I recommend reading it

Yes, I was just about to throw in.

I admit I was wrong. if the first handle is open for writing, the second must add the FILE_SHARE_WRITE flag

but there is another comment from a100 that has no record at all
 
Ilyas:

The opener cannot use the FILE_SHARE_WRITE (allow writing) flag for reading, because there is a writer.

This is a system limitation (WinAPI).

Here are the correct flags at which your code will work:

I read MSDN too. Explain, is it Microsoft doesn't know English or they don't read their documentation themselves, or is it the last option - the flags in MQL are named similar to WinApi but work in a different way?

Taken from here - https://docs.microsoft.com/en-us/windows/desktop/api/FileAPI/nf-fileapi-createfilea

FILE_SHARE_READ -Enables subsequent open operations on a file or device to request read access.Otherwise, other processes cannot open the file or device if they request read access.

FILE_SHARE_WRITE -Enables subsequent open operations on a file or device to request write access.Otherwise, other processes cannot open the file or device if they request write access.

Therefore, the first program only needs to set FILE_SHARE_READ for the second to read. FILE_SHARE_WRITE must be set only if it is known that the second program will also write to the file.

CreateFileA function
CreateFileA function
  • 2018.06.14
  • windows-sdk-content
  • docs.microsoft.com
Creates or opens a file or I/O device. The most commonly used I/O devices are as follows:\_file, file stream, directory, physical disk, volume, console buffer, tape drive, communications resource, mailslot, and pipe.
 

Question for the developers.

There is a synchronisation function:

//+------------------------------------------------------------------+
//| Проверка синхронизации символов                                                                                             |
//+------------------------------------------------------------------+
bool CheckSync()
        {
         //--- Проверка синхронизации символов
         if( !SymbolIsSynchronized( inpSymbol_1 ) )
                {
                 Print( __FUNCTION__,": ОШИБКА #",GetLastError(),": SymbolIsSync("+inpSymbol_1+") = false!" );
                 return( false );
                }
         if( !SymbolIsSynchronized( inpSymbol_2 ) )
                {
                 Print( __FUNCTION__,": ОШИБКА #",GetLastError(),": SymbolIsSync("+inpSymbol_2+") = false!" );
                 return( false );
                }
         //--- Если символы синхронизированы
         return( true );
        }

I sometimes get this error with it:

2018.07.24 15:14:27.415 Indicator (USDJPY,M5)   CheckSync: ОШИБКА #4014:  SymbolIsSync(EURGBP) = false!

I.e. the indicator runs on USDJPY, and I get an error with EURGBP symbol. At the same time there is an open EURGBP chart in the terminal.

Error 4014 says that:

System function is not allowed to be called

How can it be?

 
TheXpert:

Yes, I was just about to throw in.

I admit I was wrong. if the first handle is open for writing, the second must add FILE_SHARE_WRITE flag

but there is also a comment from a100 that has no record at all.
In my case ServiceDesk now writes that it cannot play... need help from the room ... later I will describe how to do it ...