if(!FileIsExist(mySpreadSheet,FILE_COMMON)){ //If the file does not exist, create file and add the date. The problem is here. int fileIsExistError = GetLastError(); PrintFormat("File does not exist. Error %d", fileIsExistError); //Returing 5020 Error file_handle = FileOpen(mySpreadSheet,FILE_CSV|FILE_READ|FILE_WRITE,',');For an obvious reason. You are looking in the common directory, but creating/updating it in the FILE directory.
For an obvious reason. You are looking in the common directory, but creating/updating it in the FILE directory.
Thanks William, I have rewritten both FILEOPEN handles this to
file_handle = FileOpen(mySpreadSheet,FILE_COMMON | FILE_READ | FILE_WRITE,',');
which has done the trick.
int orderHist = OrdersHistoryTotal()-1; if(!OrderSelect(orderHist,SELECT_BY_POS,MODE_HISTORY)){
-
Do not assume history has only closed orders.
OrderType() == 6, 7 in the history pool? - MQL4 programming forum (2017) -
Do not assume history is ordered by date, it's not.
Could EA Really Live By Order_History Alone? (ubzen) - MQL4 programming forum (2012)
Taking the last profit and storing it in a variable | MQL4 - MQL4 programming forum #3 (2020) -
Total Profit is OrderProfit() + OrderSwap() + OrderCommission(). Some brokers don't use the Commission/Swap fields. Instead, they add balance entries. (Maybe related to Government required accounting/tax laws.)
"balance" orders in account history - Day Trading Techniques - MQL4 programming forum (2017)Broker History FXCM Commission - <TICKET>
Rollover - <TICKET>>R/O - 1,000 EUR/USD @0.52 #<ticket> N/A OANDA Balance update
Financing (Swap: One entry for all open orders.)
-
Do not assume history has only closed orders.
OrderType() == 6, 7 in the history pool? - MQL4 programming forum (2017) -
Do not assume history is ordered by date, it's not.
Could EA Really Live By Order_History Alone? (ubzen) - MQL4 programming forum (2012)
Taking the last profit and storing it in a variable | MQL4 - MQL4 programming forum #3 (2020) -
Total Profit is OrderProfit() + OrderSwap() + OrderCommission(). Some brokers don't use the Commission/Swap fields. Instead, they add balance entries. (Maybe related to Government required accounting/tax laws.)
"balance" orders in account history - Day Trading Techniques - MQL4 programming forum (2017)Broker History FXCM Commission - <TICKET>
Rollover - <TICKET>>R/O - 1,000 EUR/USD @0.52 #<ticket> N/A OANDA Balance update
Financing (Swap: One entry for all open orders.)
No worries, thanks :)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have a file writing function which has been rewritten, specifying the data from the OrderHistory log.
It now checks to see if the file exists before deciding to either create a new file and write the relevant data into it, or find the existing file, go to the end of the file and write data.
For some reason it's not finding the file through the FileIsExist function, and so - as is programmed to do so - it creates a new file.
Yes, I have read the documentation on the FileIsExist function, I am aware of the 5019 error which confirms if the file is an actual file or a subdirectory, & which is not an issue in this case, as I have - as you will see in the text below - specified the FILE_COMMON flag.
I have also checked the Write to File Syntax documentation as well.
I don't see why it's not finding the file despite clearly specifying which directory to look for the file in, under FileIsExist.