fxseedtrading:
Hi,
I want to write data to a CSV file for analyzing. It writes effectively but only one valye, and not each value at each tick or bar. There is something i don't understand. Anyone can help me?
Here is my code, copied and adapted from mql5 reference. The write code is in a function, called in OnTick().
Thank you for advance. :)
Hi fxseedtrading,
Try this. Read the example of file's combination of flags https://www.mql5.com/en/docs/constants/io_constants/fileflags.
:D
//+------------------------------------------------------------------+ void OnTick() { //--- //--- Writing datas MqlTick Tick_tock; ResetLastError(); int file_handle = FileOpen("datas.csv",FILE_READ|FILE_WRITE|FILE_CSV); if (file_handle != INVALID_HANDLE) { if (SymbolInfoTick(Symbol(),Tick_tock)) { FileSeek(file_handle, 0, SEEK_END); FileWrite(file_handle,Tick_tock.time,DoubleToString(Tick_tock.ask),DoubleToString(Tick_tock.bid)); } else Print("SymbolInfoTick() failed, error = ",GetLastError()); FileClose(file_handle); } else Print("File open failed, error ",GetLastError()); //--- } //+------------------------------------------------------------------+

Documentation on MQL5: Standard Constants, Enumerations and Structures / Input/Output Constants / File Opening Flags
- www.mql5.com
Standard Constants, Enumerations and Structures / Input/Output Constants / File Opening Flags - Documentation on MQL5

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
Hi,
I want to write data to a CSV file for analyzing. It writes effectively but only one valye, and not each value at each tick or bar. There is something i don't understand. Anyone can help me?
Here is my code, copied and adapted from mql5 reference. The write code is in a function, called in OnTick().
Thank you for advance. :)