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

 
Igor Makanu:

this code works, do it by analogy:

Made minimal changes - removed OrderMagicNumber() analysis and added three logs.
The result, unfortunately, is the same - see pr. - On the first screenshot it starts (I don't know why it doesn't start with 0), and on the second one it starts with 124 to 99.

int NumberOfOrders()
{
int i,res=0,k=OrdersTotal(); string sy=Symbol();

for(i=0; i<k; i++)
{
log("k = " + k +"; ");
log("i = " + i +"; ");
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if((OrderSymbol()==sy)) res++; //if((OrderMagicNumber()==magic_) && (OrderSymbol()==sy)) res++;
log("res = " + res +"; ");

}
}
return(res);
}

Files:
test_1.png  6 kb
test_2.png  6 kb
 
Alexey Viktorov:
Does this code really compile without errors??? I don't believe it...
What makes you doubt it? In any case, MQL4 does not produce any errors.
 
Algotrader18:

(it's unclear why it doesn't start with 0), and on the second place where it comes from 124 to 99.

because the terminal "ate" a part of Print(), output in MQL has the lowest priority, add Slepp(123) before Print() and there will be no skips

although according to the log you are just printing the loop counter

 
Igor Makanu:

because the terminal "ate" part of Print(), in MQL output has the lowest priority, add Slepp(123) before Print() and there will be no skips

although according to the log you are just printing the loop counter

This is very interesting - can you be a little more specific? How does this process of "eating" happen?

Your reply gives me an impression that I "ate" it simply means that I didn't log it because there were more important things, but my real task was to go through all orders and delete certain ones and I noticed that the EA was skipping some of them (this was not outputting information with the lowest priority). I simplified the task to understand the reason and as a result, we have only the output in the log, but I still see omitted orders, i.e. the Expert Advisor jumps over several orders. The lowest order priority explains very well that the output does not start from 0 but this may explain inconsistent output when it jumps from 124 to 99, for example.

If by "ate" we mean something else, I would like to understand what?
Files:
test_2.png  6 kb
 
neverness:

That's awesome!

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 you have 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's the problem?

the difference in close averages does not equal the difference in close averages, alas and ah

 
Algotrader18:
What are the doubts? Anyway, no errors in MQL4.

1. Learn how to insert code.

Algotrader18:

I made minimal changes - removed OrderMagicNumber() analysis and added three logs.
The result, unfortunately, is the same - see above. - On the first screenshot the beginning (I don't know why it doesn't start with 0), and on the second one - the place where it starts with 124 to 99.

int NumberOfOrders()
  {
   int i,res=0,k=OrdersTotal(); string sy=Symbol();
  
   for(i=0; i<k; i++)
     {
      log("k = " + k +"; ");
      log("i = " + i +"; ");
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if((OrderSymbol()==sy)) res++;  //if((OrderMagicNumber()==magic_) && (OrderSymbol()==sy)) res++;
         log("res = " + res +"; ");
        
        }
     }
   return(res);
  }

2. log is a logarithm???

Note

You can use log()instead of MathLog().

MathLog - Математические функции - Справочник MQL4
MathLog - Математические функции - Справочник MQL4
  • docs.mql4.com
MathLog - Математические функции - Справочник MQL4
 
Roman Sharanov:

I also found a serious drawback, there are too many CopyClose() calls

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, but MQL doesn't support it, like %.

What do you mean by "double array"?

 
Alexey Viktorov:

What do you mean by 'double array'?

Well, two-dimensional.

 
Roman Sharanov:

Well two-dimensional.

Where is it written that CopyClose copies data into a 2D array? Why was the 2D array mentioned in the first place?

 
Alexey Viktorov:

Where is it written that CopyClose copies data to a 2D array? Why was the two-dimensional array mentioned?

Because I need to store arrays of quotes in an array

In order to copy it once in a loop and then to perform calculations using ArrayCopy, but not CloseCopy

Reason: