
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
This is the section that open the file and close the file :
I use the standard MQL4 file functions, not DLL calls.
Can you add the following and report back what the output is please . . .
Have you confirmed that the file exists in the correct directory ? it no longer should be in experts\files . . . . it has to be in MQL4\Files you can find the correct MQL4 folder from MT4 by clicking File > Open data Folder
Orderticket is an int, StringLen expects a string
so if the number of digits < 7 (like in the tester) the call fails. > 7 leading digits are removed?
Try IntegerToString( OrderTicket(), 7, '0') + ".DAT" // 12345 -> 0012345.DAT
Can you add the following and report back what the output is please . . .
Have you confirmed that the file exists in the correct directory ? it no longer should be in experts\files . . . . it has to be in MQL4\Files you can find the correct MQL4 folder from MT4 by clicking File > Open data Folder
Can you add the following and report back what the output is please . . .
Have you confirmed that the file exists in the correct directory ? it no longer should be in experts\files . . . . it has to be in MQL4\Files you can find the correct MQL4 folder from MT4 by clicking File > Open data Folder
Dear RaptorUK,
Here I attached the file from the log following the Print statement.
I am aware that the folder structure has been changed in build 610. But then, the terminal client program should adjust it automatically because I use the default folders.
Thank you for your help.
Orderticket is an int, StringLen expects a string
so if the number of digits < 7 (like in the tester) the call fails. > 7 leading digits are removed?
Try IntegerToString( OrderTicket(), 7, '0') + ".DAT" // 12345 -> 0012345.DAT
Dear WHRoder,
I tried your suggestion and It still gives me the same error code: 5004. You pointed out a good info that orderticket returns int. But then, the old client terminal program (build 580 something) didn't return any compilation error nor runtime error. This error code 5004, as I mentioned before, doesn't seem to affect my EA performance at all. my EA still can open and close position at the correct condition.
I use the default directory, I don't specify a specific directory. I could see the files are there but still it fails to fileopen them. To add more confusion, It does not fail all the time. Most of the times, it succeed to fileopen. I have add another condition to test if it succeed to fileopen. The success rate is around 10 : 1 ratio where the 1 is the fileopen fails.
Thank you for your help anyway.
what version are you using
& maybe its a UAC issue
As WHRoeder said above.. if you are using the tester and it is not using a ticket number that contains at least 7 digits then you are asking it to look for as substring starting at the 6 minus 7(ticketString-7) or -1 position.. which will make it fall. Also you mentioned the 'default' folder.
The 'default' folder has changed from what it used to be. I will have to assume that when you say 'default' you are talking about the new 'default' folder at Mql4/files.. not at the old experts/files.
Make sure that you took the suggestion above and used the file>Open Data Folder and looked in the actual location that your platform is using. It may be over in users/appdata if you are using UAC as has been suggested also... which is fine as long as you are aware of it and adjust your paths accordingly if need be.
If it is trading properly apparently this part of the code is just for record keeping and logging and not an integral part of the strategy. Hope some of these suggestions help you get it running error free.. Welcome to the Forum!
PipPip...Jimdandy
what version are you using
& maybe its a UAC issue
the current client terminal I am using is build 610.
As WHRoeder said above.. if you are using the tester and it is not using a ticket number that contains at least 7 digits then you are asking it to look for as substring starting at the 6 minus 7(ticketString-7) or -1 position.. which will make it fall. Also you mentioned the 'default' folder.
The 'default' folder has changed from what it used to be. I will have to assume that when you say 'default' you are talking about the new 'default' folder at Mql4/files.. not at the old experts/files.
Make sure that you took the suggestion above and used the file>Open Data Folder and looked in the actual location that your platform is using. It may be over in users/appdata if you are using UAC as has been suggested also... which is fine as long as you are aware of it and adjust your paths accordingly if need be.
If it is trading properly apparently this part of the code is just for record keeping and logging and not an integral part of the strategy. Hope some of these suggestions help you get it running error free.. Welcome to the Forum!
PipPip...Jimdandy
As I have replied to WHRoeder, I have followed his suggestion and it still gives me the same error code 5004.
For the default folder, I am aware that folders structure has changed in build 610. I have recompiled my EA and I never specified my own folders. So, I assumed that the EA would create and look for the DAT files in the client terminal default folders. And it is confirmed that most of the time, the FILEOPEN succeeds. Only 10% of the same statement fails. (I am using simple if statement to test whether it succeeds).
Cheers,
Dear RaptorUK,
Here I attached the file from the log following the Print statement.
I am aware that the folder structure has been changed in build 610. But then, the terminal client program should adjust it automatically because I use the default folders.
Thank you for your help.
There was no file attached . . .
Have you confirmed that the file you are trying to read from actually exists ? please look in the correct folder and check . . . one other thing, why do you have a function called filewriting() to READ from a file ?