FileWrite doesnt write

 

Hello I am trying to make an Ea that write to a CSV file but I have been trying and dont find where is the error.

This is my first mql4 Code, so I hope you can help. I dont know if it has anything to do but I get 4105 as Error Code.

It compiles, also the world "open" that I placed inside the if of the FileWrite function appears in the journal, so I really have no idea.

There you have the entire code just in case. Thanks in Advance.

//+------------------------------------------------------------------+
//|                                             MarketConditions.mq4 |
//|                      Copyright © 2009, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
int Counter=0;
  int handle;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
  
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
    
  datetime orderOpen=OrderOpenTime();
  

    
    
    if(Counter==0) // this conditional-if controls the FileWrite code and allows the FileWrite code to be accessed only one time
{ // Begin Brace for Counter conditinal-if

Counter=1;

handle=FileOpen("mac.csv", FILE_CSV|FILE_READ|FILE_WRITE, ';');
if(handle>0)
{

//---- add data to the end of file
FileWrite(handle,"TIME_MINUTES","TIME_SECONDS","Fibo_1","Fibo_2");
Print(" open"); //this word appears in the journal, so the code gets here.
     FileWrite(handle, "viva viva");
     Print(GetLastError());
     FileClose(handle);



handle=0;
}else{Print("didnt open");}


} // End Brace for Counter conditional-if


//----
   return(0);
  }
//+------------------------------------------------------------------+
 
Before OrderOpenTime();
you should SelectOrder(.....) first.
 
DxdCn wrote >>
Before OrderOpenTime();
you should SelectOrder(.....) first.

Thank you very much.. But do you have any idea why it doesnt write a word to the cvs file??

btw I have corrected what you suggested

 

Writes properly.

Where are you looking for your file "mac.csv"?

 

Yes you r right. I didnt know where it was suppposed to be placed,now I found it.

Thanks