fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    Change semi-colons to commas in Write to file

    Questions & Answers
    2
    2
    701
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      richard96816 last edited by richard96816

      How do I change the semi-colons to commas in Write to file output?

      Also, can I get rid of the two extra fields at the beginning of each record, Time (local) and Time (server)?

      Thanks

      Edit: Write to file sends lots of duplicates of all trades to the file. Would be nice to clean that up too.

      1 Reply Last reply Reply Quote 0
      • fxDreema
        fxDreema last edited by

        This block is old, there are people using it and I don't feel like I want to change something in it that could break something for someone đŸ™‚

        You can try to make a custom block if you know a little bit of MQL đŸ™‚ At least you will be able to customize it as you wish. Here is how the current block looks like in https://fxdreema.com/studio/MQL4

        This is the code:

        string filename = Filename + ".csv";
        int handle      = FileOpen(filename, FILE_CSV|FILE_READ|FILE_WRITE, ';');
        
        if (handle == INVALID_HANDLE)
        {
           Print(filename," OPEN Error: ",ErrorMessage());
        
           ~error~
        }
        else
        {
           FileSeek(handle,0,SEEK_END);
        
           if (FileSize(handle)==0)
        	{
              FileWrite(handle,"Time (local)","Time (server)",C1Title,C2Title,C3Title,C4Title,C5Title,C6Title,C7Title,C8Title,C9Title,C10Title);
           }
        
           if(handle > 0)
           {
              FileWrite(handle,TimeToString(TimeLocal()),TimeToString(TimeCurrent()),~Column1~,~Column2~,~Column3~,~Column4~,~Column5~,~Column6~,~Column7~,~Column8~,~Column9~,~Column10~);
              FileClose(handle);
           }
        
           ~next~
        }
        

        The input parameters look like this:
        0_1541437442036_f2d4fea8-3d45-4f6b-ac3e-67817c384dc2-image.png

        0_1541437471619_baeebb89-3d40-4b91-9e35-26cd89eb3030-image.png

        0_1541437493272_82200b8c-cd82-4509-9368-c75de2169fe2-image.png

        0_1541437508181_c73d1ebc-eb76-4ccd-b2a1-b2b794ede0aa-image.png

        ... and for the others it is similar, only "Variable Name" has different number.... C2Title, Column2, C3Title, Column3 and so on.

        Parameters are added with that "New" button and separators are added with that "--" button

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post

        Online Users

        M
        S
        T
        O
        G
        B
        A
        P
        I
        M
        M
        J
        T
        S
        T
        M

        27
        Online

        146.7k
        Users

        22.4k
        Topics

        122.6k
        Posts

        Powered by NodeBB Forums | Contributors