Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 169
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Good afternoon. I can't read data from file and immediately write it back. If I uncomment a code fragment with loops and MathRand(), the file gets mush as it should be. But if lines are left commented out (already there is mess in the file), then the next time I enable/disable the Expert Advisor, the file will contain zeros. The read-write arrays are double ROM1[128][128] and double ROM2[3][128]. The arrays are not changed anywhere else in the code, only read. Here is a piece of code:
int init()
{
Print ("Сработала ф-ия init"); // Сообщение
Handle=FileOpen("Neuro",FILE_BIN|FILE_READ|FILE_WRITE);// Открытие файла на чтение и запись
FileSeek(Handle, 0, SEEK_SET); //указатель на начало файла
FileReadArray(Handle, ROM1);
FileSeek(Handle, 131073, SEEK_SET); //указатель на конец первого массива
FileReadArray(Handle, ROM2);
/*
for(i=0; i<128; i++) //заполнение памяти первого слоя кашей
{
for(k=0; k<128; k++)
{
ROM1[i][k] = (MathRand()-16383)/3200;
}
}
for(i=0; i<3; i++) //заполнение памяти второго слоя кашей
{
for(k=0; k<128; k++)
{
ROM1[i][k] = (MathRand()-16383)/3200;
}
}
*/
return(0);
}
//--------------------------------------------------------------------
int deinit()
{
FileSeek(Handle, 0, SEEK_SET);
FileWriteArray(Handle, ROM1);
FileSeek(Handle, 131073, SEEK_SET);
FileWriteArray(Handle, ROM2);
FileClose(Handle);
return(0);
}
two identical orders.
Thank you.
two identical orders.
Thank you.
You can search for a signal whenever you like but the opening of a position should be timed.
Watch the time of opening a position with magic 565 and watch the current time. If the current time is longer than the time of opening a position with magic 565 by the specified number of minutes, then you can open a position.
You can search for a signal whenever you want, but you must allow a position to be opened by time.
See the time of opening a position with magic 565 and see the current time. If the current time is longer than the opening time of Magik 565 by a given number of minutes, then the position may be opened.
Thank you very much. What does it look like in the code?
A little bit of it. The function won't read a two-dimensional array double, though it will write it correctly.
I have made a loop for element-by-element reading. May be, it may be of use to somebody.
FileSeek(Handle, n, SEEK_SET); //изменение позиции файлового курсора
Neuron[k][i].rom[l] = FileReadDouble(Handle, DOUBLE_VALUE); //загрузка из файла
n=n+8;
}
Thank you very much. What does it look like in code?
And this is not free code writing, but help for those who are trying to write them themselves, but can't get it right.
Show us what you can't do in your code - we'll help you.
I've worked it out a bit. The two-dimensional array double function does not want to read, although it writes fine.
I have made a loop-by-loop reading. Maybe someone will need it.
FileSeek(Handle, n, SEEK_SET); //изменение позиции файлового курсора
Neuron[k][i].rom[l] = FileReadDouble(Handle, DOUBLE_VALUE); //загрузка из файла
n=n+8;
}
Why should I offer such crutches to people, just because I haven't coped with the task myself?
To read a two-dimensional array from a file, it should be a two-dimensional array prepared for it.
If I remember that code sample correctly, I did not see that the file is closed after being written. An empty file is created and data are written into it but this filled file is stored in the main memory and the file data can only be read from the disk. As a result, the file looks like it has been written but physically it is not on the disk... In order to save the data to disk, one should either close the file or forcibly save it to disk.
And this is not free code writing, but help for those who are trying to write them themselves, but can't get it right.
Show us what you can't do in your code and we'll help.
thanks
Hello! Please write a simple (very simple) example in mql4. I am just a complete beginner.
1) open a pending order when it reaches a certain value (i.e. if the price is 0.7777, then open a pending order)
2) Close a market order when it has reached any value (i.e. if the price is 0.6666, then close the order).
I can't even close an order using a unique order number. I want to try to change the current state of my trading robot, but I don't understand anything.
I tried to read a tutorial from this site, but no effect (maybe I'm so stupid), and the elementary examples are somehow not on the Internet. Thanks in advance
Hello! Please write a simple (very simple) example in mql4. I am just a complete beginner.
1) open a pending order when it reaches any value (i.e. if the price is 0.7777, then open a pending order)
2) Close a market order when it has reached any value (i.e. if the price is 0.6666, then close the order).
I can't even close an order using a unique order number. I want to try to change the current state of my trading robot, but I don't understand anything.
I tried to read a tutorial from this site, but no effect (maybe I'm so stupid), and the elementary examples are somehow not on the Internet. Thanks in advance
If you have problems with pending orders, look for them on the CodeBase and see how the code is written.