Batuhan:
..., the first row is always replaced by the values coming with the next calls of the function.
By calling FileOpen you reset the file cursor to the beginning. It's like opening a text in Word and placing the cursor to the start. Then you write a line and close it. The previous line is overwritten.
You need to open and close the file outside the log function like so:
int LogHandle; int OnInit() { LogHandle = FileOpen("abc.txt", FILE_READ|FILE_WRITE|FILE_TXT); if(LogHandle==INVALID_HANDLE) { PrintFormat("Failed to open %s file, Error code = %d", "abc.txt", GetLastError()); return INIT_FAILED; } return INIT_SUCCEEDED; } void OnDeinit(const int reason) { FileClose(LogHandle); } void Log_On_Chart(string labelText, color labelColor) { FileWrite(LogHandle, labelText); //FileWrite(LogHandle, labelText + "\n"); <-- "\n" is done automatically by FileWrite .... .... }
lippmaje:
By calling FileOpen you reset the file cursor to the beginning. It's like opening a text in Word and placing the cursor to the start. Then you write a line and close it. The previous line is overwritten.
You need to open and close the file outside the log function like so:
Thanks a lot lippmaje.
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
I want to save the labelText parameter of this function into a .txt file in rows, but "\n" does not work here, the first row is always replaced by the values coming with the next calls of the function.
How can I write the values of this parameter in a .txt file in rows?
Thanks.