After MetaEditor Update my script have erros - page 2

 

only one solution, close all, disconect internet, open an old version platform wher your EA was running as normal, and reconnect internet and NO PROBLEM

but dont forget to disconnect internet when you open platform because now MQ4 will upgrade automaticaly without your autorisation

A copy of build 500 will be very expensive now, if you need I can send you some

 
bisewski:
This is my entire code.

Ok, so it's WriteFile from WinApi. This function is independent from ANSI or UNICODE. Anyway your code doesn't compile, so I can't test it.

How are you checking the number of lines of your CSV files ?

Are you opening it with a texteditor ?

 
eliot:

only one solution, close all, disconect internet, open an old version platform wher your EA was running as normal, and reconnect internet and NO PROBLEM

but dont forget to disconnect internet when you open platform because now MQ4 will upgrade automaticaly without your autorisation

A copy of build 500 will be very expensive now, if you need I can send you some


Can you please stop your off-topic comments ? Or I have to take measures.
 
string pathName="D:\\Forex\\Dados\\"+paridade;
                           string FullName;
                           string Buffer_Old = "vazio";
                           string Buffer_New = NULL;
                           for(int in=0; in<6; in++){ //o in aqui vai me dar uma nova posição no array que contém os dados para guardar e pegar os dados no csv
                               periodo = StrToInteger(StringSpliter(Pairs_Time_Infos[in],"@",0)); //pode ser 1,5,15,60,1440,10080.
                               bars_count = StrToInteger(StringSpliter(Pairs_Time_Infos[in],"@",2)); //200,200,3461,3461,1000,587.
                               FullName=pathName+StringSpliter(Pairs_Time_Infos[in],"@",1); //Um.csv,Cinco.csv,Quinze.csv...
                               RefreshRates();
                               Print(bars_count);
                               //MessageBox(TimeToStr(iTime(paridade,periodo,bars_count), TIME_DATE));
                               
                               if (TimeToStr(iTime(paridade,periodo,bars_count), TIME_DATE) != "1970.01.01"){
                                  //Data;Hora;Open;Close;High;Low
                                  Buffer_Old = TimeToStr(iTime(paridade,periodo,bars_count), TIME_DATE) + "," + TimeToStr(iTime(paridade,periodo,bars_count), TIME_MINUTES)+ "," + DoubleToStr(iOpen(paridade,periodo,bars_count),5) + "," + DoubleToStr(iClose(paridade,periodo,bars_count),5) + "," + DoubleToStr(iHigh(paridade,periodo,bars_count),5) +  "," + DoubleToStr(iLow(paridade,periodo,bars_count),5);
                               }else{
                                  Buffer_Old = "vazio";
                               }
                               
                for(int k=(bars_count-1);k >=0;k--) //vai dar um loop nos candle e ir somando os valores no Buffer_old.
                   {
                      if (TimeToStr(iTime(paridade,periodo,k), TIME_DATE) != "1970.01.01"){
                         if (Buffer_Old == "vazio"){
                            Buffer_Old = TimeToStr(iTime(paridade,periodo,k), TIME_DATE) + "," + TimeToStr(iTime(paridade,periodo,k), TIME_MINUTES)+ "," + DoubleToStr(iOpen(paridade,periodo,k),5) + "," + DoubleToStr(iClose(paridade,periodo,k),5) + "," + DoubleToStr(iHigh(paridade,periodo,k),5) +  "," + DoubleToStr(iLow(paridade,periodo,k),5);
                         }else{
                            Buffer_New =TimeToStr(iTime(paridade,periodo,k), TIME_DATE) + "," + TimeToStr(iTime(paridade,periodo,k), TIME_MINUTES)+ "," + DoubleToStr(iOpen(paridade,periodo,k),5) + "," + DoubleToStr(iClose(paridade,periodo,k),5) + "," + DoubleToStr(iHigh(paridade,periodo,k),5) +  "," + DoubleToStr(iLow(paridade,periodo,k),5);
                            Buffer_Old = Buffer_Old + "\r\n" + Buffer_New;
                            RefreshRates();
                         }
                      }
                   }//Fecha for(int k=0;k<=bars_count;k++)
                
                int ShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
                int fWrite= CreateFileW(FullName, GENERIC_WRITE, ShareMode, 0, CREATE_ALWAYS, 0, 0);
                //return fWrite = 1400;
                if (fWrite == INVALID_HANDLE_VALUE)
                   {
                      Print("Unable to open " + FullName + " for writing");
                   }else{
                      int BytesWritten[1] = {0};
                      
                      Buffer_Old = "Teste de texto";
                      int szData = StringLen(Buffer_Old);
                      //return szData = 14
                      //WriteFile(fWrite, MulDiv(Buffer_Old, 1, 1), szData, BytesWritten, NULL);
                      int teste = WriteFile(fWrite, Buffer_Old, szData, BytesWritten, NULL);
                      //return teste = 1;
                      CloseHandle(fWrite);
                      Print(StringSpliter(Pairs_Time_Infos[in],"@",1) + " was saved.");
                   }//Fecha o Else do if (!IsValidFileHandle(fWrite))
                           }//for(int in=0; in<6; in++){

only half of the text is saved in .csv file. "Teste d" only 7 characters.

I put in code in red some results if to help to understand...I will to continue testing...and I will posting the results...

yes, I opened in notepad windows. No problems like before, with the Nulls charactes, but only the half text "Teste de texto" are saved.

 

if I multiply by 2 szData all the text is saved. Not make sense for me...

int teste = WriteFile(fWrite, Buffer_Old, 2*szData, BytesWritten, NULL);
 
bisewski:

if I multiply by 2 szData all the text is saved. Not make sense for me...

WriteFile() function copy a number of byte, independently of encoding (ANSI or Unicode). So you have to pas the number of byte as parameter and not the number of characters. Sorry for not seeing it earlier.
 
bisewski:

Hi Everybody.

I dont understandin why my script that ran perfectly now have erros.

My metaeditor was updated to 5 but not to mql5, continue being mql4.

But now I have an error here:

This code always run perfectly and now, after this update, get error.

Any change happens in new version? The exactly version is 5.00 Build 883.

Thanks


hello. i have code

#define GENERIC_READ                   0x80000000
#define GENERIC_WRITE                  0x40000000
#define PIPE_ACCESS_DUPLEX             3
#define PIPE_UNLIMITED_INSTANCES       255
#define PIPE_NOWAIT                    1
#define PIPE_TYPE_MESSAGE              4
#define PIPE_READMODE_MESSAGE          2
#define PIPE_WAIT                      0

#import "kernel32.dll"
   int CreateNamedPipeW(string pipeName,int openMode,int pipeMode,int maxInstances,int outBufferSize,int inBufferSize,int defaultTimeOut,int security);
#import

CreateNamedPipeW("\\\\..\\pipe\\mt4-pricetaker", GENERIC_READ | PIPE_ACCESS_DUPLEX, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_NOWAIT, PIPE_UNLIMITED_INSTANCES, 1000, 1000, 0, NULL)
don't work. return -1. what am I doing wrong?
 
mmmoguschiy:
CreateNamedPipeW("\\\\..\\pipe\\mt4-pricetaker", GENERIC_READ | PIPE_ACCESS_DUPLEX, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_NOWAIT, PIPE_UNLIMITED_INSTANCES, 1000, 1000, 0, NULL)
don't work. return -1. what am I doing wrong?
Named pipes have the form:
You have:
\\..\pipe\mt4-pricetaker
 
WHRoeder:
Named pipes have the form:
You have:
\\..\pipe\mt4-pricetaker


sorry, wrong wrote. the second point is superfluous. but still does not work
 

Yes, all right! Fixed:

CreateNamedPipeW("\\\\.\\pipe\\mt4-pricetaker", GENERIC_READ | PIPE_ACCESS_DUPLEX, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_NOWAIT, PIPE_UNLIMITED_INSTANCES, 1000, 1000, 0, NULL)
but still does not work! please help with this!
Reason: