Download MetaTrader 5

How to create a file

To add comments, please log in or register
luo jun
143
luo jun  
 void OnTick()

{

  string FileName = TerminalInfoString(TERMINAL_DATA_PATH)+"\\"+"abc.txt";

  if(MyHandle == 0)

  {

    Print(FileName);

    MyHandle=FileOpen(FileName,FILE_WRITE|FILE_TXT);

    Print("MyHandle:",MyHandle);

  }

  

  if(MyHandle > 0)

  {

    FileWrite(MyHandle, string(AccountEquity()));

    FileClose(MyHandle);     

  } 

 

The log shows bellow info. And the error code is 5002. Whats the problem? 

EURUSDpro,M5: D:\MetaTrader 4\abc.txt

EURUSDpro,M5: MyHandle:-1 

Alain Verleyen
Moderator
32022
Alain Verleyen  

Forum on trading, automated trading systems and testing trading strategies


Hello,

Please use the SRC button when you post code. Thank you.


This time, I edited it for you.


Alain Verleyen
Moderator
32022
Alain Verleyen  
luo jun:

The log shows bellow info. And the error code is 5002. Whats the problem? 

EURUSDpro,M5: D:\MetaTrader 4\abc.txt

EURUSDpro,M5: MyHandle:-1 

Please read the documentation more carefully.

  string FileName = "abc.txt";
To add comments, please log in or register