Error Code 5004

 
Was trying to bring the value of ZigzagBuffer in my EA by writing the value to a file, in the indicator and then reading it from the file, into my EA.  Was able to write to file, but when trying to read, I get error code 5004.  Below is the code I used.
      // ----------------------------------------------------------------------------- FileWrite ZigzagBuff ----------------

       {
       ZigzagBuffI=FileOpen("ZigzagBuff", FILE_CSV|FILE_WRITE, ';');
       
       if(ZigzagBuffI>0)
       {FileWrite(ZigzagBuffI, ZigzagBuff);
       FileClose(ZigzagBuffI);}
       }

// -------------------------------------------------------------------------------------------------------------  




// ----------------------------------------------------------------------------- File ZigzagBuff Read ----------------  


        double ZigzagO;
        double ZigzagV;
        ZigzagO=FileOpen("ZigzagBuff"+" .txt",FILE_CSV|FILE_READ,';');
        if(ZigzagO>0)
        {ZigzagV = FileReadNumber(ZigzagO);
        FileClose(ZigzagO);
        Zigzag = ZigzagV;}     
        
        if(ZigzagO<1)       
        {Alert("ZigzagBuff error is:  ",GetLastError());}          
        
 

Yellowbeard: Was trying to bring the value of ZigzagBuffer in my EA by writing the value to a file, in the indicator and then reading it from the file, into my EA. 

Was able to write to file, but when trying to read, I get error code 5004.

  1. Why are you doing that instead of just reading from the buffer with iCustom? Detailed explanation of iCustom - MQL4 forum
  2. You wrote the file "ZigZagBuff"
    ZigzagBuffI=FileOpen("ZigzagBuff", FILE_CSV|FILE_WRITE, ';');
  3. You try to read the file "ZigZagBuff<space>.txt"
    ZigzagO=FileOpen("ZigzagBuff"+" .txt",FILE_CSV|FILE_READ,';');
  4. And you wonder why you get:

    5004

    ERR_FILE_CANNOT_OPEN

    Cannot open file

 

Yeah, I figured it out.  I removed the "+" .txt" from the read statement and now no problems.  Maybe I need glasses!


Thanks!



Reason: