Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1440

 
ANDREY:

Glad I could be of some help to you :=) :=) :=)

Now about my code, which is probably so bad that it is unpleasant to poke around in it. But tell me at least what would be the advantage of my code, if I had written a single array (with values of prices) of this code in a file and then the program would read it from this file and use its values in further calculations, with an array of only 60 elements. What exactly in my code would be optimal?
Thanks for your help.

It's not about the quality of code. I don't look at any other people's code. Except for what I need or in the agony of a bout of charity, :=))) but that happens less and less often...

If you like, you can describe in words what is needed as a result and what you did for it. Then it will be clear how much direction the problem is heading in the right direction.

 
Alexey Viktorov:

or in the agony of a bout of charity, :=))) ....

I have read that relapses may occur in early spring. I wish your remission were over sooner : =))).

And I wish your attacks were as frequent as possible..... :=)) :=)))

 
ANDREY:

Thanks for the tip. I've already started reading the FILE OPERATIONS section from Kovalev's textbook. Indeed... something is starting to become clear. I understood that all EAs I test read text files with bar prices (though not created by my program) with .cvv extension in Tester terminal directory.
In other words, information (data) from any program is written to the file and read this data from the file, also by any program. It seems to me that the files store large amount of data which is not reasonable to store in the program. Something like mqh file.
If you want to explain me what Alexey Victorov's phrase means : ".... Do you want to write .csv and read array....." from post with reference to my code from post
. I thought he meant the text file .cvv, with bar prices from the tester directory. But what exactly he means, I still do not understand. I'm not writing these .cvv files, but the Alpari dealer's program... How the program reads from an array - in general I understand a little ... It accesses a cell of an array by its address, gets inside the cell and accesses the value of the cell (i.e. reads it). How can a program read into an array instead of out of it? This is an unsolvable contradiction, ...., as it seems to me, in my layman's opinion. I think, for some reason, that in an array you can only write some values. And you can only read from an array.

Writing an array in binary has no Kovalev. The textbook is from 2009. There were only binfiles. And the array to bin file appeared later. Bin files are written and read faster. They don't have line feeds. But they are not readable for humans).

 
Valeriy Yastremskiy:

Kovalev does not have a bifile array record. The textbook is from 2009. There were only binfiles there. And array to bin file appeared later. Bin files are written and read faster. They don't have line feeds. But they are not readable for humans).

Thank you very much for the information, which is new to me. And I understand it 50%.... I will study this theme in depth, if I am sure I need it in my current stage of development.
At the moment I focused on my little code , trying to find the price minimum between 2 adjacent orders opened on one minute candle with 2 points difference, using minimal time and other computer resources. I have created an array for this purpose. Some people try to convince me here that this array must be written to a file using a function and then another function should be used to get data from the file (i.e., from the array) for further calculations.

But where would it be an advantage if I wrote a single array (with values of prices) of this code to a file, and then the program would read it from this file and use its values in subsequent calculations? And the array would only contain 60 elements. What would be optimal in my code, exactly?

Naturally in the course of testing, There will be a lot of such orders inside the minute candles, between which we will need to calculate the minimum, there will be a lot of them.. My code is just an illustration of an idea that came to me.
Alexey Viktorov cannot answer this question because he has not yet had an attack of charity .... and he hasn't had the agony and convulsions in connection with it :=).
Maybe you already have all the prerequisites in place to help me move forward.


Thank you for your help.

 
ANDREY:

it is difficult to understand the creator of the Grail. It is possible to pass all calculations to the Indicator and get a signal into the Expert Advisor.

 
ANDREY:

Thank you very much for the information which is new to me. And I understood 50% of it.... And if I am sure I need it at this stage of my development, I will study this topic thoroughly.
At the moment I focused on my code , trying to find the price minimum between 2 adjacent orders opened on one minute candle with 2 points difference, using minimal time and other computer resources. For this I have created an array. Some people try to convince me here that this array must be written to a file using a function and then another function should be used to get data from the file (i.e., from the array) for further calculations.

But where would it be an advantage if I wrote a single array (with values of prices) of this code to a file, and then the program would read it from this file and use its values in subsequent calculations? And the array would only contain 60 elements. What would be optimal in my code, exactly?

Of course, in the course of testing, There will be a lot of such orders inside the minute candlesticks between which we will have to calculate the minimum, there will be a lot of them.. My code is just an illustration of an idea that came to me.
Alexei Viktorov cannot answer this question, because he has not yet had a charitable attack .... and he hasn't had the agony and convulsions in connection with it :=).
Maybe you already have all the prerequisites in place to help me move forward.


Thank you for your help.

I do not understand the logic a bit. Why would you need to write a couple of data in an array? You can write them in variables. An array is when there are many variables of the same type. And if there are less than 5 of them, you can store them in variables. Why should the data stored in the array be written to a file that can be read later in the same Expert Advisor? They are available anyway. They are written in the file for exchange between different Expert Advisors or for further processing, not in this EA. In addition, the array is always global, if I'm not mistaken.

 
ANDREY:

Thank you very much for the information which is new to me. And I understood 50% of it.... And if I am sure I need it at this stage of my development, I will study this topic thoroughly.
At the moment I focused on my code , trying to find the price minimum between 2 adjacent orders opened on one minute candle with 2 points difference, using minimal time and other computer resources. I have created an array for this purpose. Some people try to convince me here that this array must be written to a file using a function and then another function should be used to get data from the file (i.e., from the array) for further calculations.

But where would it be an advantage if I wrote a single array (with values of prices) of this code to a file, and then the program would read it from this file and use its values in subsequent calculations? And the array would only contain 60 elements. What would be optimal in my code, exactly?

Naturally, during testing, There will be a lot of such orders inside the minute candlesticks between which we will need to calculate the minimum, there will be a lot of them.. My code is just an illustration of an idea that came to me.
Alexei Viktorov cannot answer this question, because he has not yet had a charitable attack .... and he hasn't had the agony and convulsions in connection with it :=).
Maybe you already have all the prerequisites in place to help me move forward.


Thanks for the help.

The beginning is so far, that it's difficult to answer in details... But I will try to be clever nevertheless...

If I remember correctly, you have to determine when the Low was formed on the candle in which the order was opened. When this candlestick is current, it is no problem: we put the smaller of the two numbers into the variable and do this until the candlestick closes. But if we need to determine it when this candle is already the 10th, then it is already a problem for mql4. It's very easy to do it in mql5, just copy the ticks "from and to" the time and everything is in the array. But for mql4, you have been suggested to write the ticks to a file, so that later you may get these ticks and use this array to determine if the Low of that candlestick is lower than the minimum value in the array, it means that Low was before the order was opened. If they are equal, it means that Low was formed after the order was opened.

However... if the EA works, it is enough to determine it in a variable, as it is described here; there is a function for this purpose that you can read about in the documentation in the Mathematical Functions section; if the EA does not work for some reason, it will not record ticks and will not even get them.

 
Alexey Viktorov:

The beginning is so far away that it's hard to answer in detail... But I'll try to be clever...

If I remember correctly, you have to determine when the Low of the candle was formed on which the order was opened. When this candlestick is current, it is no problem: we put the smaller of the two numbers into the variable and do this until the candlestick closes. But if we need to determine it when this candle is already the 10th, then it is already a problem for mql4. It's very easy to do it in mql5, just copy "from and to" the selected time ticks, and the array will contain everything you need. But for mql4, you have been suggested to write the ticks to a file, so that later you may get these ticks and use this array to determine if the Low of that candlestick is lower than the minimum value in the array, it means that Low was before the order was opened. If they are equal, it means that Low was formed after the order was opened.

However... if the EA works, it is enough to store it in a variable, as it is described here, there is a function for this purpose that you can read about in the documentation in section Mathematical Functions.

Thank you very much for the new information for me.... especially about mql4 capabilities compared to mql5 in this case. However, strange as it may seem, the task you describe, I have solved it myself and the way it was solved I was surprised with its originality and optimality.
After that I faced another similar problem
I was told to write ticks to a file,

Instead of writing ticks to a file, I created a code, which solves my task without writing ticks to a fileUsing this code, I try to find the price minimum between 2 adjacent orders opened at one minute candle with 2 points difference using theleast time and other computer resources. Of course, there will be a lot of such ordersinside one-minute candlesticks between which we will have to calculate the minimum. This is just an illustration of my idea.

And now I am interested in the answer to the question What would be the advantage of my code if I had written ticks to a file, as you advised me?What exactly would be optimal in my code?


On this question was shed light by Valeriy Yastremskiy But I'd like to listen to feedback from someone who advised me to put ticks into a file.
Thanks for the help.

 
Valeriy Yastremskiy:

The logic is a little unclear. Why write pairs of data in an array. you can write them in variables. An array is when there are many variables of the same type. And if there are less than 5 of them, you can store them in variables. Why should the data stored in the array be written to a file that can be read later in the same Expert Advisor? They are available anyway. They are written in the file for exchange between different Expert Advisors or for further processing, not in this EA. In addition, the array is always global, if I'm not mistaken.

Thanks for the tip. I agree, sometimes there can be 5 or less ticks. But in one minute candle there can be many more ticks than seconds and their number between adjacent orders can also be much more than 5.
I was particularly pleased that my thoughts coincided with the highlighted red. But I was unsure of them as more experienced comrades reinforced my uncertainty.

 
ANDREY:

Thank you very much for the new information for me.... especially about mql4 capabilities compared to mql5 in this case. However, strange as it may seem, I have solved the problem described above myself and I was surprised with its originality and optimality .
Then I faced another similar problem formulated in this post.

every tick. I also know how to do it with a cycle at the time of X+2. And how to do it all at once at the time of X+2 as in the case of iLow andiLowest.
I would be very grateful if you could teach me how to do this.
Thanks


I have been advised to record ticks in a file

Forum on trading, automated trading systems and testing trading strategies.

Any questions from newbies about MQL4 and MQL5, help and discussion of algorithms and codes

Alexey Viktorov, 2021.04.09 18:33

You may. You should write in your .bin file using the

uint  FileWriteArray( 
   int          file_handle,         // handle файла 
   const void&  array[],             // массив 
   int          start=0,             // начальный индекс в массиве 
   int          count=WHOLE_ARRAY    // количество элементов 
   );

and read

uint  FileReadArray( 
   int    file_handle,               // handle файла 
   void&  array[],                   // массив для записи 
   int    start=0,                   // стартовая позиция для записи в массив 
   int    count=WHOLE_ARRAY          // сколько читать 
   );

I've created code that solves my problem without writing ticks to a file instead of writing them to a file

writing it to a file? As in my code. This is not a working code but to illustrate my idea of how to find the minimum between two adjacent orders opened on one minute candlestick
Thanks for the help.

double P[60],Z;
int Tick,x,x1,G,G1,G2,T;

void OnTick()
{
Tick++;

if (OrdersTotal()==1&&Tick<2189)
{
P[x]=Bid;
Print("------------------------P[x]=Bid------------------------=", DoubleToString(P[x],5), "  x ",  x);
x++;
}
if (OrdersTotal()==2&&Tick==2189)
{
x1=x;
x=0;
ArraySort(P,WHOLE_ARRAY,0,MODE_ASCEND);
T=(60-x1);
Print("------------------------МИНИМУМ=------------------------=",DoubleToString(P[T],5), "  Tick ",  Tick, "  x1 ",  x);
}

if (Tick==2176||Tick==2188)
{
OrderSend(Symbol(),OP_SELL,0.1,Bid, 3,Ask+300*Point,Ask-100*Point,"300",0);
G2=G;
G=Tick;
}
}

It means I wrote prices of each tick directly into an array, not into a file.


Withthis code, I try to find the price minimum between two adjacent orders opened on one minute candle with a 2-point differenceusing the least time and other computer resources. Of course, there will be a lot of such ordersinside one-minute candlesticks between which we will have to calculate the minimum. This is just an illustration of my idea.

And now I am interested in the answer to the question What would be the advantage of my code if I had written ticks to a file, as you advised me?What exactly would be optimal in my code?


On this question was shed light by Valeriy Yastremskiy But I'd like to listen to feedback from someone who advised me to put ticks into a file.
Thanks for the help.

In order not to strain trying to help, in particular me, it is better to put the message "in your pocket" and paste it instead of linking to it.

Now about this problem: Order #1 has opened... at this point Low is of course lower than the open price of the order. Well, let's face it...

The order number 2 is opened and we should control the price at........., using the mathematical function fmin() we again write in the variable the value before the close of the candle. Once the candle is closed, we stop price control, we don't need it anymore. The value obtained will be the minimum price in the time interval between the second order opening and the candle closing. Or maybe I've got it wrong...