Download MetaTrader 5
To add comments, please log in or register
Join MQL5 Cloud Network. Improve your rating!
Paul
529
Paul 2014.09.03 19:29 
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());}          
        
whroeder1
13644
whroeder1 2014.09.04 00:17  

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

Paul
529
Paul 2014.09.04 12:38  

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


Thanks!



/
To add comments, please log in or register