Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 659
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
I also found a serious drawback, too many calls to CopyClose()
Can you tell me how to copy quotes from an array of currency pairs in a loop?
That would appear to be a double array, that's why MQL doesn't support it, like %.
MQL4 seems to work with two-dimensional dynamic arrays. You should change the first dimension with ArayResize(), and pass the second one toCopyClose()
Or a universal solution from the developers, because two-dimensional dynamic arrays do not work in MQL5, wrap a one-dimensional array in a structure and create an array of such structures.... If you get the hang of it, consider that you've almost created a class, and it's more optimal - a class with methods that load the data and store it in the class properties (fields)MQL4 seems to work with two-dimensional dynamic arrays, use ArayResize() to change the first dimension andCopyClose() to change the second.
or a universal solution from the developers, because 2-dimensional dynamic arrays do not work in MQL5, wrap a one-dimensional array in a structure and create an array of such structures.... If you get the hang of it, consider that you've almost created a class, and it's more optimal - the class with the method that loads the data and stores it in the class properties (fields)Thank you and I will try
Another question about the indicator, I don't know what else to do here
I need to print the difference between closing of the pairs entered and the moving average of them.
I do not know what else to do.
Orders should be enumerated in a loop, not on every tick... To be more precise, a tick came and all of your orders are counted in the loop: for(j=0;j<OrderTotal;j++)
OrdersTotal() shows how many orders are open (including pending orders, including orders on all symbols... in total... Here is how many orders are opened in the terminal - this is how many )))).
The order numbering is like in the arrays, from 0 to OrdersTotal()-1 - this is the last order, and you probably have a non-existent ticket number [OrdersTotal()] or some other information in the journal on every tick, which is difficult to guess.
Yes I do - and I want it to go through all the orders. The function was a bit different at first, but I've simplified it as much as possible in the hope of finding the cause and fixing it. Full consecutive retracement only happens when ticks are rare or after I remove the EA from the chart and no new ticks come in.
I always thought that if the EA has entered the body of a function, it should not react to other ticks until it exits the loop, but it seems that this is not the case. How can I get around this situation?
int test()
{
int total;
total = OrdersTotal();
log("total = " + total +"; ");
for (int j = 0; j < total; j++)
{
log("j = " + j +"; ");
}
return(0);
}
Why do we even need information on all orders every tick? Wouldn't it be better to introduce restrictions on order viewing, e.g. every new minute, five minutes, ..., hour?
The problem is not even that I need information for every tick, but that, if I understand correctly, the loop does not have time to finish before a new tick arrives and the new tick somehow breaks the account. Here's another screenshot, so that you don't have to look for the previous one. It shows that the EA has counted up to 52 and then jumped to 93. I had a hard time believing that this is because of new ticks, but I cannot find any other reason, because with rare ticks the account finishes fine, as well as the last cycle after the EA was removed from the chart.
I have already simplified the code as much as possible:
int test()
{
int total;
total = OrdersTotal();
log("total = " + total +"; ");
for (int j = 0; j < total; j++)
{
log("j = " + j +"; ");
}
return(0);
}
How do you know that? It doesn't.
Until all calculations that started with the arrival of the tick are completed, all subsequent ticks are skipped.
As I wrote just above, I have the same situation, only I have already simplified it to a point and come to the conclusion that not only can I not normally do any calculation, but just go through the orders one by one and print their numbers in the log.
I too have always believed that "Until all calculations that started with the arrival of a tick have been completed, all subsequent ticks are skipped". I wish it were so, but I can't find any other reason, other than new ticks, yet.
No one will tell without the code.
Here is an extremely simplified code, which has the same problem - new ticks throw off successive output of order numbers.
int test()
{
int total;
total = OrdersTotal();
log("total = " + total +"; ");
for (int j = 0; j < total; j++)
{
log("j = " + j +"; ");
}
return(0);
}
Here is an extremely simplified code that has the same problem - new ticks throw off the sequential output of order numbers.
int test()
{
int total;
total = OrdersTotal();
log("total = " + total +"; ");
for (int j = 0; j < total; j++)
{
log("j = " + j +"; ");
}
return(0);
}
Another question about the indicator, I don't know what else to do here
I need to print the difference between closing of the pairs entered and the moving average of them.
In the end it just displays the difference without MA, what is the problem?
This is cool!
Roman!
I, for example, am a successful trader with 20 years of experience.
I do not understand why you need "the difference between the closes of the pairs entered, anda moving average of them".
Moreover, do you know how to build a moving average of these differences? - Fantastic!
Can you simply draw the moving average of the quotes? - Also no?
So what is the problem?
Here is an extremely simplified code which has the same problem - new ticks throw off the sequential output of order numbers.
int test()
{
int total;
total = OrdersTotal();
log("total = " + total +"; ");
for (int j = 0; j < total; j++)
{
log("j = " + j +"; ");
}
return(0);
}
this code works, do it by analogy: