How to create a file

 
 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 

 

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.


 
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";
Reason: